Object-makeDebuggeeValue-01.js (1608B)
1 // Debugger.Object.prototype.makeDebuggeeValue creates only one 2 // Debugger.Object instance for each debuggee object. 3 4 var g = newGlobal({newCompartment: true}); 5 var dbg = new Debugger(); 6 var gw = dbg.addDebuggee(g); 7 8 g.eval("var x = { 'now playing': 'Joy Division' };"); 9 g.eval("var y = { 'mood': 'bleak' };"); 10 11 wx = gw.makeDebuggeeValue(g.x); 12 assertEq(wx, gw.makeDebuggeeValue(g.x)); 13 assertEq(wx === g.x, false); 14 assertEq("now playing" in wx, false); 15 assertEq(wx.getOwnPropertyNames().indexOf("now playing"), 0); 16 wx.commentary = "deconstruction"; 17 assertEq("deconstruction" in g.x, false); 18 19 wy = gw.makeDebuggeeValue(g.y); 20 assertEq(wy === wx, false); 21 wy.commentary = "reconstruction"; 22 assertEq(wx.commentary, "deconstruction"); 23 24 // Separate debuggers get separate Debugger.Object instances, but both 25 // instances' referents are the same underlying object. 26 var dbg2 = new Debugger(); 27 var gw2 = dbg2.addDebuggee(g); 28 w2x = gw2.makeDebuggeeValue(g.x); 29 assertEq(wx === w2x, false); 30 w2x.defineProperty("breadcrumb", { value: "pumpernickel" }); 31 assertEq(wx.getOwnPropertyDescriptor("breadcrumb").value, "pumpernickel"); 32 33 // Non-objects are already debuggee values. 34 assertEq(gw.makeDebuggeeValue("foonting turlingdromes"), "foonting turlingdromes"); 35 assertEq(gw.makeDebuggeeValue(true), true); 36 assertEq(gw.makeDebuggeeValue(false), false); 37 assertEq(gw.makeDebuggeeValue(null), null); 38 assertEq(gw.makeDebuggeeValue(1729), 1729); 39 assertEq(gw.makeDebuggeeValue(Math.PI), Math.PI); 40 assertEq(gw.makeDebuggeeValue(undefined), undefined); 41 var s = g.eval("Symbol('Stavromula Beta')"); 42 assertEq(gw.makeDebuggeeValue(s), s);