Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /wasm/webapi/invalid-code.any.html - WPT Dashboard Interop Dashboard
- /wasm/webapi/invalid-code.any.serviceworker.html - WPT Dashboard Interop Dashboard
- /wasm/webapi/invalid-code.any.sharedworker.html - WPT Dashboard Interop Dashboard
- /wasm/webapi/invalid-code.any.worker.html - WPT Dashboard Interop Dashboard
// 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}`);
}