• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// META: global=window,dedicatedworker,jsshell
2
3test(() => {
4  const thisValues = [
5    undefined,
6    null,
7    true,
8    "",
9    Symbol(),
10    1,
11    {},
12    WebAssembly.Table,
13    WebAssembly.Table.prototype,
14  ];
15
16  const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length");
17  assert_equals(typeof desc, "object");
18
19  const getter = desc.get;
20  assert_equals(typeof getter, "function");
21
22  assert_equals(typeof desc.set, "undefined");
23
24  for (const thisValue of thisValues) {
25    assert_throws_js(TypeError, () => getter.call(thisValue), `this=${format_value(thisValue)}`);
26  }
27}, "Branding");
28
29test(() => {
30  const argument = { "element": "anyfunc", "initial": 2 };
31  const table = new WebAssembly.Table(argument);
32  assert_equals(table.length, 2, "Initial length");
33
34  const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length");
35  assert_equals(typeof desc, "object");
36
37  const getter = desc.get;
38  assert_equals(typeof getter, "function");
39
40  assert_equals(getter.call(table, {}), 2);
41}, "Stray argument");
42
43test(() => {
44  const argument = { "element": "anyfunc", "initial": 2 };
45  const table = new WebAssembly.Table(argument);
46  assert_equals(table.length, 2, "Initial length");
47  table.length = 4;
48  assert_equals(table.length, 2, "Should not change the length");
49}, "Setting (sloppy mode)");
50
51test(() => {
52  const argument = { "element": "anyfunc", "initial": 2 };
53  const table = new WebAssembly.Table(argument);
54  assert_equals(table.length, 2, "Initial length");
55  assert_throws_js(TypeError, () => {
56    "use strict";
57    table.length = 4;
58  });
59  assert_equals(table.length, 2, "Should not change the length");
60}, "Setting (strict mode)");
61