PageRenderTime 28ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 5ms

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

http://github.com/zpao/v8monkey
JavaScript | 29 lines | 17 code | 5 blank | 7 comment | 0 complexity | 92a65e80004eb9901ffb8de7559c2f61 MD5 | raw file
 1// obj.getOwnPropertyDescriptor works when obj is a transparent cross-compartment wrapper.
 2
 3var g1 = newGlobal('new-compartment');
 4var g2 = newGlobal('new-compartment');
 5g1.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
14var dbg = new Debugger;
15var g1obj = dbg.addDebuggee(g1);
16var g2obj = dbg.addDebuggee(g2);
17var wobj = g1obj.getOwnPropertyDescriptor("next").value;
18assertEq(wobj instanceof Debugger.Object, true);
19assertEq(wobj !== g2obj, true);  // referents are in two different compartments
20
21g2.x = "ok";
22assertEq(wobj.getOwnPropertyDescriptor("x").value, "ok");
23
24g1.g2min = g2.min = g2.Math.min;
25g2.eval("Object.defineProperty(this, 'y', {get: min});");
26assertEq(g2.y, Infinity);
27var wmin = wobj.getOwnPropertyDescriptor("y").get;
28assertEq(wmin !== g2obj.getOwnPropertyDescriptor("min").value, true);  // as above
29assertEq(wmin, g1obj.getOwnPropertyDescriptor("g2min").value);