js/src/jit-test/tests/debug/Frame-onPop-15.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 // Each resumption of a generator gets a fresh frame, whose onPop handler
     2 // fires the next time the generator yields.
     3 // This is not the behavior the spec requests, but it's what we do for the
     4 // moment, and it's good to check that at least we don't crash.
     5 var g = newGlobal();
     6 var dbg = new Debugger(g);
     7 var log;
     9 var debuggerFrames = [];
    10 var poppedFrames = [];
    11 dbg.onDebuggerStatement = function handleDebugger(frame) {
    12     log += 'd';
    13     assertEq(frame.type, "call");
    15     assertEq(debuggerFrames.indexOf(frame), -1);
    16     assertEq(poppedFrames.indexOf(frame), -1);
    17     debuggerFrames.push(frame);
    19     if (frame.eval('i').return % 3 == 0) {
    20         frame.onPop = function handlePop(c) {
    21             log += ')' + c.return;
    22             assertEq(debuggerFrames.indexOf(this) != -1, true);
    23             assertEq(poppedFrames.indexOf(this), -1);
    24             poppedFrames.push(this);
    25         };
    26     }
    27 };
    29 g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
    30 log ='';
    31 assertEq(g.eval("var t = 0; for (j in g()) t += j; t;"), 45);
    32 assertEq(log, "d)0ddd)3ddd)6ddd)9");

mercurial