browser_application_panel_viewsource-service-worker.js (1590B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TAB_URL = URL_ROOT + "resources/service-workers/debug.html"; 7 const SW_URL = URL_ROOT + "resources/service-workers/debug-sw.js"; 8 9 add_task(async function () { 10 await enableApplicationPanel(); 11 12 // disable service worker debugging 13 await pushPref( 14 "devtools.debugger.features.windowless-service-workers", 15 false 16 ); 17 18 const { panel, tab, commands } = await openNewTabAndApplicationPanel(TAB_URL); 19 const doc = panel.panelWin.document; 20 21 selectPage(panel, "service-workers"); 22 23 info("Wait until the service worker appears in the application panel"); 24 await waitUntil(() => getWorkerContainers(doc).length === 1); 25 26 const container = getWorkerContainers(doc)[0]; 27 info("Wait until the inspect link is displayed"); 28 await waitUntil(() => { 29 return container.querySelector(".js-inspect-link"); 30 }); 31 32 info("Click on the inspect link and wait for a new view-source: tab open"); 33 // click on the link and wait for the new tab to open 34 const onTabLoaded = BrowserTestUtils.waitForNewTab( 35 gBrowser, 36 `view-source:${SW_URL}` 37 ); 38 const inspectLink = container.querySelector(".js-inspect-link"); 39 inspectLink.click(); 40 41 const sourceTab = await onTabLoaded; 42 ok(sourceTab, "The service worker source was opened in a new tab"); 43 44 // clean up 45 await unregisterAllWorkers(commands.client, doc); 46 // close the tabs 47 info("Closing the tabs."); 48 await BrowserTestUtils.removeTab(sourceTab); 49 await BrowserTestUtils.removeTab(tab); 50 });