~ubuntu-branches/ubuntu/saucy/mozjs17/saucy

« back to all changes in this revision

Viewing changes to js/src/jit-test/tests/debug/breakpoint-08.js

  • Committer: Package Import Robot
  • Author(s): Rico Tzschichholz
  • Date: 2013-05-25 12:24:23 UTC
  • Revision ID: package-import@ubuntu.com-20130525122423-zmxucrhtensw90xy
Tags: upstream-17.0.0
ImportĀ upstreamĀ versionĀ 17.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Breakpoints are dropped from eval scripts when they finish executing.
 
2
// (The eval cache doesn't cache breakpoints.)
 
3
 
 
4
var g = newGlobal('new-compartment');
 
5
 
 
6
g.line0 = undefined;
 
7
g.eval("function f() {\n" +
 
8
       "    return eval(s);\n" +
 
9
       "}\n");
 
10
g.s = ("line0 = Error().lineNumber;\n" +
 
11
       "debugger;\n" +          // line0 + 1
 
12
       "result = 'ok';\n");     // line0 + 2
 
13
 
 
14
var dbg = Debugger(g);
 
15
var hits = 0, bphits = 0;
 
16
dbg.onDebuggerStatement = function (frame) {
 
17
    assertEq(frame.type, 'eval');
 
18
    assertEq(frame.script.getBreakpoints().length, 0);
 
19
    var h = {hit: function (frame) { bphits++; }};
 
20
    var offs = frame.script.getLineOffsets(g.line0 + 2);
 
21
    for (var i = 0; i < offs.length; i++)
 
22
        frame.script.setBreakpoint(offs[i], h);
 
23
    hits++;
 
24
};
 
25
 
 
26
for (var i = 0; i < 3; i++) {
 
27
    assertEq(g.f(), 'ok');
 
28
    assertEq(g.result, 'ok');
 
29
}
 
30
assertEq(hits, 3);
 
31
assertEq(bphits, 3);