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