diff options
-rw-r--r-- | cli/tests/unit/wasm_test.ts | 13 | ||||
-rw-r--r-- | ext/fetch/26_fetch.js | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/cli/tests/unit/wasm_test.ts b/cli/tests/unit/wasm_test.ts index c2180db3c..938eeab7a 100644 --- a/cli/tests/unit/wasm_test.ts +++ b/cli/tests/unit/wasm_test.ts @@ -48,6 +48,19 @@ unitTest( }, ); +unitTest( + async function wasmInstantiateStreamingNoContentType() { + await assertThrowsAsync( + async () => { + const response = Promise.resolve(new Response(simpleWasm)); + await WebAssembly.instantiateStreaming(response); + }, + TypeError, + "Invalid WebAssembly content type.", + ); + }, +); + unitTest(async function wasmInstantiateStreaming() { let isomorphic = ""; for (const byte of simpleWasm) { diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 2d7180691..edd14abf1 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -503,9 +503,10 @@ // The spec is ambiguous here, see // https://github.com/WebAssembly/spec/issues/1138. The WPT tests // expect the raw value of the Content-Type attribute lowercased. + const contentType = res.headers.get("Content-Type"); if ( - StringPrototypeToLowerCase(res.headers.get("Content-Type")) !== - "application/wasm" + typeof contentType !== "string" || + StringPrototypeToLowerCase(contentType) !== "application/wasm" ) { throw new TypeError("Invalid WebAssembly content type."); } |