summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/gc-01.js
blob: 949c74b57686b9642cfae4272b3547a23b92d8ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Debuggers with enabled hooks should not be GC'd even if they are otherwise
// unreachable.

var g = newGlobal({newCompartment: true});
var actual = 0;
var expected = 0;

function f() {
    for (var i = 0; i < 20; i++) {
        var dbg = new Debugger(g);
        dbg.num = i;
        dbg.onDebuggerStatement = function (stack) { actual += this.num; };
        expected += i;
    }
}

f();
gc(); gc(); gc();
g.eval("debugger;");
assertEq(actual, expected);