|
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 */ |
|
6 |
|
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'; |
|
12 |
|
13 print(BUGNUMBER + ": " + summary); |
|
14 |
|
15 /************** |
|
16 * BEGIN TEST * |
|
17 **************/ |
|
18 |
|
19 var originalEval = eval; |
|
20 var res; |
|
21 |
|
22 function f() |
|
23 { |
|
24 return [this, eval("this")]; |
|
25 } |
|
26 |
|
27 var otherGlobalSameCompartment = newGlobal("same-compartment"); |
|
28 |
|
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); |
|
35 |
|
36 res = f(); |
|
37 assertEq(res[0] !== res[1], true); |
|
38 assertEq(res[0], this); |
|
39 assertEq(res[1], otherGlobalSameCompartment); |
|
40 |
|
41 var otherGlobalDifferentCompartment = newGlobal(); |
|
42 |
|
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); |
|
49 |
|
50 res = f(); |
|
51 assertEq(res[0] !== res[1], true); |
|
52 assertEq(res[0], this); |
|
53 assertEq(res[1], otherGlobalDifferentCompartment); |
|
54 |
|
55 /******************************************************************************/ |
|
56 |
|
57 if (typeof reportCompare === "function") |
|
58 reportCompare(true, true); |
|
59 |
|
60 print("All tests passed!"); |