PageRenderTime 24ms CodeModel.GetById 16ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/jit-test/tests/debug/Frame-onStep-04.js

http://github.com/zpao/v8monkey
JavaScript | 34 lines | 24 code | 4 blank | 6 comment | 1 complexity | ea7b136642d1dc3017171a5fefbf9b18 MD5 | raw file
 1// When a recursive function has many frames on the stack, onStep may be set or
 2// not independently on each frame.
 3
 4var g = newGlobal('new-compartment');
 5g.eval("function f(x) {\n" +
 6       "    if (x > 0)\n" +
 7       "        f(x - 1);\n" +
 8       "    else\n" +
 9       "        debugger;\n" +
10       "    return x;\n" +
11       "}");
12
13var dbg = Debugger(g);
14var seen = [0, 0, 0, 0, 0, 0, 0, 0];
15function step() {
16    seen[this.arguments[0]] = 1;
17}
18dbg.onEnterFrame = function (frame) {
19    // Turn on stepping for even-numbered frames.
20    var x = frame.arguments[0];
21    if (x % 2 === 0)
22        frame.onStep = step;
23};
24dbg.onDebuggerStatement = function (frame) {
25    // This is called with 8 call frames on the stack, 7 down to 0.
26    // At this point we should have seen all the even-numbered frames.
27    assertEq(seen.join(""), "10101010");
28
29    // Now reset seen to see which frames fire onStep on the way out.
30    seen = [0, 0, 0, 0, 0, 0, 0, 0];
31};
32
33g.f(7);
34assertEq(seen.join(""), "10101010");