browser_dbg-tabs-without-urls.js (1289B)
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 URL-less sources have tabs added to the UI, are named correctly 6 // and do not persist upon reload 7 8 "use strict"; 9 10 add_task(async function () { 11 const dbg = await initDebugger( 12 "doc-scripts.html", 13 "simple1.js", 14 "simple2.js" 15 ); 16 17 await selectSource(dbg, "simple1.js"); 18 is(countTabs(dbg), 1, "Only the `simple.js` source tab exists"); 19 20 invokeInTab("doEval"); 21 await waitForPaused(dbg); 22 23 is(countTabs(dbg), 2, "The new eval tab is now added"); 24 25 info("Assert that the eval source the tab source name correctly"); 26 ok( 27 /source\d+/g.test(getTabContent(dbg, 0)), 28 "The tab name pattern is correct" 29 ); 30 31 await resume(dbg); 32 33 // Test reloading the debugger 34 await reload(dbg, "simple1.js", "simple2.js"); 35 is(countTabs(dbg), 1, "The eval source tab is no longer available"); 36 }); 37 38 /** 39 * Get the tab content for the specific tab 40 * 41 * @param {number} index - index of the tab to get the source content 42 */ 43 function getTabContent(dbg, index) { 44 const tabs = findElement(dbg, "sourceTabs").children; 45 return tabs[index]?.innerText || ""; 46 }