summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/fields/private-proxy-oom.js
blob: dd5200d9a6460c2abd4f15486f7390ae0a554003 (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
// |jit-test| skip-if: !('oomTest' in this);
// Check for proxy expando OOM issues.

function assertThrowsTypeError(f) {
  assertThrowsInstanceOf(f, TypeError);
}


function testing() {
  var target = {};
  var p1 = new Proxy(target, {});
  var p2 = new Proxy(target, {});

  class A extends class {
    constructor(o) {
      return o;
    }
  }
  {
    #field = 10;
    static gf(o) {
      return o.#field;
    }
    static sf(o) {
      o.#field = 15;
    }
  }

  // Verify field handling on the proxy we install it on.
  new A(p1);
  assertEq(A.gf(p1), 10);
  A.sf(p1)
  assertEq(A.gf(p1), 15);

  // Should't be on the target
  assertThrowsTypeError(() => A.gf(target));

  // Can't set the field, doesn't exist
  assertThrowsTypeError(() => A.sf(p2));

  // Definitely can't get the field, doesn't exist.
  assertThrowsTypeError(() => A.gf(p2));

  // Still should't be on the target.
  assertThrowsTypeError(() => A.gf(target));
}

oomTest(testing);