michael@0: // One Debugger's onPop handler can remove another Debugger's onPop handler. michael@0: var g = newGlobal(); michael@0: var dbg1 = new Debugger(g); michael@0: var dbg2 = new Debugger(g); michael@0: michael@0: var log; michael@0: var frames = []; michael@0: var firstPop = true; michael@0: michael@0: function handleEnter(frame) { michael@0: log += '('; michael@0: frames.push(frame); michael@0: frame.onPop = function handlePop(completion) { michael@0: log += ')'; michael@0: assertEq(completion.return, 42); michael@0: if (firstPop) { michael@0: // We can't say which frame's onPop handler will get called first. michael@0: if (this == frames[0]) michael@0: frames[1].onPop = undefined; michael@0: else michael@0: frames[0].onPop = undefined; michael@0: gc(); michael@0: } else { michael@0: assertEq("second pop handler was called", michael@0: "second pop handler should not be called"); michael@0: } michael@0: firstPop = false; michael@0: }; michael@0: }; michael@0: michael@0: dbg1.onEnterFrame = handleEnter; michael@0: dbg2.onEnterFrame = handleEnter; michael@0: michael@0: log = ''; michael@0: assertEq(g.eval('40 + 2'), 42); michael@0: assertEq(log, '(()');