From 6ced7b0383769807bdd864ebbf6a16a418d3f821 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 16 Aug 2021 12:53:30 +0200 Subject: fix(ext/fetch): better error if no content-type The streaming WASM support code inspects the Response object's Content-Type header but if that was missing, it failed with a fairly inscrutable "String.prototype.toLowerCase called on null or undefined" exception. Now it raises a more legible "Invalid WebAssembly content type" exception. --- cli/tests/unit/wasm_test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'cli/tests/unit') 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) { -- cgit v1.2.3