browser_application_panel_telemetry-debug-worker.js (1597B)
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/simple.html"; 7 8 // check telemetry for debugging a service worker 9 add_task(async function () { 10 await enableApplicationPanel(); 11 12 const { panel, tab, toolbox, commands } = 13 await openNewTabAndApplicationPanel(TAB_URL); 14 15 const doc = panel.panelWin.document; 16 17 selectPage(panel, "service-workers"); 18 setupTelemetryTest(); 19 20 info("Wait until the service worker appears in the application panel"); 21 await waitUntil(() => getWorkerContainers(doc).length === 1); 22 23 const container = getWorkerContainers(doc)[0]; 24 info("Wait until the debug link is displayed"); 25 await waitUntil(() => { 26 return container.querySelector(".js-inspect-link"); 27 }); 28 29 info("Click on the debug link and wait for debugger to be ready"); 30 const debugLink = container.querySelector(".js-inspect-link"); 31 debugLink.click(); 32 await waitUntil(() => toolbox.getPanel("jsdebugger")); 33 34 const events = getTelemetryEvents("jsdebugger"); 35 const openToolboxEvent = events.find(event => event.method == "enter"); 36 Assert.greater( 37 Number(openToolboxEvent.session_id), 38 0, 39 "Event has a valid session id" 40 ); 41 is( 42 openToolboxEvent.start_state, 43 "application", 44 "Event has the 'application' start state" 45 ); 46 47 // clean up and close the tab 48 await unregisterAllWorkers(commands.client, doc); 49 info("Closing the tab."); 50 await commands.client.waitForRequestsToSettle(); 51 await BrowserTestUtils.removeTab(tab); 52 });