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