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

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

http://github.com/zpao/v8monkey
JavaScript | 19 lines | 17 code | 1 blank | 1 comment | 1 complexity | e272df6b2fc7146d009e4ca1b26dcfa9 MD5 | raw file
 1// A breakpoint handler may clear itself.
 2
 3var g = newGlobal('new-compartment');
 4var bphits = 0;
 5var handler = {hit: function (frame) { frame.script.clearBreakpoint(this); bphits++; }};
 6var dbg = Debugger(g);
 7var hits = 0;
 8dbg.onDebuggerStatement = function (frame) {
 9    var offs = frame.script.getLineOffsets(g.line0 + 3);
10    for (var i = 0; i < offs.length; i++)
11        frame.script.setBreakpoint(offs[i], handler);
12    hits++;
13};
14g.eval("var line0 = Error().lineNumber;\n" +
15       "debugger;\n" +                    // line0 + 1
16       "for (var i = 0; i < 4; i++)\n" +  // line0 + 2
17       "    result = 'ok';\n");           // line0 + 3
18assertEq(hits, 1);
19assertEq(bphits, 1);