summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Frame-onStack-04.js
blob: cc9a13209196811346e4f0ae3335f796f36f08f4 (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
29
30
31
// frame.onStack is false for frames discarded during uncatchable error unwinding.

load(libdir + 'asserts.js');

var g = newGlobal({newCompartment: true});
var dbg = Debugger(g);
var hits = 0;
var snapshot;
dbg.onDebuggerStatement = function (frame) {
    var stack = [];
    for (var f = frame; f; f = f.older) {
        if (f.type === "call" && f.script !== null)
            stack.push(f);
    }
    snapshot = stack;
    if (hits++ === 0)
        assertEq(frame.eval("x();"), null);
    else
        return null;
};

g.eval("function z() { debugger; }");
g.eval("function y() { z(); }");
g.eval("function x() { y(); }");
assertEq(g.eval("debugger; 'ok';"), "ok");
assertEq(hits, 2);
assertEq(snapshot.length, 3);
for (var i = 0; i < snapshot.length; i++) {
    assertEq(snapshot[i].onStack, false);
    assertThrowsInstanceOf(() => frame.script, Error);
}