test_breakpoint-06.js (2453B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 /* eslint-disable no-shadow, max-nested-callbacks */ 4 5 "use strict"; 6 7 /** 8 * Check that setting a breakpoint in a line without code in a deeply-nested 9 * child script will skip forward. 10 */ 11 12 add_task( 13 threadFrontTest(({ threadFront, debuggee }) => { 14 return new Promise(resolve => { 15 threadFront.once("paused", async function (packet) { 16 const source = await getSourceById( 17 threadFront, 18 packet.frame.where.actor 19 ); 20 const location = { line: debuggee.line0 + 5 }; 21 22 source.setBreakpoint(location).then(function ([response, bpClient]) { 23 // Check that the breakpoint has properly skipped forward one line. 24 Assert.equal(response.actualLocation.source.actor, source.actor); 25 Assert.equal(response.actualLocation.line, location.line + 1); 26 27 threadFront.once("paused", function (packet) { 28 // Check the return value. 29 Assert.equal(packet.frame.where.actor, source.actor); 30 Assert.equal(packet.frame.where.line, location.line + 1); 31 Assert.equal(packet.why.type, "breakpoint"); 32 Assert.equal(packet.why.actors[0], bpClient.actor); 33 // Check that the breakpoint worked. 34 Assert.equal(debuggee.a, 1); 35 Assert.equal(debuggee.b, undefined); 36 37 // Remove the breakpoint. 38 bpClient.remove(function () { 39 threadFront.resume().then(resolve); 40 }); 41 }); 42 43 // Continue until the breakpoint is hit. 44 threadFront.resume(); 45 }); 46 }); 47 48 // prettier-ignore 49 Cu.evalInSandbox( 50 "var line0 = Error().lineNumber;\n" + 51 "function foo() {\n" + // line0 + 1 52 " function bar() {\n" + // line0 + 2 53 " function baz() {\n" + // line0 + 3 54 " this.a = 1;\n" + // line0 + 4 55 " // A comment.\n" + // line0 + 5 56 " this.b = 2;\n" + // line0 + 6 57 " }\n" + // line0 + 7 58 " baz();\n" + // line0 + 8 59 " }\n" + // line0 + 9 60 " bar();\n" + // line0 + 10 61 "}\n" + // line0 + 11 62 "debugger;\n" + // line0 + 12 63 "foo();\n", // line0 + 13 64 debuggee 65 ); 66 }); 67 }) 68 );