|
1 // obj.getOwnPropertyDescriptor works when obj is a transparent cross-compartment wrapper. |
|
2 |
|
3 var g1 = newGlobal(); |
|
4 var g2 = newGlobal(); |
|
5 g1.next = g2; |
|
6 |
|
7 // This test is a little hard to follow, especially the !== assertions. |
|
8 // |
|
9 // Bottom line: the value of a property of g1 can only be an object in g1's |
|
10 // compartment, so any Debugger.Objects obtained by calling |
|
11 // g1obj.getOwnPropertyDescriptor should all have referents in g1's |
|
12 // compartment. |
|
13 |
|
14 var dbg = new Debugger; |
|
15 var g1obj = dbg.addDebuggee(g1); |
|
16 var g2obj = dbg.addDebuggee(g2); |
|
17 var wobj = g1obj.getOwnPropertyDescriptor("next").value; |
|
18 assertEq(wobj instanceof Debugger.Object, true); |
|
19 assertEq(wobj !== g2obj, true); // referents are in two different compartments |
|
20 |
|
21 g2.x = "ok"; |
|
22 assertEq(wobj.getOwnPropertyDescriptor("x").value, "ok"); |
|
23 |
|
24 g1.g2min = g2.min = g2.Math.min; |
|
25 g2.eval("Object.defineProperty(this, 'y', {get: min});"); |
|
26 assertEq(g2.y, Infinity); |
|
27 var wmin = wobj.getOwnPropertyDescriptor("y").get; |
|
28 assertEq(wmin !== g2obj.getOwnPropertyDescriptor("min").value, true); // as above |
|
29 assertEq(wmin, g1obj.getOwnPropertyDescriptor("g2min").value); |