js/src/jit-test/tests/debug/Debugger-debuggees-16.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial