Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 // Debugger.Object.prototype.makeDebuggeeValue creates only one
2 // Debugger.Object instance for each debuggee object.
4 var g = newGlobal();
5 var dbg = new Debugger();
6 var gw = dbg.addDebuggee(g);
8 g.eval("var x = { 'now playing': 'Joy Division' };");
9 g.eval("var y = { 'mood': 'bleak' };");
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);
19 wy = gw.makeDebuggeeValue(g.y);
20 assertEq(wy === wx, false);
21 wy.commentary = "reconstruction";
22 assertEq(wx.commentary, "deconstruction");
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");
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);