summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/body.any.js
blob: 4db7e8d123cfb6bba8b2a429cd5bc6ac1efb89ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// META: global=window,worker
// META: script=/wasm/jsapi/wasm-module-builder.js

for (const method of ["compileStreaming", "instantiateStreaming"]) {
  promise_test(t => {
    const buffer = new WasmModuleBuilder().toBuffer();
    const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
    argument.arrayBuffer();
    return promise_rejects_js(t, TypeError, WebAssembly[method](argument));
  }, `${method} after consumption`);

  promise_test(t => {
    const buffer = new WasmModuleBuilder().toBuffer();
    const argument = new Response(buffer, { headers: { "Content-Type": "application/wasm" } });
    const promise = WebAssembly[method](argument);
    argument.arrayBuffer();
    return promise_rejects_js(t, TypeError, promise);
  }, `${method} before consumption`);
}