browser_aboutdebugging_telemetry_inspect.js (1959B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* import-globals-from helper-telemetry.js */ 7 Services.scriptloader.loadSubScript( 8 CHROME_URL_ROOT + "helper-telemetry.js", 9 this 10 ); 11 12 const TAB_URL = "data:text/html,<title>TEST_TAB</title>"; 13 14 /** 15 * Check that telemetry events are recorded when inspecting a target. 16 */ 17 add_task(async function () { 18 setupTelemetryTest(); 19 20 const { document, tab, window } = await openAboutDebugging(); 21 await selectThisFirefoxPage(document, window.AboutDebugging.store); 22 23 const sessionId = getOpenEventSessionId(); 24 ok(!isNaN(sessionId), "Open event has a valid session id"); 25 26 info("Open a new background tab TEST_TAB"); 27 const backgroundTab1 = await addTab(TAB_URL, { background: true }); 28 29 info("Wait for the tab to appear in the debug targets with the correct name"); 30 await waitUntil(() => findDebugTargetByText("TEST_TAB", document)); 31 32 const { devtoolsTab } = await openAboutDevtoolsToolbox( 33 document, 34 tab, 35 window, 36 "TEST_TAB" 37 ); 38 39 const evts = readAboutDebuggingEvents().filter(e => e.method === "inspect"); 40 is(evts.length, 1, "Exactly one Inspect event found"); 41 is( 42 evts[0].extras.target_type, 43 "TAB", 44 "Inspect event has the expected target type" 45 ); 46 is( 47 evts[0].extras.runtime_type, 48 "this-firefox", 49 "Inspect event has the expected runtime type" 50 ); 51 is( 52 evts[0].extras.session_id, 53 sessionId, 54 "Inspect event has the expected session" 55 ); 56 57 info("Close the about:devtools-toolbox tab"); 58 await closeAboutDevtoolsToolbox(document, devtoolsTab, window); 59 await waitForAboutDebuggingRequests(window.AboutDebugging.store); 60 61 info("Remove first background tab"); 62 await removeTab(backgroundTab1); 63 await waitUntil(() => !findDebugTargetByText("TEST_TAB", document)); 64 await waitForAboutDebuggingRequests(window.AboutDebugging.store); 65 66 await removeTab(tab); 67 });