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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // A proxy on the prototype chain of the global should not observe anything at
     2 // all about lazy resolution of globals.
     4 var global = this;
     5 var status = "pass";
     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);
    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;
    22 // Trip the alarm once, to make sure the proxies are working.
    23 this.nonExistingProperty;
    24 assertEq(status, "SMASH");
    26 // OK. Reset the status and run the actual test.
    27 status = "pass";
    28 Map;
    29 ArrayBuffer;
    30 Date;
    31 assertEq(status, "pass");

mercurial