michael@0: // GC can turn off debug mode in a compartment. michael@0: michael@0: var dbgs = []; michael@0: var nonDebugGlobals = []; michael@0: var f = gc; michael@0: for (var i = 0; i < 4; i++) { michael@0: // Create two globals, one debuggee. michael@0: var g1 = newGlobal(); michael@0: var g2 = g1.eval("newGlobal('same-compartment')"); michael@0: var dbg = Debugger(g1); michael@0: dbg.onDebuggerStatement = function () {}; michael@0: michael@0: // Thread a chain of functions through the non-debuggee globals. michael@0: g2.eval("function f() { return g() + 1; }"); michael@0: g2.g = f; michael@0: f = g2.f; michael@0: michael@0: // Root the Debugger objects and non-debuggee globals. michael@0: dbgs[i] = dbg; michael@0: nonDebugGlobals[i] = g2; michael@0: } michael@0: michael@0: // Call the chain of functions. At the end of the chain is gc. This will michael@0: // collect (some or all of) the debuggee globals, leaving non-debuggee michael@0: // globals. It should disable debug mode in those debuggee compartments. michael@0: nonDebugGlobals[nonDebugGlobals.length - 1].f(); michael@0: michael@0: gc(); michael@0: nonDebugGlobals[0].g = function () { return 0; } michael@0: assertEq(nonDebugGlobals[nonDebugGlobals.length - 1].f(), nonDebugGlobals.length);