Thu, 15 Jan 2015 15:55:04 +0100
Back out 97036ab72558 which inappropriately compared turds to third parties.
michael@0 | 1 | // |reftest| skip-if(!xulRuntime.shell) -- needs newGlobal() |
michael@0 | 2 | /* |
michael@0 | 3 | * Any copyright is dedicated to the Public Domain. |
michael@0 | 4 | * http://creativecommons.org/licenses/publicdomain/ |
michael@0 | 5 | */ |
michael@0 | 6 | |
michael@0 | 7 | //----------------------------------------------------------------------------- |
michael@0 | 8 | var BUGNUMBER = 608473; |
michael@0 | 9 | var summary = |
michael@0 | 10 | '|var eval = otherWindow.eval; eval(...)| should behave like indirectly ' + |
michael@0 | 11 | 'calling that eval from a script in that other window'; |
michael@0 | 12 | |
michael@0 | 13 | print(BUGNUMBER + ": " + summary); |
michael@0 | 14 | |
michael@0 | 15 | /************** |
michael@0 | 16 | * BEGIN TEST * |
michael@0 | 17 | **************/ |
michael@0 | 18 | |
michael@0 | 19 | var originalEval = eval; |
michael@0 | 20 | var res; |
michael@0 | 21 | |
michael@0 | 22 | function f() |
michael@0 | 23 | { |
michael@0 | 24 | return [this, eval("this")]; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | var otherGlobalSameCompartment = newGlobal("same-compartment"); |
michael@0 | 28 | |
michael@0 | 29 | eval = otherGlobalSameCompartment.eval; |
michael@0 | 30 | res = new f(); |
michael@0 | 31 | assertEq(res[0] !== res[1], true); |
michael@0 | 32 | assertEq(res[0] !== this, true); |
michael@0 | 33 | assertEq(res[0] instanceof f, true); |
michael@0 | 34 | assertEq(res[1], otherGlobalSameCompartment); |
michael@0 | 35 | |
michael@0 | 36 | res = f(); |
michael@0 | 37 | assertEq(res[0] !== res[1], true); |
michael@0 | 38 | assertEq(res[0], this); |
michael@0 | 39 | assertEq(res[1], otherGlobalSameCompartment); |
michael@0 | 40 | |
michael@0 | 41 | var otherGlobalDifferentCompartment = newGlobal(); |
michael@0 | 42 | |
michael@0 | 43 | eval = otherGlobalDifferentCompartment.eval; |
michael@0 | 44 | res = new f(); |
michael@0 | 45 | assertEq(res[0] !== res[1], true); |
michael@0 | 46 | assertEq(res[0] !== this, true); |
michael@0 | 47 | assertEq(res[0] instanceof f, true); |
michael@0 | 48 | assertEq(res[1], otherGlobalDifferentCompartment); |
michael@0 | 49 | |
michael@0 | 50 | res = f(); |
michael@0 | 51 | assertEq(res[0] !== res[1], true); |
michael@0 | 52 | assertEq(res[0], this); |
michael@0 | 53 | assertEq(res[1], otherGlobalDifferentCompartment); |
michael@0 | 54 | |
michael@0 | 55 | /******************************************************************************/ |
michael@0 | 56 | |
michael@0 | 57 | if (typeof reportCompare === "function") |
michael@0 | 58 | reportCompare(true, true); |
michael@0 | 59 | |
michael@0 | 60 | print("All tests passed!"); |