summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/breakpoint-04.js
blob: f5c0c957b3ba5add7b355c5272cf4653c40482a3 (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
// Hitting a breakpoint with no hit method does nothing.

var g = newGlobal({newCompartment: true});
g.s = '';
g.eval("var line0 = Error().lineNumber;\n" +
       "function f() {\n" +   // line0 + 1
       "    debugger;\n" +  // line0 + 2
       "    s += 'x';\n" +  // line0 + 3
       "}\n")
var dbg = Debugger(g);
var bp = [];
dbg.onDebuggerStatement = function (frame) {
    g.s += 'D';
    var arr = frame.script.getLineOffsets(g.line0 + 3);
    for (var i = 0; i < arr.length; i++) {
        var obj = {};
        bp[i] = obj;
        frame.script.setBreakpoint(arr[i], obj);
    }
};

g.f();
assertEq(g.s, "Dx");

dbg.onDebuggerStatement = undefined;

for (var i = 0; i < bp.length; i++)
    bp[i].hit = function () { g.s += 'B'; };
g.f();
assertEq(g.s, "DxBx");