summaryrefslogtreecommitdiff
path: root/cli/tests/unit/wasm_test.ts
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2021-08-16 12:53:30 +0200
committerLuca Casonato <lucacasonato@yahoo.com>2021-08-16 19:45:37 +0200
commit6ced7b0383769807bdd864ebbf6a16a418d3f821 (patch)
tree13a5010e4a67edf7a42d4046cc0205b3ad1c5d09 /cli/tests/unit/wasm_test.ts
parent6ddabb742757e1031f04b896c6f319dd0dadbc73 (diff)
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.
Diffstat (limited to 'cli/tests/unit/wasm_test.ts')
-rw-r--r--cli/tests/unit/wasm_test.ts13
1 files changed, 13 insertions, 0 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) {