PageRenderTime 23ms CodeModel.GetById 13ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/Debugger-clearAllBreakpoints-01.js

http://github.com/zpao/v8monkey
JavaScript | 29 lines | 24 code | 4 blank | 1 comment | 2 complexity | 5ca23c4457215e29f021c9ae8791d014 MD5 | raw file
 1// clearAllBreakpoints clears breakpoints for the current Debugger object only.
 2
 3var g = newGlobal('new-compartment');
 4
 5var hits = 0;
 6function attach(i) {
 7    var dbg = Debugger(g);
 8    var handler = {
 9        hit: function (frame) {
10            hits++;
11            dbg.clearAllBreakpoints(handler);
12        }
13    };
14
15    dbg.onDebuggerStatement = function (frame) {
16        var s = frame.script;
17        var offs = s.getLineOffsets(g.line0 + 3);
18        for (var i = 0; i < offs.length; i++)
19            s.setBreakpoint(offs[i], handler);
20    };
21}
22for (var i = 0; i < 4; i++)
23    attach(i);
24
25g.eval("var line0 = Error().lineNumber;\n" +
26       "debugger;\n" +                      // line0 + 1
27       "for (var i = 0; i < 7; i++)\n" +    // line0 + 2
28       "    Math.sin(0);\n");               // line0 + 3
29assertEq(hits, 4);