summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Script-clearBreakpoint-01.js
blob: 4d0b2bb830af17237e908c18a999505f2a38cb20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// A breakpoint handler may clear itself.

var g = newGlobal();
var bphits = 0;
var handler = {hit: function (frame) { frame.script.clearBreakpoint(this); bphits++; }};
var dbg = Debugger(g);
var hits = 0;
dbg.onDebuggerStatement = function (frame) {
    var offs = frame.script.getLineOffsets(g.line0 + 3);
    for (var i = 0; i < offs.length; i++)
        frame.script.setBreakpoint(offs[i], handler);
    hits++;
};
g.eval("var line0 = Error().lineNumber;\n" +
       "debugger;\n" +                    // line0 + 1
       "for (var i = 0; i < 4; i++)\n" +  // line0 + 2
       "    result = 'ok';\n");           // line0 + 3
assertEq(hits, 1);
assertEq(bphits, 1);