test_conditional_breakpoint-02.js (1377B)
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 conditional breakpoint when condition evaluates to false. 8 */ 9 10 add_task( 11 threadFrontTest(async ({ threadFront, debuggee }) => { 12 const packet1 = await executeOnNextTickAndWaitForPause( 13 () => evalCode(debuggee), 14 threadFront 15 ); 16 17 const source = await getSourceById(threadFront, packet1.frame.where.actor); 18 const location1 = { sourceUrl: source.url, line: 3 }; 19 threadFront.setBreakpoint(location1, { condition: "a === 2" }); 20 21 const location2 = { sourceUrl: source.url, line: 4 }; 22 threadFront.setBreakpoint(location2, { condition: "a === 1" }); 23 24 // Continue until the breakpoint is hit. 25 const packet2 = await resumeAndWaitForPause(threadFront); 26 27 // Check the return value. 28 Assert.equal(packet2.why.type, "breakpoint"); 29 Assert.equal(packet2.frame.where.line, 4); 30 31 // Remove the breakpoint. 32 await threadFront.removeBreakpoint(location2); 33 34 await threadFront.resume(); 35 }) 36 ); 37 38 function evalCode(debuggee) { 39 /* eslint-disable */ 40 Cu.evalInSandbox( 41 "debugger;\n" + // line 1 42 "var a = 1;\n" + // line 2 43 "var b = 2;\n" + // line 3 44 "b++;" + // line 4 45 "debugger;", // line 5 46 debuggee, 47 "1.8", 48 "test.js", 49 1 50 ); 51 /* eslint-enable */ 52 }