js/src/jit-test/tests/debug/Frame-onPop-15.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/debug/Frame-onPop-15.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,32 @@
     1.4 +// Each resumption of a generator gets a fresh frame, whose onPop handler
     1.5 +// fires the next time the generator yields.
     1.6 +// This is not the behavior the spec requests, but it's what we do for the
     1.7 +// moment, and it's good to check that at least we don't crash.
     1.8 +var g = newGlobal();
     1.9 +var dbg = new Debugger(g);
    1.10 +var log;
    1.11 +
    1.12 +var debuggerFrames = [];
    1.13 +var poppedFrames = [];
    1.14 +dbg.onDebuggerStatement = function handleDebugger(frame) {
    1.15 +    log += 'd';
    1.16 +    assertEq(frame.type, "call");
    1.17 +
    1.18 +    assertEq(debuggerFrames.indexOf(frame), -1);
    1.19 +    assertEq(poppedFrames.indexOf(frame), -1);
    1.20 +    debuggerFrames.push(frame);
    1.21 +
    1.22 +    if (frame.eval('i').return % 3 == 0) {
    1.23 +        frame.onPop = function handlePop(c) {
    1.24 +            log += ')' + c.return;
    1.25 +            assertEq(debuggerFrames.indexOf(this) != -1, true);
    1.26 +            assertEq(poppedFrames.indexOf(this), -1);
    1.27 +            poppedFrames.push(this);
    1.28 +        };
    1.29 +    }
    1.30 +};
    1.31 +
    1.32 +g.eval("function g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
    1.33 +log ='';
    1.34 +assertEq(g.eval("var t = 0; for (j in g()) t += j; t;"), 45);
    1.35 +assertEq(log, "d)0ddd)3ddd)6ddd)9");

mercurial