summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-gc-01.js
blob: 5d71b1e399955c7acb8abdb7e4e8c69f4caa7aa0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Debugger.Script instances with live referents stay alive.

var N = 4;
var g = newGlobal();
var dbg = new Debugger(g);
var i;
dbg.onDebuggerStatement = function (frame) {
    assertEq(frame.script instanceof Debugger.Script, true);
    frame.script.id = i;
};

g.eval('var arr = [];')
for (i = 0; i < N; i++)  // loop to defeat conservative GC
    g.eval("arr.push(function () { debugger }); arr[arr.length - 1]();");

gc();

var hits;
dbg.onDebuggerStatement = function (frame) {
    hits++;
    assertEq(frame.script.id, i);
};
hits = 0;
for (i = 0; i < N; i++)
    g.arr[i]();
assertEq(hits, N);