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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/proxy/bug901979-2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,31 @@
     1.4 +// A proxy on the prototype chain of the global should not observe anything at
     1.5 +// all about lazy resolution of globals.
     1.6 +
     1.7 +var global = this;
     1.8 +var status = "pass";
     1.9 +
    1.10 +// This is a little tricky. There are two proxies.
    1.11 +// 1. handler is a proxy that fails the test if you try to call a method on it.
    1.12 +var metaHandler = {
    1.13 +  get: _ => { status = "SMASH"; },
    1.14 +  has: _ => { status = "SMASH"; },
    1.15 +  invoke: _ => { status = "SMASH"; }
    1.16 +};
    1.17 +var handler = new Proxy({}, metaHandler);
    1.18 +
    1.19 +// 2. Then we create a proxy using 'handler' as its handler. This means the test
    1.20 +//    will fail if *any* method of the handler is called, not just get/has/invoke.
    1.21 +var angryProxy = new Proxy(Object.create(null), handler);
    1.22 +this.__proto__ = angryProxy;
    1.23 +Object.prototype.__proto__ = angryProxy;
    1.24 +
    1.25 +// Trip the alarm once, to make sure the proxies are working.
    1.26 +this.nonExistingProperty;
    1.27 +assertEq(status, "SMASH");
    1.28 +
    1.29 +// OK. Reset the status and run the actual test.
    1.30 +status = "pass";
    1.31 +Map;
    1.32 +ArrayBuffer;
    1.33 +Date;
    1.34 +assertEq(status, "pass");

mercurial