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