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 | // Test that Ion frames are invalidated by turning on Debugger. Invalidation |
michael@0 | 2 | // is unobservable, but we know that Ion scripts cannot handle Debugger |
michael@0 | 3 | // handlers, so we test for the handlers being called. |
michael@0 | 4 | |
michael@0 | 5 | load(libdir + "jitopts.js"); |
michael@0 | 6 | |
michael@0 | 7 | if (!jitTogglesMatch(Opts_Ion2NoParallelCompilation)) |
michael@0 | 8 | quit(); |
michael@0 | 9 | |
michael@0 | 10 | withJitOptions(Opts_Ion2NoParallelCompilation, function () { |
michael@0 | 11 | var g = newGlobal(); |
michael@0 | 12 | var dbg = new Debugger; |
michael@0 | 13 | var onPopExecuted = false; |
michael@0 | 14 | var breakpointHit = false; |
michael@0 | 15 | |
michael@0 | 16 | g.toggle = function toggle(d) { |
michael@0 | 17 | if (d) { |
michael@0 | 18 | dbg.addDebuggee(g); |
michael@0 | 19 | |
michael@0 | 20 | var frame1 = dbg.getNewestFrame(); |
michael@0 | 21 | assertEq(frame1.implementation, "ion"); |
michael@0 | 22 | frame1.onPop = function () { |
michael@0 | 23 | onPopExecuted = true; |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | var frame2 = frame1.older; |
michael@0 | 27 | assertEq(frame2.implementation, "ion"); |
michael@0 | 28 | // Offset of |print(42 + 42)| |
michael@0 | 29 | var offset = frame2.script.getLineOffsets(3)[0]; |
michael@0 | 30 | frame2.script.setBreakpoint(offset, { hit: function (fr) { |
michael@0 | 31 | assertEq(fr.implementation != "ion", true); |
michael@0 | 32 | breakpointHit = true; |
michael@0 | 33 | }}); |
michael@0 | 34 | } |
michael@0 | 35 | }; |
michael@0 | 36 | |
michael@0 | 37 | g.eval("" + function f(d) { |
michael@0 | 38 | g(d); |
michael@0 | 39 | print(42 + 42); |
michael@0 | 40 | }); |
michael@0 | 41 | g.eval("" + function g(d) { toggle(d); }); |
michael@0 | 42 | |
michael@0 | 43 | g.eval("(" + function test() { |
michael@0 | 44 | for (var i = 0; i < 5; i++) |
michael@0 | 45 | f(false); |
michael@0 | 46 | f(true); |
michael@0 | 47 | } + ")();"); |
michael@0 | 48 | |
michael@0 | 49 | assertEq(onPopExecuted, true); |
michael@0 | 50 | assertEq(breakpointHit, true); |
michael@0 | 51 | }); |