test_breakpoint-18.js (1566B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that we only break on offsets that are entry points for the line we are 8 * breaking on. Bug 907278. 9 */ 10 11 add_task( 12 threadFrontTest(async ({ threadFront, client, debuggee }) => { 13 const packet = await executeOnNextTickAndWaitForPause( 14 () => evaluateTestCode(debuggee), 15 threadFront 16 ); 17 18 const source = await getSourceById(threadFront, packet.frame.where.actor); 19 const location = { sourceUrl: source.url, line: 3 }; 20 threadFront.setBreakpoint(location, {}); 21 await client.waitForRequestsToSettle(); 22 23 debuggee.eval("var console = { log: x => void x }"); 24 25 await resume(threadFront); 26 27 const packet2 = await executeOnNextTickAndWaitForPause( 28 () => debuggee.eval("test()"), 29 threadFront 30 ); 31 Assert.equal(packet2.why.type, "breakpoint"); 32 33 const packet3 = await resumeAndWaitForPause(threadFront); 34 testDbgStatement(packet3); 35 36 await resume(threadFront); 37 }) 38 ); 39 40 function evaluateTestCode(debuggee) { 41 Cu.evalInSandbox( 42 "debugger;\n" + 43 function test() { 44 console.log("foo bar"); 45 debugger; 46 }, 47 debuggee, 48 "1.8", 49 "http://example.com/", 50 1 51 ); 52 } 53 54 function testDbgStatement({ why }) { 55 // Should continue to the debugger statement. 56 Assert.equal(why.type, "debuggerStatement"); 57 // Not break on another offset from the same line (that isn't an entry point 58 // to the line) 59 Assert.notEqual(why.type, "breakpoint"); 60 }