michael@0: // Each resumption of a generator gets a fresh frame, whose onPop handler michael@0: // fires the next time the generator yields. michael@0: // This is not the behavior the spec requests, but it's what we do for the michael@0: // moment, and it's good to check that at least we don't crash. 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; 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: assertEq(g.eval("var t = 0; for (j in g()) t += j; t;"), 45); michael@0: assertEq(log, "d)0ddd)3ddd)6ddd)9");