blob: 37373d49971a3d89b04720cc10669f4929fc9142 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// META: global=window,worker
// META: script=/wasm/jsapi/wasm-module-builder.js
let emptyModuleBinary;
setup(() => {
emptyModuleBinary = new WasmModuleBuilder().toBuffer();
});
for (const method of ["compileStreaming", "instantiateStreaming"]) {
promise_test(t => {
const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0, 0]));
const response = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](response));
}, `Invalid code (0x0000): ${method}`);
promise_test(t => {
const buffer = new Uint8Array(Array.from(emptyModuleBinary).concat([0xCA, 0xFE]));
const response = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](response));
}, `Invalid code (0xCAFE): ${method}`);
}
|