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 // GC can turn off debug mode in a compartment.
3 var dbgs = [];
4 var nonDebugGlobals = [];
5 var f = gc;
6 for (var i = 0; i < 4; i++) {
7 // Create two globals, one debuggee.
8 var g1 = newGlobal();
9 var g2 = g1.eval("newGlobal('same-compartment')");
10 var dbg = Debugger(g1);
11 dbg.onDebuggerStatement = function () {};
13 // Thread a chain of functions through the non-debuggee globals.
14 g2.eval("function f() { return g() + 1; }");
15 g2.g = f;
16 f = g2.f;
18 // Root the Debugger objects and non-debuggee globals.
19 dbgs[i] = dbg;
20 nonDebugGlobals[i] = g2;
21 }
23 // Call the chain of functions. At the end of the chain is gc. This will
24 // collect (some or all of) the debuggee globals, leaving non-debuggee
25 // globals. It should disable debug mode in those debuggee compartments.
26 nonDebugGlobals[nonDebugGlobals.length - 1].f();
28 gc();
29 nonDebugGlobals[0].g = function () { return 0; }
30 assertEq(nonDebugGlobals[nonDebugGlobals.length - 1].f(), nonDebugGlobals.length);