summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/gc-02.js
blob: 4055650c71765287f14e605217f2ab2453dc8767 (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
27
28
// Dispatching an event to a debugger must keep enough of it gc-alive to avoid
// crashing.

var g = newGlobal();
var hits;

function addDebug() {
    // The loop is here to defeat the conservative GC. :-\
    for (var i = 0; i < 4; i++) {
        var dbg = new Debugger(g);
        dbg.onDebuggerStatement = function (stack) {
            hits++;
            this.enabled = false;
            this.onDebuggerStatement = undefined;
            gc();
        };
        if (i > 0) {
            dbg.enabled = false;
            dbg.onDebuggerStatement = undefined;
            dbg = null;
        }
    }
}

addDebug();
hits = 0;
g.eval("debugger;");
assertEq(hits, 1);