browser_dbg-sourcemaps-indexed.js (1634B)
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 // Tests loading sourcemapped sources, setting breakpoints, and 6 // stepping in them. 7 8 "use strict"; 9 10 requestLongerTimeout(2); 11 12 // This source map does not have source contents, so it's fetched separately 13 add_task(async function () { 14 // NOTE: the CORS call makes the test run times inconsistent 15 const dbg = await initDebugger( 16 "doc-sourcemaps-indexed.html", 17 "main.js", 18 "main.min.js" 19 ); 20 const { 21 selectors: { getBreakpoint, getBreakpointCount }, 22 } = dbg; 23 24 ok(true, "Original sources exist"); 25 const mainSrc = findSource(dbg, "main.js"); 26 27 await selectSource(dbg, mainSrc); 28 29 // Test that breakpoint is not off by a line. 30 await addBreakpoint(dbg, mainSrc, 4, 3); 31 is(getBreakpointCount(), 1, "One breakpoint exists"); 32 ok( 33 getBreakpoint(createLocation({ source: mainSrc, line: 4, column: 2 })), 34 "Breakpoint has correct line" 35 ); 36 37 await assertBreakpoint(dbg, 4); 38 invokeInTab("logMessage"); 39 40 await waitForPausedInOriginalFileAndToggleMapScopes(dbg); 41 await assertPausedAtSourceAndLine(dbg, mainSrc.id, 4, 3); 42 43 // Tests the existence of the sourcemap link in the original source. 44 is( 45 findElement(dbg, "mappedSourceLink").textContent, 46 "To main.min.js", 47 "Sourcemap link in original source" 48 ); 49 await selectSource(dbg, "main.min.js"); 50 51 is( 52 findElement(dbg, "mappedSourceLink").textContent, 53 "From main.js", 54 "Sourcemap link in generated source" 55 ); 56 });