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 | // The debugger can eval in any frame in the stack even if every frame was |
michael@0 | 2 | // pushed in a different context. |
michael@0 | 3 | |
michael@0 | 4 | var g = newGlobal(); |
michael@0 | 5 | g.eval('function f(a) {\n' + |
michael@0 | 6 | ' if (a == 1)\n' + |
michael@0 | 7 | ' debugger;\n' + |
michael@0 | 8 | ' else\n' + |
michael@0 | 9 | ' evaluate("f(" + a + " - 1);", {newContext: true});\n' + |
michael@0 | 10 | '}\n'); |
michael@0 | 11 | var N = 9; |
michael@0 | 12 | |
michael@0 | 13 | var dbg = new Debugger(g); |
michael@0 | 14 | var frames = []; |
michael@0 | 15 | var hits = 0; |
michael@0 | 16 | dbg.onEnterFrame = function (frame) { |
michael@0 | 17 | if (frame.type == "call" && frame.callee.name == "f") { |
michael@0 | 18 | frames.push(frame); |
michael@0 | 19 | frame.onPop = function () { assertEq(frames.pop(), frame); }; |
michael@0 | 20 | } |
michael@0 | 21 | }; |
michael@0 | 22 | dbg.onDebuggerStatement = function (frame) { |
michael@0 | 23 | assertEq(frames.length, N); |
michael@0 | 24 | var i = N; |
michael@0 | 25 | for (var f of frames) |
michael@0 | 26 | assertEq(f.eval('a').return, i--); |
michael@0 | 27 | hits++; |
michael@0 | 28 | }; |
michael@0 | 29 | |
michael@0 | 30 | g.f(N); |
michael@0 | 31 | assertEq(hits, 1); |
michael@0 | 32 | assertEq(frames.length, 0); |