test_breakpoint-22.js (1449B)
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 1333219 - make that setBreakpoint fails when script is not found 8 * at the specified line. 9 */ 10 11 add_task( 12 threadFrontTest(async ({ threadFront, debuggee }) => { 13 // Populate the `ScriptStore` so that we only test that the script 14 // is added through `onNewScript` 15 await getSources(threadFront); 16 17 const packet = await executeOnNextTickAndWaitForPause(() => { 18 evalCode(debuggee); 19 }, threadFront); 20 const source = await getSourceById(threadFront, packet.frame.where.actor); 21 22 const location = { 23 line: debuggee.line0 + 2, 24 }; 25 26 const [res] = await setBreakpoint(source, location); 27 ok(!res.error); 28 29 const location2 = { 30 line: debuggee.line0 + 7, 31 }; 32 33 await source.setBreakpoint(location2).then( 34 () => { 35 do_throw("no code shall not be found the specified line or below it"); 36 }, 37 reason => { 38 Assert.equal(reason.error, "noCodeAtLineColumn"); 39 ok(reason.message); 40 } 41 ); 42 43 await resume(threadFront); 44 }) 45 ); 46 47 function evalCode(debuggee) { 48 // Start a new script 49 Cu.evalInSandbox( 50 ` 51 var line0 = Error().lineNumber; 52 function some_function() { 53 // breakpoint is valid here -- it slides one line below (line0 + 2) 54 } 55 debugger; 56 // no breakpoint is allowed after the EOF (line0 + 6) 57 `, 58 debuggee 59 ); 60 }