PageRenderTime 15ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/Script-clearBreakpoint-03.js

http://github.com/zpao/v8monkey
JavaScript | 25 lines | 21 code | 3 blank | 1 comment | 2 complexity | ea0dcf4792a91540f55f1f537af3c216 MD5 | raw file
 1// Clearing a breakpoint by handler can clear multiple breakpoints.
 2
 3var g = newGlobal('new-compartment');
 4var dbg = Debugger(g);
 5var s;
 6dbg.onDebuggerStatement = function (frame) {
 7    s = frame.eval("f").return.script;
 8};
 9g.eval("var line0 = Error().lineNumber;\n" +
10       "function f(a, b) {\n" +     // line0 + 1
11       "    return a + b;\n" +      // line0 + 2
12       "}\n" +
13       "debugger;\n");
14
15var hits = 0;
16var handler = {hit: function (frame) { hits++; s.clearBreakpoint(handler); }};
17var offs = s.getLineOffsets(g.line0 + 2);
18for (var i = 0; i < 4; i++) {
19    for (var j = 0; j < offs.length; j++)
20        s.setBreakpoint(offs[j], handler);
21}
22
23assertEq(g.f(2, 2), 4);
24assertEq(hits, 1);
25assertEq(s.getBreakpoints().length, 0);