Bug 1456087 - Create tests for devtools.main.exit telemetry event r=yulia
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Wed, 25 Apr 2018 17:18:58 +0100
changeset 471944 5af5821aa84c8f73fdf1d1802b3eea717fc4c8a4
parent 471862 04ed4418999887db0ef9caf980ba2469ee19793b
child 471945 9a020203cc6fca59853fb4f3e92eff9590896cc3
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1456087
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456087 - Create tests for devtools.main.exit telemetry event r=yulia MozReview-Commit-ID: J2PgWMEfE5C
devtools/client/framework/test/browser.ini
devtools/client/framework/test/browser_toolbox_telemetry_exit.js
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -102,16 +102,17 @@ skip-if = e10s # Bug 1069044 - destroyIn
 [browser_toolbox_sidebar_events.js]
 [browser_toolbox_sidebar_existing_tabs.js]
 [browser_toolbox_sidebar_overflow_menu.js]
 [browser_toolbox_split_console.js]
 [browser_toolbox_target.js]
 [browser_toolbox_tabsswitch_shortcuts.js]
 [browser_toolbox_telemetry_close.js]
 [browser_toolbox_telemetry_enter.js]
+[browser_toolbox_telemetry_exit.js]
 [browser_toolbox_textbox_context_menu.js]
 [browser_toolbox_theme.js]
 [browser_toolbox_theme_registration.js]
 [browser_toolbox_toggle.js]
 [browser_toolbox_tool_ready.js]
 [browser_toolbox_tool_remote_reopen.js]
 [browser_toolbox_toolbar_overflow.js]
 [browser_toolbox_toolbar_reorder_by_dnd.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/framework/test/browser_toolbox_telemetry_exit.js
@@ -0,0 +1,126 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const URL = "data:text/html;charset=utf8,browser_toolbox_telemetry_enter.js";
+const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT;
+const DATA = [
+  {
+    timestamp: null,
+    category: "devtools.main",
+    method: "exit",
+    object: "inspector",
+    value: null,
+    extra: {
+      host: "bottom",
+      width: 1300,
+      panel_name: "inspector",
+      next_panel: "jsdebugger",
+      reason: "toolbox_show"
+    }
+  }, {
+    timestamp: null,
+    category: "devtools.main",
+    method: "exit",
+    object: "jsdebugger",
+    value: null,
+    extra: {
+      host: "bottom",
+      width: 1300,
+      panel_name: "jsdebugger",
+      next_panel: "styleeditor",
+      reason: "toolbox_show"
+    }
+  }, {
+    timestamp: null,
+    category: "devtools.main",
+    method: "exit",
+    object: "styleeditor",
+    value: null,
+    extra: {
+      host: "bottom",
+      width: 1300,
+      panel_name: "styleeditor",
+      next_panel: "netmonitor",
+      reason: "toolbox_show"
+    }
+  }, {
+    timestamp: null,
+    category: "devtools.main",
+    method: "exit",
+    object: "netmonitor",
+    value: null,
+    extra: {
+      host: "bottom",
+      width: 1300,
+      panel_name: "netmonitor",
+      next_panel: "storage",
+      reason: "toolbox_show"
+    }
+  }, {
+    timestamp: null,
+    category: "devtools.main",
+    method: "exit",
+    object: "storage",
+    value: null,
+    extra: {
+      host: "bottom",
+      width: 1300,
+      panel_name: "storage",
+      next_panel: "netmonitor",
+      reason: "toolbox_show"
+    }
+  }
+];
+
+add_task(async function() {
+  // Let's reset the counts.
+  Services.telemetry.clearEvents();
+
+  // Ensure no events have been logged
+  const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
+  ok(!snapshot.parent, "No events have been logged for the main process");
+
+  const tab = await addTab(URL);
+  const target = TargetFactory.forTab(tab);
+
+  // Open the toolbox
+  await gDevTools.showToolbox(target, "inspector");
+
+  // Switch between a few tools
+  await gDevTools.showToolbox(target, "jsdebugger");
+  await gDevTools.showToolbox(target, "styleeditor");
+  await gDevTools.showToolbox(target, "netmonitor");
+  await gDevTools.showToolbox(target, "storage");
+  await gDevTools.showToolbox(target, "netmonitor");
+
+  await checkResults();
+});
+
+async function checkResults() {
+  const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true);
+  const events = snapshot.parent.filter(event => event[1] === "devtools.main" &&
+                                                 event[2] === "exit" &&
+                                                 event[4] === null
+  );
+
+  for (let i in DATA) {
+    const [ timestamp, category, method, object, value, extra ] = events[i];
+    const expected = DATA[i];
+
+    // ignore timestamp
+    ok(timestamp > 0, "timestamp is greater than 0");
+    is(category, expected.category, "category is correct");
+    is(method, expected.method, "method is correct");
+    is(object, expected.object, "object is correct");
+    is(value, expected.value, "value is correct");
+
+    // extras
+    is(extra.host, expected.extra.host, "host is correct");
+    ok(extra.width > 0, "width is greater than 0");
+    is(extra.panel_name, expected.extra.panel_name, "panel_name is correct");
+    is(extra.next_panel, expected.extra.next_panel, "next_panel is correct");
+    is(extra.reason, expected.extra.reason, "reason is correct");
+  }
+}