Debian Codegraph @

js/src/jit-test/tests/proxy/testDirectProxyGet12.js

raw
1 load(libdir + "asserts.js");
2
3 let {object: target, transplant} = transplantableObject(options);
4 let otherGlobal = newGlobal({newCompartment: true});
5
6 var returnValue = 42;
7 var handler = {
8 get(t, p) {
9 if (returnValue != 42) {
10 transplant(otherGlobal);
11 Object.defineProperty(target, "x", {
12 value: 42,
13 writable: false,
14 configurable: false,
15 });
16 }
17 return returnValue;
18 }
19 };
20 var proxy = new Proxy(target, handler);
21
22 function testGet(p) {
23 return p.x;
24 }
25
26 for (i = 0; i < 200; i++) {
27 assertEq(testGet(proxy), returnValue);
28 }
29
30 returnValue = 43;
31 assertThrowsInstanceOf(function () { testGet(proxy) }, TypeError);