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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
// META: global=window,dedicatedworker,jsshell
test(() => {
const thisValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
WebAssembly.Table,
WebAssembly.Table.prototype,
];
const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length");
assert_equals(typeof desc, "object");
const getter = desc.get;
assert_equals(typeof getter, "function");
assert_equals(typeof desc.set, "undefined");
for (const thisValue of thisValues) {
assert_throws_js(TypeError, () => getter.call(thisValue), `this=${format_value(thisValue)}`);
}
}, "Branding");
test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");
const desc = Object.getOwnPropertyDescriptor(WebAssembly.Table.prototype, "length");
assert_equals(typeof desc, "object");
const getter = desc.get;
assert_equals(typeof getter, "function");
assert_equals(getter.call(table, {}), 2);
}, "Stray argument");
test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");
table.length = 4;
assert_equals(table.length, 2, "Should not change the length");
}, "Setting (sloppy mode)");
test(() => {
const argument = { "element": "anyfunc", "initial": 2 };
const table = new WebAssembly.Table(argument);
assert_equals(table.length, 2, "Initial length");
assert_throws_js(TypeError, () => {
"use strict";
table.length = 4;
});
assert_equals(table.length, 2, "Should not change the length");
}, "Setting (strict mode)");
|