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