summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/wasm/jsapi/memory/constructor-shared.tentative.any.js
blob: 216fc4ca55591f1fa412aeadf5fd538c3afa0af3 (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
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
// META: global=window,dedicatedworker,jsshell
// META: script=/wasm/jsapi/assertions.js
// META: script=/wasm/jsapi/memory/assertions.js

test(() => {
  assert_throws_js(TypeError, () => new WebAssembly.Memory({ "initial": 10, "shared": true }));
}, "Shared memory without maximum");

test(t => {
  const order = [];

  new WebAssembly.Memory({
    get maximum() {
      order.push("maximum");
      return {
        valueOf() {
          order.push("maximum valueOf");
          return 1;
        },
      };
    },

    get initial() {
      order.push("initial");
      return {
        valueOf() {
          order.push("initial valueOf");
          return 1;
        },
      };
    },

    get shared() {
      order.push("shared");
      return {
        valueOf: t.unreached_func("should not call shared valueOf"),
      };
    },
  });

  assert_array_equals(order, [
    "initial",
    "initial valueOf",
    "maximum",
    "maximum valueOf",
    "shared",
  ]);
}, "Order of evaluation for descriptor (with shared)");

test(() => {
  const argument = { "initial": 4, "maximum": 10, shared: true };
  const memory = new WebAssembly.Memory(argument);
  assert_Memory(memory, { "size": 4, "shared": true });
}, "Shared memory");