|
1 // GC can turn off debug mode in a compartment. |
|
2 |
|
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 () {}; |
|
12 |
|
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; |
|
17 |
|
18 // Root the Debugger objects and non-debuggee globals. |
|
19 dbgs[i] = dbg; |
|
20 nonDebugGlobals[i] = g2; |
|
21 } |
|
22 |
|
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(); |
|
27 |
|
28 gc(); |
|
29 nonDebugGlobals[0].g = function () { return 0; } |
|
30 assertEq(nonDebugGlobals[nonDebugGlobals.length - 1].f(), nonDebugGlobals.length); |