js/src/tests/ecma_5/extensions/cross-global-eval-is-indirect.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 // |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal()
     2 /*
     3  * Any copyright is dedicated to the Public Domain.
     4  * http://creativecommons.org/licenses/publicdomain/
     5  */
     7 //-----------------------------------------------------------------------------
     8 var BUGNUMBER = 608473;
     9 var summary =
    10   '|var eval = otherWindow.eval; eval(...)| should behave like indirectly ' +
    11   'calling that eval from a script in that other window';
    13 print(BUGNUMBER + ": " + summary);
    15 /**************
    16  * BEGIN TEST *
    17  **************/
    19 var originalEval = eval;
    20 var res;
    22 function f()
    23 {
    24   return [this, eval("this")];
    25 }
    27 var otherGlobalSameCompartment = newGlobal("same-compartment");
    29 eval = otherGlobalSameCompartment.eval;
    30 res = new f();
    31 assertEq(res[0] !== res[1], true);
    32 assertEq(res[0] !== this, true);
    33 assertEq(res[0] instanceof f, true);
    34 assertEq(res[1], otherGlobalSameCompartment);
    36 res = f();
    37 assertEq(res[0] !== res[1], true);
    38 assertEq(res[0], this);
    39 assertEq(res[1], otherGlobalSameCompartment);
    41 var otherGlobalDifferentCompartment = newGlobal();
    43 eval = otherGlobalDifferentCompartment.eval;
    44 res = new f();
    45 assertEq(res[0] !== res[1], true);
    46 assertEq(res[0] !== this, true);
    47 assertEq(res[0] instanceof f, true);
    48 assertEq(res[1], otherGlobalDifferentCompartment);
    50 res = f();
    51 assertEq(res[0] !== res[1], true);
    52 assertEq(res[0], this);
    53 assertEq(res[1], otherGlobalDifferentCompartment);
    55 /******************************************************************************/
    57 if (typeof reportCompare === "function")
    58   reportCompare(true, true);
    60 print("All tests passed!");

mercurial