browser_toolbox_telemetry_open_event.js (1391B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that the "open" telemetry event is correctly logged when opening the 7 // toolbox. 8 const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS; 9 10 add_task(async function () { 11 const tab = await addTab("data:text/html;charset=utf-8,Test open event"); 12 13 info("Open the toolbox with a shortcut to trigger the open event"); 14 const onToolboxReady = gDevTools.once("toolbox-ready"); 15 EventUtils.synthesizeKey("VK_F12", {}); 16 await onToolboxReady; 17 18 const snapshot = Services.telemetry.snapshotEvents(ALL_CHANNELS, true); 19 // The telemetry is sent by DevToolsStartup and so isn't flaged against any session id 20 const events = snapshot.parent.filter( 21 event => 22 event[1] === "devtools.main" && 23 event[2] === "open" && 24 event[5].session_id == -1 25 ); 26 27 is(events.length, 1, "Telemetry open event was logged"); 28 29 const extras = events[0][5]; 30 is(extras.entrypoint, "KeyShortcut", "entrypoint extra is correct"); 31 // The logged shortcut is `${modifiers}+${shortcut}`, which adds an 32 // extra `+` before F12 here. 33 // See https://searchfox.org/mozilla-central/rev/c7e8bc4996f979e5876b33afae3de3b1ab4f3ae1/devtools/startup/DevToolsStartup.jsm#1070 34 is(extras.shortcut, "+F12", "entrypoint shortcut is correct"); 35 36 gBrowser.removeTab(tab); 37 });