js/src/jit-test/tests/debug/Frame-onPop-star-generators-03.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.

michael@0 1 // Each resumption of an ES6 generator gets a fresh frame, whose onPop
michael@0 2 // handler fires the next time the generator yields. This is not the
michael@0 3 // behavior the spec requests, but it's what we do for the moment, and
michael@0 4 // it's good to check that at least we don't crash.
michael@0 5
michael@0 6 load(libdir + 'iteration.js');
michael@0 7
michael@0 8 var g = newGlobal();
michael@0 9 var dbg = new Debugger(g);
michael@0 10 var log;
michael@0 11
michael@0 12 var debuggerFrames = [];
michael@0 13 var poppedFrames = [];
michael@0 14 dbg.onDebuggerStatement = function handleDebugger(frame) {
michael@0 15 log += 'd';
michael@0 16 assertEq(frame.type, "call");
michael@0 17
michael@0 18 assertEq(debuggerFrames.indexOf(frame), -1);
michael@0 19 assertEq(poppedFrames.indexOf(frame), -1);
michael@0 20 debuggerFrames.push(frame);
michael@0 21
michael@0 22 if (frame.eval('i').return % 3 == 0) {
michael@0 23 frame.onPop = function handlePop(c) {
michael@0 24 log += ')' + c.return.value;
michael@0 25 assertEq(debuggerFrames.indexOf(this) != -1, true);
michael@0 26 assertEq(poppedFrames.indexOf(this), -1);
michael@0 27 poppedFrames.push(this);
michael@0 28 };
michael@0 29 }
michael@0 30 };
michael@0 31
michael@0 32 g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }");
michael@0 33 log ='';
michael@0 34 g.eval("var t = 0, iter = g();");
michael@0 35 for (var j = 0; j < 10; j++)
michael@0 36 g.eval("t += iter.next().value;");
michael@0 37 assertIteratorResult(g.eval("iter.next()"), undefined, true);
michael@0 38 assertEq(g.eval("t"), 45);
michael@0 39
michael@0 40 // FIXME: Should equal this, but see bug 917809.
michael@0 41 // assertEq(log, "d)0ddd)3ddd)6ddd)9");
michael@0 42 assertEq(log, "d)undefinedddd)undefinedddd)undefinedddd)undefined");

mercurial