browser_application_panel_open-links.js (1441B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const { Toolbox } = require("resource://devtools/client/framework/toolbox.js"); 7 8 /** 9 * Check that links work when the devtools are detached in a separate window. 10 */ 11 12 const TAB_URL = URL_ROOT + "resources/service-workers/empty.html"; 13 14 add_task(async function () { 15 await enableApplicationPanel(); 16 17 const { panel, toolbox } = await openNewTabAndApplicationPanel(TAB_URL); 18 const doc = panel.panelWin.document; 19 20 selectPage(panel, "service-workers"); 21 22 // detach devtools in a separate window 23 await toolbox.switchHost(Toolbox.HostType.WINDOW); 24 25 // click on the link and wait for the new tab to open 26 const onTabLoaded = BrowserTestUtils.waitForNewTab( 27 gBrowser, 28 "about:debugging#workers", 29 true 30 ); 31 doc.querySelector(".js-trusted-link").click(); 32 info("Opening link in a new tab."); 33 const newTab = await onTabLoaded; 34 35 // We only need to check that newTab is truthy since 36 // BrowserTestUtils.waitForNewTab checks the URL. 37 ok(newTab, "The expected tab was opened."); 38 39 info("Wait until the main about debugging container is available"); 40 await waitUntil(() => { 41 const aboutDebuggingDoc = newTab.linkedBrowser.contentDocument; 42 return aboutDebuggingDoc.querySelector(".app"); 43 }); 44 45 // close the tab 46 info("Closing the tab."); 47 await BrowserTestUtils.removeTab(newTab); 48 });