browser_dbg-old-breakpoint.js (3089B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 // Test that we show a breakpoint in the UI when there is an old pending 6 // breakpoint with an invalid original location. 7 8 "use strict"; 9 10 add_task(async function () { 11 clearDebuggerPreferences(); 12 13 const pending = { 14 bp1: { 15 location: { 16 sourceId: "", 17 sourceUrl: `${EXAMPLE_URL}nowhere2.js`, 18 line: 5, 19 column: 0, 20 }, 21 generatedLocation: { 22 sourceUrl: `${EXAMPLE_URL}simple1.js`, 23 line: 4, 24 column: 0, 25 }, 26 options: {}, 27 disabled: false, 28 }, 29 bp2: { 30 location: { 31 sourceId: "", 32 sourceUrl: `${EXAMPLE_URL}nowhere.js`, 33 line: 5, 34 column: 0, 35 }, 36 generatedLocation: { 37 sourceUrl: `${EXAMPLE_URL}simple3.js`, 38 line: 2, 39 column: 0, 40 }, 41 options: {}, 42 disabled: false, 43 }, 44 }; 45 asyncStorage.setItem("debugger.pending-breakpoints", pending); 46 47 const toolbox = await openNewTabAndToolbox( 48 `${EXAMPLE_URL}doc-scripts.html`, 49 "jsdebugger" 50 ); 51 const dbg = createDebuggerContext(toolbox); 52 53 // Select a source so that the source editor gets initialized 54 await selectSource(dbg, "doc-scripts.html"); 55 56 const onBreakpoint = waitForDispatch(dbg.store, "SET_BREAKPOINT", 2); 57 const breakpointsVisible = await waitForState( 58 dbg, 59 state => dbg.selectors.getBreakpointCount(state) == 2 60 ); 61 // Pending breakpoints are installed asynchronously, keep invoking the entry 62 // function until the debugger pauses. 63 await waitUntil(async () => { 64 invokeInTab("main"); 65 return isPaused(dbg); 66 }); 67 ok(true, "Paused at unmapped breakpoint"); 68 await Promise.any([breakpointsVisible, onBreakpoint]); 69 70 is(dbg.selectors.getBreakpointCount(), 2, "Unmapped breakpoints shown in UI"); 71 }); 72 73 // Test that if we show a breakpoint with an old generated location, it is 74 // removed after we load the original source and find the new generated 75 // location. 76 add_task(async function () { 77 clearDebuggerPreferences(); 78 79 const pending = { 80 bp1: { 81 location: { 82 sourceId: "", 83 sourceUrl: "webpack:///entry.js", 84 line: 15, 85 column: 0, 86 }, 87 generatedLocation: { 88 sourceUrl: `${EXAMPLE_URL}sourcemaps/bundle.js`, 89 line: 47, 90 column: 16, 91 }, 92 options: {}, 93 disabled: false, 94 }, 95 }; 96 asyncStorage.setItem("debugger.pending-breakpoints", pending); 97 98 const toolbox = await openNewTabAndToolbox( 99 `${EXAMPLE_URL}doc-sourcemaps.html`, 100 "jsdebugger" 101 ); 102 const dbg = createDebuggerContext(toolbox); 103 104 await waitForState(dbg, state => { 105 const bps = dbg.selectors.getBreakpointsList(state); 106 return ( 107 bps.length == 1 && 108 bps[0].location.source.url.includes("entry.js") && 109 bps[0].location.line == 15 110 ); 111 }); 112 ok(true, "removed old breakpoint during sync"); 113 await waitForRequestsToSettle(dbg); 114 });