browser_dbg-sourcemaps2.js (1838B)
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-sourcemaps2.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); 42 43 // Tests the existence of the sourcemap link in the original source. 44 let sourceMapLink = findElement(dbg, "mappedSourceLink"); 45 is( 46 sourceMapLink.textContent, 47 "To main.min.js", 48 "Sourcemap link in original source refers to the bundle" 49 ); 50 51 await selectSource(dbg, "main.min.js"); 52 53 // The mapped source link is computed asynchronously when we are on the bundle 54 sourceMapLink = await waitFor(() => findElement(dbg, "mappedSourceLink")); 55 is( 56 sourceMapLink.textContent, 57 "From main.js", 58 "Sourcemap link in bundle refers to the original source" 59 ); 60 });