test_breakpoint-21.js (1862B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Bug 1122064 - make sure that scripts introduced via onNewScripts 8 * properly populate the `ScriptStore` with all there nested child 9 * scripts, so you can set breakpoints on deeply nested scripts 10 */ 11 12 add_task( 13 threadFrontTest(async ({ threadFront, debuggee }) => { 14 // Populate the `ScriptStore` so that we only test that the script 15 // is added through `onNewScript` 16 await getSources(threadFront); 17 18 let packet = await executeOnNextTickAndWaitForPause(() => { 19 evalCode(debuggee); 20 }, threadFront); 21 const source = await getSourceById(threadFront, packet.frame.where.actor); 22 const location = { 23 sourceUrl: source.url, 24 line: debuggee.line0 + 8, 25 }; 26 27 setBreakpoint(threadFront, location); 28 29 await resume(threadFront); 30 packet = await waitForPause(threadFront); 31 Assert.equal(packet.why.type, "breakpoint"); 32 Assert.equal(packet.frame.where.actor, source.actor); 33 Assert.equal(packet.frame.where.line, location.line); 34 35 await resume(threadFront); 36 }) 37 ); 38 39 function evalCode(debuggee) { 40 // Start a new script 41 /* eslint-disable mozilla/var-only-at-top-level, max-nested-callbacks, no-unused-vars */ 42 // prettier-ignore 43 Cu.evalInSandbox( 44 "var line0 = Error().lineNumber;\n(" + function () { 45 debugger; 46 var a = (function () { 47 return (function () { 48 return (function () { 49 return (function () { 50 return (function () { 51 var x = 10; // This line gets a breakpoint 52 return 1; 53 })(); 54 })(); 55 })(); 56 })(); 57 })(); 58 } + ")()", 59 debuggee 60 ); 61 /* eslint-enable mozilla/var-only-at-top-level, max-nested-callbacks, no-unused-vars */ 62 }