browser_source_map-01.js (2441B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests the SourceMapService updates generated sources when source maps 8 * are subsequently found. Also checks when no column is provided, and 9 * when tagging an already source mapped location initially. 10 */ 11 12 // There are shutdown issues for which multiple rejections are left uncaught. 13 // See bug 1018184 for resolving these issues. 14 const { PromiseTestUtils } = ChromeUtils.importESModule( 15 "resource://testing-common/PromiseTestUtils.sys.mjs" 16 ); 17 PromiseTestUtils.allowMatchingRejectionsGlobally(/this\.worker is null/); 18 PromiseTestUtils.allowMatchingRejectionsGlobally(/Component not initialized/); 19 20 // Empty page 21 const PAGE_URL = `${URL_ROOT_SSL}doc_empty-tab-01.html`; 22 const JS_URL = `${URL_ROOT_SSL}code_binary_search.js`; 23 const COFFEE_URL = `${URL_ROOT_SSL}code_binary_search.coffee`; 24 25 add_task(async function () { 26 const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger"); 27 const service = toolbox.sourceMapURLService; 28 29 // Inject JS script 30 const sourceSeen = waitForSourceLoad(toolbox, JS_URL); 31 await createScript(JS_URL); 32 await sourceSeen; 33 34 const loc1 = { url: JS_URL, line: 6 }; 35 const newLoc1 = await new Promise(r => 36 service.subscribeByURL(loc1.url, loc1.line, 4, r) 37 ); 38 checkLoc1(loc1, newLoc1); 39 40 const loc2 = { url: JS_URL, line: 8, column: 3 }; 41 const newLoc2 = await new Promise(r => 42 service.subscribeByURL(loc2.url, loc2.line, loc2.column, r) 43 ); 44 checkLoc2(loc2, newLoc2); 45 46 await toolbox.destroy(); 47 gBrowser.removeCurrentTab(); 48 finish(); 49 }); 50 51 function checkLoc1(oldLoc, newLoc) { 52 is(oldLoc.line, 6, "Correct line for JS:6"); 53 is(oldLoc.column, undefined, "Correct column for JS:6"); 54 is(oldLoc.url, JS_URL, "Correct url for JS:6"); 55 is(newLoc.line, 4, "Correct line for JS:6 -> COFFEE"); 56 is( 57 newLoc.column, 58 2, 59 "Correct column for JS:6 -> COFFEE -- handles falsy column entries" 60 ); 61 is(newLoc.url, COFFEE_URL, "Correct url for JS:6 -> COFFEE"); 62 } 63 64 function checkLoc2(oldLoc, newLoc) { 65 is(oldLoc.line, 8, "Correct line for JS:8:3"); 66 is(oldLoc.column, 3, "Correct column for JS:8:3"); 67 is(oldLoc.url, JS_URL, "Correct url for JS:8:3"); 68 is(newLoc.line, 6, "Correct line for JS:8:3 -> COFFEE"); 69 is(newLoc.column, 10, "Correct column for JS:8:3 -> COFFEE"); 70 is(newLoc.url, COFFEE_URL, "Correct url for JS:8:3 -> COFFEE"); 71 }