summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-gc-01.js
blob: f328008b15aad2c56aa9ac40c8d719542c5a476e (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({newCompartment: true});
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);