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

load(libdir + "asserts.js");

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.onExceptionUnwind = function (stack, exc) { actual += this.num; };
        expected += i;
    }
}

f();
gc();
assertThrowsValue(function () { g.eval("throw 'fit';"); }, "fit");
assertEq(actual, expected);