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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // When a recursive function has many frames on the stack, onStep may be set or
     2 // not independently on each frame.
     4 var g = newGlobal();
     5 g.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        "}");
    13 var dbg = Debugger(g);
    14 var seen = [0, 0, 0, 0, 0, 0, 0, 0];
    15 function step() {
    16     seen[this.arguments[0]] = 1;
    17 }
    18 dbg.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 };
    24 dbg.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");
    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 };
    33 g.f(7);
    34 assertEq(seen.join(""), "10101010");

mercurial