PageRenderTime 8ms CodeModel.GetById 2ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/breakpoint-01.js

http://github.com/zpao/v8monkey
JavaScript | 22 lines | 20 code | 1 blank | 1 comment | 1 complexity | 92cf03e4c8ee04cfcdd46d0c311adf06 MD5 | raw file
 1// Basic breakpoint test.
 2
 3var g = newGlobal('new-compartment');
 4g.s = '';
 5var handler = {
 6    hit: function (frame) {
 7        assertEq(this, handler);
 8        g.s += '1';
 9    }
10};
11var dbg = Debugger(g);
12dbg.onDebuggerStatement = function (frame) {
13    g.s += '0';
14    var line0 = frame.script.getOffsetLine(frame.offset);
15    var offs = frame.script.getLineOffsets(line0 + 2);
16    for (var i = 0; i < offs.length; i++)
17        frame.script.setBreakpoint(offs[i], handler);
18};
19g.eval("debugger;\n" +
20       "s += 'a';\n" +  // line0 + 1
21       "s += 'b';\n");  // line0 + 2
22assertEq(g.s, "0a1b");