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 | // One Debugger's onPop handler can remove another Debugger's onPop handler. |
michael@0 | 2 | var g = newGlobal(); |
michael@0 | 3 | var dbg1 = new Debugger(g); |
michael@0 | 4 | var dbg2 = new Debugger(g); |
michael@0 | 5 | |
michael@0 | 6 | var log; |
michael@0 | 7 | var frames = []; |
michael@0 | 8 | var firstPop = true; |
michael@0 | 9 | |
michael@0 | 10 | function handleEnter(frame) { |
michael@0 | 11 | log += '('; |
michael@0 | 12 | frames.push(frame); |
michael@0 | 13 | frame.onPop = function handlePop(completion) { |
michael@0 | 14 | log += ')'; |
michael@0 | 15 | assertEq(completion.return, 42); |
michael@0 | 16 | if (firstPop) { |
michael@0 | 17 | // We can't say which frame's onPop handler will get called first. |
michael@0 | 18 | if (this == frames[0]) |
michael@0 | 19 | frames[1].onPop = undefined; |
michael@0 | 20 | else |
michael@0 | 21 | frames[0].onPop = undefined; |
michael@0 | 22 | gc(); |
michael@0 | 23 | } else { |
michael@0 | 24 | assertEq("second pop handler was called", |
michael@0 | 25 | "second pop handler should not be called"); |
michael@0 | 26 | } |
michael@0 | 27 | firstPop = false; |
michael@0 | 28 | }; |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | dbg1.onEnterFrame = handleEnter; |
michael@0 | 32 | dbg2.onEnterFrame = handleEnter; |
michael@0 | 33 | |
michael@0 | 34 | log = ''; |
michael@0 | 35 | assertEq(g.eval('40 + 2'), 42); |
michael@0 | 36 | assertEq(log, '(()'); |