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 | // evalWithBindings code is debuggee code, so it can trip the debugger. It nests! |
michael@0 | 2 | var g = newGlobal(); |
michael@0 | 3 | var dbg = new Debugger(g); |
michael@0 | 4 | var f1; |
michael@0 | 5 | var hits = 0; |
michael@0 | 6 | dbg.onDebuggerStatement = function (frame) { |
michael@0 | 7 | f1 = frame; |
michael@0 | 8 | |
michael@0 | 9 | // This trips the onExceptionUnwind hook. |
michael@0 | 10 | var x = frame.evalWithBindings("wrongSpeling", {rightSpelling: 2}).throw; |
michael@0 | 11 | |
michael@0 | 12 | assertEq(frame.evalWithBindings("exc.name", {exc: x}).return, "ReferenceError"); |
michael@0 | 13 | hits++; |
michael@0 | 14 | }; |
michael@0 | 15 | dbg.onExceptionUnwind = function (frame, exc) { |
michael@0 | 16 | assertEq(frame !== f1, true); |
michael@0 | 17 | |
michael@0 | 18 | // f1's environment does not contain the binding for the first evalWithBindings call. |
michael@0 | 19 | assertEq(f1.eval("rightSpelling").return, "dependent"); |
michael@0 | 20 | assertEq(f1.evalWithBindings("n + rightSpelling", {n: "in"}).return, "independent"); |
michael@0 | 21 | |
michael@0 | 22 | // frame's environment does contain the binding. |
michael@0 | 23 | assertEq(frame.eval("rightSpelling").return, 2); |
michael@0 | 24 | assertEq(frame.evalWithBindings("rightSpelling + three", {three: 3}).return, 5); |
michael@0 | 25 | hits++; |
michael@0 | 26 | }; |
michael@0 | 27 | g.eval("(function () { var rightSpelling = 'dependent'; debugger; })();"); |