1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/debug/Object-makeDebuggeeValue-01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +// Debugger.Object.prototype.makeDebuggeeValue creates only one 1.5 +// Debugger.Object instance for each debuggee object. 1.6 + 1.7 +var g = newGlobal(); 1.8 +var dbg = new Debugger(); 1.9 +var gw = dbg.addDebuggee(g); 1.10 + 1.11 +g.eval("var x = { 'now playing': 'Joy Division' };"); 1.12 +g.eval("var y = { 'mood': 'bleak' };"); 1.13 + 1.14 +wx = gw.makeDebuggeeValue(g.x); 1.15 +assertEq(wx, gw.makeDebuggeeValue(g.x)); 1.16 +assertEq(wx === g.x, false); 1.17 +assertEq("now playing" in wx, false); 1.18 +assertEq(wx.getOwnPropertyNames().indexOf("now playing"), 0); 1.19 +wx.commentary = "deconstruction"; 1.20 +assertEq("deconstruction" in g.x, false); 1.21 + 1.22 +wy = gw.makeDebuggeeValue(g.y); 1.23 +assertEq(wy === wx, false); 1.24 +wy.commentary = "reconstruction"; 1.25 +assertEq(wx.commentary, "deconstruction"); 1.26 + 1.27 +// Separate debuggers get separate Debugger.Object instances, but both 1.28 +// instances' referents are the same underlying object. 1.29 +var dbg2 = new Debugger(); 1.30 +var gw2 = dbg2.addDebuggee(g); 1.31 +w2x = gw2.makeDebuggeeValue(g.x); 1.32 +assertEq(wx === w2x, false); 1.33 +w2x.defineProperty("breadcrumb", { value: "pumpernickel" }); 1.34 +assertEq(wx.getOwnPropertyDescriptor("breadcrumb").value, "pumpernickel"); 1.35 + 1.36 +// Non-objects are already debuggee values. 1.37 +assertEq(gw.makeDebuggeeValue("foonting turlingdromes"), "foonting turlingdromes"); 1.38 +assertEq(gw.makeDebuggeeValue(true), true); 1.39 +assertEq(gw.makeDebuggeeValue(false), false); 1.40 +assertEq(gw.makeDebuggeeValue(null), null); 1.41 +assertEq(gw.makeDebuggeeValue(1729), 1729); 1.42 +assertEq(gw.makeDebuggeeValue(Math.PI), Math.PI); 1.43 +assertEq(gw.makeDebuggeeValue(undefined), undefined);