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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Debugger-debuggees-16.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,30 @@
     1.4 +// GC can turn off debug mode in a compartment.
     1.5 +
     1.6 +var dbgs = [];
     1.7 +var nonDebugGlobals = [];
     1.8 +var f = gc;
     1.9 +for (var i = 0; i < 4; i++) {
    1.10 +    // Create two globals, one debuggee.
    1.11 +    var g1 = newGlobal();
    1.12 +    var g2 = g1.eval("newGlobal('same-compartment')");
    1.13 +    var dbg = Debugger(g1);
    1.14 +    dbg.onDebuggerStatement = function () {};
    1.15 +
    1.16 +    // Thread a chain of functions through the non-debuggee globals.
    1.17 +    g2.eval("function f() { return g() + 1; }");
    1.18 +    g2.g = f;
    1.19 +    f = g2.f;
    1.20 +
    1.21 +    // Root the Debugger objects and non-debuggee globals.
    1.22 +    dbgs[i] = dbg;
    1.23 +    nonDebugGlobals[i] = g2;
    1.24 +}
    1.25 +
    1.26 +// Call the chain of functions. At the end of the chain is gc. This will
    1.27 +// collect (some or all of) the debuggee globals, leaving non-debuggee
    1.28 +// globals. It should disable debug mode in those debuggee compartments.
    1.29 +nonDebugGlobals[nonDebugGlobals.length - 1].f();
    1.30 +
    1.31 +gc();
    1.32 +nonDebugGlobals[0].g = function () { return 0; }
    1.33 +assertEq(nonDebugGlobals[nonDebugGlobals.length - 1].f(), nonDebugGlobals.length);

mercurial