michael@0: // Each resumption of an ES6 generator gets a fresh frame, whose onPop michael@0: // handler fires the next time the generator yields. This is not the michael@0: // behavior the spec requests, but it's what we do for the moment, and michael@0: // it's good to check that at least we don't crash. michael@0: michael@0: load(libdir + 'iteration.js'); michael@0: michael@0: var g = newGlobal(); michael@0: var dbg = new Debugger(g); michael@0: var log; michael@0: michael@0: var debuggerFrames = []; michael@0: var poppedFrames = []; michael@0: dbg.onDebuggerStatement = function handleDebugger(frame) { michael@0: log += 'd'; michael@0: assertEq(frame.type, "call"); michael@0: michael@0: assertEq(debuggerFrames.indexOf(frame), -1); michael@0: assertEq(poppedFrames.indexOf(frame), -1); michael@0: debuggerFrames.push(frame); michael@0: michael@0: if (frame.eval('i').return % 3 == 0) { michael@0: frame.onPop = function handlePop(c) { michael@0: log += ')' + c.return.value; michael@0: assertEq(debuggerFrames.indexOf(this) != -1, true); michael@0: assertEq(poppedFrames.indexOf(this), -1); michael@0: poppedFrames.push(this); michael@0: }; michael@0: } michael@0: }; michael@0: michael@0: g.eval("function* g() { for (var i = 0; i < 10; i++) { debugger; yield i; } }"); michael@0: log =''; michael@0: g.eval("var t = 0, iter = g();"); michael@0: for (var j = 0; j < 10; j++) michael@0: g.eval("t += iter.next().value;"); michael@0: assertIteratorResult(g.eval("iter.next()"), undefined, true); michael@0: assertEq(g.eval("t"), 45); michael@0: michael@0: // FIXME: Should equal this, but see bug 917809. michael@0: // assertEq(log, "d)0ddd)3ddd)6ddd)9"); michael@0: assertEq(log, "d)undefinedddd)undefinedddd)undefinedddd)undefined");