test_breakpoint-10.js (2628B)
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 setting a breakpoint in a line with multiple entry points 8 * triggers no matter which entry point we reach. 9 */ 10 11 add_task( 12 threadFrontTest(async ({ threadFront, client, debuggee }) => { 13 const packet = await executeOnNextTickAndWaitForPause( 14 () => evaluateTestCode(debuggee), 15 threadFront 16 ); 17 const source = await getSourceById(threadFront, packet.frame.where.actor); 18 const location = { 19 sourceUrl: source.url, 20 line: debuggee.line0 + 3, 21 column: 5, 22 }; 23 24 //Pause at debugger statement. 25 Assert.equal(packet.frame.where.line, debuggee.line0 + 1); 26 Assert.equal(packet.why.type, "debuggerStatement"); 27 28 threadFront.setBreakpoint(location, {}); 29 await client.waitForRequestsToSettle(); 30 31 await resume(threadFront); 32 33 const packet2 = await waitForPause(threadFront); 34 // Check the return value. 35 Assert.equal(packet2.why.type, "breakpoint"); 36 // Check that the breakpoint worked. 37 Assert.equal(debuggee.i, 0); 38 // Check pause location 39 Assert.equal(packet2.frame.where.line, debuggee.line0 + 3); 40 Assert.equal(packet2.frame.where.column, 5); 41 42 // Remove the breakpoint. 43 threadFront.removeBreakpoint(location); 44 await client.waitForRequestsToSettle(); 45 46 const location2 = { 47 sourceUrl: source.url, 48 line: debuggee.line0 + 3, 49 column: 12, 50 }; 51 threadFront.setBreakpoint(location2, {}); 52 await client.waitForRequestsToSettle(); 53 54 await resume(threadFront); 55 const packet3 = await waitForPause(threadFront); 56 // Check the return value. 57 Assert.equal(packet3.why.type, "breakpoint"); 58 // Check that the breakpoint worked. 59 Assert.equal(debuggee.i, 1); 60 // Check execution location 61 Assert.equal(packet3.frame.where.line, debuggee.line0 + 3); 62 Assert.equal(packet3.frame.where.column, 12); 63 64 // Remove the breakpoint. 65 threadFront.removeBreakpoint(location2); 66 await client.waitForRequestsToSettle(); 67 68 await resume(threadFront); 69 }) 70 ); 71 72 function evaluateTestCode(debuggee) { 73 // prettier-ignore 74 Cu.evalInSandbox("var line0 = Error().lineNumber;\n" + 75 "debugger;\n" + // line0 + 1 76 "var a, i = 0;\n" + // line0 + 2 77 "for (i = 1; i <= 2; i++) {\n" + // line0 + 3 78 " a = i;\n" + // line0 + 4 79 "}\n", // line0 + 5 80 debuggee); 81 }