Debian Codegraph @

js/src/jit-test/tests/proxy/bug901979-2.js

raw
1 // A proxy on the prototype chain of the global should not observe anything at
2 // all about lazy resolution of globals.
3 load(libdir + "immutable-prototype.js");
4
5 var global = this;
6 var status = "pass";
7
8 // This is a little tricky. There are two proxies.
9 // 1. handler is a proxy that fails the test if you try to call a method on it.
10 var metaHandler = {
11 get: _ => { status = "SMASH"; },
12 has: _ => { status = "SMASH"; },
13 invoke: _ => { status = "SMASH"; }
14 };
15 var handler = new Proxy({}, metaHandler);
16
17 // 2. Then we create a proxy using 'handler' as its handler. This means the test
18 // will fail if *any* method of the handler is called, not just get/has/invoke.
19 var angryProxy = new Proxy(Object.create(null), handler);
20 if (globalPrototypeChainIsMutable()) {
21 this.__proto__ = angryProxy;
22 Object.prototype.__proto__ = angryProxy;
23 }
24
25 // Trip the alarm once, to make sure the proxies are working.
26 this.nonExistingProperty;
27 if (globalPrototypeChainIsMutable())
28 assertEq(status, "SMASH");
29 else
30 assertEq(status, "pass");
31
32 // OK. Reset the status and run the actual test.
33 status = "pass";
34 Map;
35 ArrayBuffer;
36 Date;
37 assertEq(status, "pass");