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

const invalidArguments = [
  [() => new Response(undefined, { headers: { "Content-Type": "application/wasm" } }), "no body"],
  [() => new Response("", { headers: { "Content-Type": "application/wasm" } }), "empty body"],
];

for (const method of ["compileStreaming", "instantiateStreaming"]) {
  for (const [argumentFactory, name] of invalidArguments) {
    promise_test(t => {
      const argument = argumentFactory();
      return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](argument));
    }, `${method}: ${name}`);

    promise_test(t => {
      const argument = Promise.resolve(argumentFactory());
      return promise_rejects_js(t, WebAssembly.CompileError, WebAssembly[method](argument));
    }, `${method}: ${name} in a promise`);
  }
}