browser_dbg-sourcemaps-reloading.js (1795B)
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 "use strict"; 6 7 requestLongerTimeout(2); 8 9 add_task(async function () { 10 // NOTE: the CORS call makes the test run times inconsistent 11 const dbg = await initDebugger("doc-sourcemaps.html"); 12 const { 13 selectors: { getBreakpoint, getBreakpointCount }, 14 } = dbg; 15 16 await waitForSources(dbg, "entry.js", "output.js", "times2.js", "opts.js"); 17 ok(true, "Original sources exist"); 18 const entrySrc = findSource(dbg, "entry.js"); 19 20 await selectSource(dbg, entrySrc); 21 ok( 22 getEditorContent(dbg).includes("window.keepMeAlive"), 23 "Original source text loaded correctly" 24 ); 25 26 await addBreakpoint(dbg, entrySrc, 5); 27 await addBreakpoint(dbg, entrySrc, 15, 1); 28 await disableBreakpoint(dbg, entrySrc, 15, 1); 29 30 // Test reloading the debugger 31 const onReloaded = reload(dbg, "opts.js"); 32 await waitForDispatch(dbg.store, "LOAD_ORIGINAL_SOURCE_TEXT"); 33 34 await waitForPausedInOriginalFileAndToggleMapScopes(dbg, "entry.js"); 35 await assertPausedAtSourceAndLine(dbg, findSource(dbg, "entry.js").id, 5); 36 37 await waitForBreakpointCount(dbg, 2); 38 is(getBreakpointCount(), 2, "Two breakpoints exist"); 39 40 const bp = getBreakpoint( 41 createLocation({ 42 source: entrySrc, 43 line: 15, 44 column: 0, 45 }) 46 ); 47 ok(bp, "Breakpoint is on the correct line"); 48 ok(bp.disabled, "Breakpoint is disabled"); 49 await assertBreakpoint(dbg, 15); 50 51 await resume(dbg); 52 info("Wait for reload to complete after resume"); 53 await onReloaded; 54 }); 55 56 async function waitForBreakpointCount(dbg, count) { 57 return waitForState(dbg, () => dbg.selectors.getBreakpointCount() === count); 58 }