summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcos Casagrande <marcoscvp90@gmail.com>2022-10-14 11:38:17 +0200
committerGitHub <noreply@github.com>2022-10-14 11:38:17 +0200
commit0d6dbc08bec50aa1548703bf53dc632e0aeefbd6 (patch)
treeccf55e35bfc94895f9513c7f5b5189e2177f9aff
parent50c7b893692fb6563952ab18ef8ad0f682944976 (diff)
fix(ext/fetch): throw TypeError on non-Uint8Array chunk (#16262)
-rw-r--r--ext/web/06_streams.js6
-rw-r--r--tools/wpt/expectation.json2
2 files changed, 8 insertions, 0 deletions
diff --git a/ext/web/06_streams.js b/ext/web/06_streams.js
index 933d7b09c..361e5e055 100644
--- a/ext/web/06_streams.js
+++ b/ext/web/06_streams.js
@@ -813,6 +813,12 @@
const { value: chunk, done } = await reader.read();
if (done) break;
+ if (!ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk)) {
+ throw new TypeError(
+ "Can't convert value to Uint8Array while consuming the stream",
+ );
+ }
+
ArrayPrototypePush(chunks, chunk);
totalLength += chunk.byteLength;
}
diff --git a/tools/wpt/expectation.json b/tools/wpt/expectation.json
index e9dfa03d0..558ada79a 100644
--- a/tools/wpt/expectation.json
+++ b/tools/wpt/expectation.json
@@ -3003,6 +3003,8 @@
"response-static-error.any.worker.html": true,
"response-static-redirect.any.html": true,
"response-static-redirect.any.worker.html": true,
+ "response-stream-bad-chunk.any.html": true,
+ "response-stream-bad-chunk.any.worker.html": true,
"response-stream-disturbed-1.any.html": true,
"response-stream-disturbed-1.any.worker.html": true,
"response-stream-disturbed-2.any.html": true,