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