browser_toolbox_telemetry_close.js (1470B)
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 const { TelemetryTestUtils } = ChromeUtils.importESModule( 8 "resource://testing-common/TelemetryTestUtils.sys.mjs" 9 ); 10 11 const URL = "data:text/html;charset=utf8,browser_toolbox_telemetry_close.js"; 12 const { RIGHT, BOTTOM } = Toolbox.HostType; 13 const DATA = [ 14 { 15 category: "devtools.main", 16 method: "close", 17 object: "tools", 18 value: null, 19 extra: { 20 host: "right", 21 width: w => w > 0, 22 }, 23 }, 24 { 25 category: "devtools.main", 26 method: "close", 27 object: "tools", 28 value: null, 29 extra: { 30 host: "bottom", 31 width: w => w > 0, 32 }, 33 }, 34 ]; 35 36 add_task(async function () { 37 // Let's reset the counts. 38 Services.telemetry.clearEvents(); 39 40 // Ensure no events have been logged 41 TelemetryTestUtils.assertNumberOfEvents(0); 42 43 await openAndCloseToolbox("webconsole", RIGHT); 44 await openAndCloseToolbox("webconsole", BOTTOM); 45 46 checkResults(); 47 }); 48 49 async function openAndCloseToolbox(toolId, host) { 50 const tab = await addTab(URL); 51 const toolbox = await gDevTools.showToolboxForTab(tab, { toolId }); 52 53 await toolbox.switchHost(host); 54 await toolbox.destroy(); 55 } 56 57 function checkResults() { 58 TelemetryTestUtils.assertEvents(DATA, { 59 category: "devtools.main", 60 method: "close", 61 object: "tools", 62 }); 63 }