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