summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/webapi/invalid-args.any.js
blob: b27e018a984e398b6c001426abdf8cfdc641f782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// META: global=window,worker

const invalidArguments = [
  [undefined],
  [null],
  [true],
  ["test"],
  [Symbol()],
  [0],
  [0.1],
  [NaN],
  [{}, "Empty object"],
  [Response, "Response interface object"],
  [Response.prototype, "Response interface prototype object"],
];

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

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