js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-06.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Object-getOwnPropertyDescriptor-06.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,29 @@
     1.4 +// obj.getOwnPropertyDescriptor works when obj is a transparent cross-compartment wrapper.
     1.5 +
     1.6 +var g1 = newGlobal();
     1.7 +var g2 = newGlobal();
     1.8 +g1.next = g2;
     1.9 +
    1.10 +// This test is a little hard to follow, especially the !== assertions.
    1.11 +//
    1.12 +// Bottom line: the value of a property of g1 can only be an object in g1's
    1.13 +// compartment, so any Debugger.Objects obtained by calling
    1.14 +// g1obj.getOwnPropertyDescriptor should all have referents in g1's
    1.15 +// compartment.
    1.16 +
    1.17 +var dbg = new Debugger;
    1.18 +var g1obj = dbg.addDebuggee(g1);
    1.19 +var g2obj = dbg.addDebuggee(g2);
    1.20 +var wobj = g1obj.getOwnPropertyDescriptor("next").value;
    1.21 +assertEq(wobj instanceof Debugger.Object, true);
    1.22 +assertEq(wobj !== g2obj, true);  // referents are in two different compartments
    1.23 +
    1.24 +g2.x = "ok";
    1.25 +assertEq(wobj.getOwnPropertyDescriptor("x").value, "ok");
    1.26 +
    1.27 +g1.g2min = g2.min = g2.Math.min;
    1.28 +g2.eval("Object.defineProperty(this, 'y', {get: min});");
    1.29 +assertEq(g2.y, Infinity);
    1.30 +var wmin = wobj.getOwnPropertyDescriptor("y").get;
    1.31 +assertEq(wmin !== g2obj.getOwnPropertyDescriptor("min").value, true);  // as above
    1.32 +assertEq(wmin, g1obj.getOwnPropertyDescriptor("g2min").value);

mercurial