diff --git a/browser/devtools/canvasdebugger/canvasdebugger.js b/browser/devtools/canvasdebugger/canvasdebugger.js index e333fe80204..ddfa89a6cd4 100644 --- a/browser/devtools/canvasdebugger/canvasdebugger.js +++ b/browser/devtools/canvasdebugger/canvasdebugger.js @@ -15,8 +15,6 @@ const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; const EventEmitter = require("devtools/toolkit/event-emitter"); const { CallWatcherFront } = require("devtools/server/actors/call-watcher"); const { CanvasFront } = require("devtools/server/actors/canvas"); -const Telemetry = require("devtools/shared/telemetry"); -const telemetry = new Telemetry(); XPCOMUtils.defineLazyModuleGetter(this, "Task", "resource://gre/modules/Task.jsm"); @@ -122,7 +120,6 @@ let EventsHandler = { * Listen for events emitted by the current tab target. */ initialize: function() { - telemetry.toolOpened("canvasdebugger"); this._onTabNavigated = this._onTabNavigated.bind(this); gTarget.on("will-navigate", this._onTabNavigated); gTarget.on("navigate", this._onTabNavigated); @@ -132,7 +129,6 @@ let EventsHandler = { * Remove events emitted by the current tab target. */ destroy: function() { - telemetry.toolClosed("canvasdebugger"); gTarget.off("will-navigate", this._onTabNavigated); gTarget.off("navigate", this._onTabNavigated); }, diff --git a/browser/devtools/shadereditor/shadereditor.js b/browser/devtools/shadereditor/shadereditor.js index ec6eafea366..3d9824d8986 100644 --- a/browser/devtools/shadereditor/shadereditor.js +++ b/browser/devtools/shadereditor/shadereditor.js @@ -16,8 +16,6 @@ const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; const EventEmitter = require("devtools/toolkit/event-emitter"); const {Tooltip} = require("devtools/shared/widgets/Tooltip"); const Editor = require("devtools/sourceeditor/editor"); -const Telemetry = require("devtools/shared/telemetry"); -const telemetry = new Telemetry(); // The panel's window global is an EventEmitter firing the following events: const EVENTS = { @@ -85,7 +83,6 @@ let EventsHandler = { * Listen for events emitted by the current tab target. */ initialize: function() { - telemetry.toolOpened("shadereditor"); this._onHostChanged = this._onHostChanged.bind(this); this._onTabNavigated = this._onTabNavigated.bind(this); this._onProgramLinked = this._onProgramLinked.bind(this); @@ -101,7 +98,6 @@ let EventsHandler = { * Remove events emitted by the current tab target. */ destroy: function() { - telemetry.toolClosed("shadereditor"); gToolbox.off("host-changed", this._onHostChanged); gTarget.off("will-navigate", this._onTabNavigated); gTarget.off("navigate", this._onTabNavigated); diff --git a/browser/devtools/shared/telemetry.js b/browser/devtools/shared/telemetry.js index 5221da113f5..a434d8595e2 100644 --- a/browser/devtools/shared/telemetry.js +++ b/browser/devtools/shared/telemetry.js @@ -19,17 +19,8 @@ * timerHistogram: "DEVTOOLS_MYTOOLNAME_TIME_ACTIVE_SECONDS" * }, * - * 3. Include this module at the top of your tool. Use: - * let Telemetry = require("devtools/shared/telemetry") - * - * 4. Create a telemetry instance in your tool's constructor: - * this._telemetry = new Telemetry(); - * - * 5. When your tool is opened call: - * this._telemetry.toolOpened("mytoolname"); - * - * 6. When your tool is closed call: - * this._telemetry.toolClosed("mytoolname"); + * 3. toolbox.js will automatically ping telemetry with your tools opening and + * timing information. * * Note: * You can view telemetry stats for your local Firefox instance via @@ -303,6 +294,10 @@ Telemetry.prototype = { } }, + clearToolsOpenedPref: function() { + Services.prefs.clearUserPref(TOOLS_OPENED_PREF); + }, + destroy: function() { for (let histogramId of this._timers.keys()) { this.stopTimer(histogramId); diff --git a/browser/devtools/shared/test/browser_observableobject.js b/browser/devtools/shared/test/browser_observableobject.js index 8bd1d516944..5c1cdc69acc 100644 --- a/browser/devtools/shared/test/browser_observableobject.js +++ b/browser/devtools/shared/test/browser_observableobject.js @@ -2,9 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ function test() { - let tmp = {}; - Cu.import("resource://gre/modules/devtools/Loader.jsm", tmp); - let ObservableObject = tmp.devtools.require("devtools/shared/observable-object"); + let ObservableObject = devtools.require("devtools/shared/observable-object"); let rawObject = {}; let oe = new ObservableObject(rawObject); diff --git a/browser/devtools/shared/test/browser_options-view-01.js b/browser/devtools/shared/test/browser_options-view-01.js index 398b5175a38..58cd59de870 100644 --- a/browser/devtools/shared/test/browser_options-view-01.js +++ b/browser/devtools/shared/test/browser_options-view-01.js @@ -4,7 +4,6 @@ // Tests that options-view OptionsView responds to events correctly. const {OptionsView} = devtools.require("devtools/shared/options-view"); -const {Services} = devtools.require("resource://gre/modules/Services.jsm"); const BRANCH = "devtools.debugger."; const BLACK_BOX_PREF = "auto-black-box"; diff --git a/browser/devtools/shared/test/browser_outputparser.js b/browser/devtools/shared/test/browser_outputparser.js index 583f74fad4f..47fe9685a00 100644 --- a/browser/devtools/shared/test/browser_outputparser.js +++ b/browser/devtools/shared/test/browser_outputparser.js @@ -1,8 +1,6 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ -let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); -let {Loader} = Cu.import("resource://gre/modules/commonjs/toolkit/loader.js", {}); let {OutputParser} = devtools.require("devtools/output-parser"); add_task(function*() { diff --git a/browser/devtools/shared/test/browser_telemetry_button_eyedropper.js b/browser/devtools/shared/test/browser_telemetry_button_eyedropper.js index 946e4174ebf..2b2cf2e7af4 100644 --- a/browser/devtools/shared/test/browser_telemetry_button_eyedropper.js +++ b/browser/devtools/shared/test/browser_telemetry_button_eyedropper.js @@ -8,50 +8,41 @@ let {EyedropperManager} = require("devtools/eyedropper/eyedropper"); add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); info("inspector opened"); info("testing the eyedropper button"); - testButton(toolbox, Telemetry); + testButton(toolbox); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); -function testButton(toolbox, Telemetry) { +function testButton(toolbox) { let button = toolbox.doc.querySelector("#command-button-eyedropper"); ok(button, "Captain, we have the eyedropper button"); info("clicking the button to open the eyedropper"); button.click(); - checkResults("_EYEDROPPER_", Telemetry); + checkResults(); } -function checkResults(histIdFocus, Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_") || - !histId.contains(histIdFocus)) { - // Inspector stats are tested in - // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here - // because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - is(value.length, 1, histId + " has one entry"); - - let okay = value.every(element => element === true); - ok(okay, "All " + histId + " entries are === true"); - } - } +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_EYEDROPPER_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_EYEDROPPER_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_button_paintflashing.js b/browser/devtools/shared/test/browser_telemetry_button_paintflashing.js index 692df44c457..6e9ff2e31c9 100644 --- a/browser/devtools/shared/test/browser_telemetry_button_paintflashing.js +++ b/browser/devtools/shared/test/browser_telemetry_button_paintflashing.js @@ -10,28 +10,28 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); info("inspector opened"); info("testing the paintflashing button"); - yield testButton(toolbox, Telemetry); + yield testButton(toolbox); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); -function* testButton(toolbox, Telemetry) { +function* testButton(toolbox) { info("Testing command-button-paintflashing"); let button = toolbox.doc.querySelector("#command-button-paintflashing"); ok(button, "Captain, we have the button"); yield delayedClicks(button, 4); - checkResults("_PAINTFLASHING_", Telemetry); + checkResults(); } function delayedClicks(node, clicks) { @@ -53,37 +53,19 @@ function delayedClicks(node, clicks) { }); } -function checkResults(histIdFocus, Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_") || - !histId.contains(histIdFocus)) { - // Inspector stats are tested in - // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here - // because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); - } - } +function checkResults(histIdFocus) { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_PROTOCOLDESCRIPTION_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_PAINTFLASHING_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_PAINTFLASHING_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_PAINTFLASHING_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_button_responsive.js b/browser/devtools/shared/test/browser_telemetry_button_responsive.js index fd9a33460cb..759d2df10b3 100644 --- a/browser/devtools/shared/test/browser_telemetry_button_responsive.js +++ b/browser/devtools/shared/test/browser_telemetry_button_responsive.js @@ -10,28 +10,28 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); info("inspector opened"); info("testing the responsivedesign button"); - yield testButton(toolbox, Telemetry); + yield testButton(toolbox); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); -function* testButton(toolbox, Telemetry) { +function* testButton(toolbox) { info("Testing command-button-responsive"); let button = toolbox.doc.querySelector("#command-button-responsive"); ok(button, "Captain, we have the button"); yield delayedClicks(button, 4); - checkResults("_RESPONSIVE_", Telemetry); + checkResults(); } function delayedClicks(node, clicks) { @@ -53,37 +53,19 @@ function delayedClicks(node, clicks) { }); } -function checkResults(histIdFocus, Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_") || - !histId.contains(histIdFocus)) { - // Inspector stats are tested in - // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here - // because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); - } - } +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_PROTOCOLDESCRIPTION_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RESPONSIVE_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_RESPONSIVE_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RESPONSIVE_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_button_scratchpad.js b/browser/devtools/shared/test/browser_telemetry_button_scratchpad.js index f96755fcf8e..2295f97c68f 100644 --- a/browser/devtools/shared/test/browser_telemetry_button_scratchpad.js +++ b/browser/devtools/shared/test/browser_telemetry_button_scratchpad.js @@ -10,7 +10,8 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); @@ -19,12 +20,11 @@ add_task(function*() { let onAllWindowsOpened = trackScratchpadWindows(); info("testing the scratchpad button"); - yield testButton(toolbox, Telemetry); + yield testButton(toolbox); yield onAllWindowsOpened; - checkResults("_SCRATCHPAD_", Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); @@ -64,7 +64,7 @@ function trackScratchpadWindows() { }); } -function* testButton(toolbox, Telemetry) { +function* testButton(toolbox) { info("Testing command-button-scratchpad"); let button = toolbox.doc.querySelector("#command-button-scratchpad"); ok(button, "Captain, we have the button"); @@ -91,37 +91,18 @@ function delayedClicks(node, clicks) { }); } -function checkResults(histIdFocus, Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_") || - !histId.contains(histIdFocus)) { - // Inspector stats are tested in - // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here - // because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); - } - } +function checkResults(histIdFocus) { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_PROTOCOLDESCRIPTION_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_SCRATCHPAD_OPENED_BOOLEAN", [0,4,0]); + checkTelemetry("DEVTOOLS_SCRATCHPAD_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_button_tilt.js b/browser/devtools/shared/test/browser_telemetry_button_tilt.js index 4e36618ca5e..82e096f249d 100644 --- a/browser/devtools/shared/test/browser_telemetry_button_tilt.js +++ b/browser/devtools/shared/test/browser_telemetry_button_tilt.js @@ -10,28 +10,28 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); info("inspector opened"); info("testing the tilt button"); - yield testButton(toolbox, Telemetry); + yield testButton(toolbox); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); -function* testButton(toolbox, Telemetry) { +function* testButton(toolbox) { info("Testing command-button-tilt"); let button = toolbox.doc.querySelector("#command-button-tilt"); ok(button, "Captain, we have the button"); - yield delayedClicks(button, 4) - checkResults("_TILT_", Telemetry); + yield delayedClicks(button, 4); + checkResults(); } function delayedClicks(node, clicks) { @@ -53,37 +53,19 @@ function delayedClicks(node, clicks) { }); } -function checkResults(histIdFocus, Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_") || - !histId.contains(histIdFocus)) { - // Inspector stats are tested in - // browser_telemetry_toolboxtabs_{toolname}.js so we skip them here - // because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); - } - } +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_PROTOCOLDESCRIPTION_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TILT_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TILT_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TILT_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_sidebar.js b/browser/devtools/shared/test/browser_telemetry_sidebar.js index b80930e0e6c..977ff3476cf 100644 --- a/browser/devtools/shared/test/browser_telemetry_sidebar.js +++ b/browser/devtools/shared/test/browser_telemetry_sidebar.js @@ -9,16 +9,16 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); let target = TargetFactory.forTab(gBrowser.selectedTab); let toolbox = yield gDevTools.showToolbox(target, "inspector"); info("inspector opened"); yield testSidebar(toolbox); - checkResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); yield gDevTools.closeToolbox(target); gBrowser.removeCurrentTab(); }); @@ -49,37 +49,29 @@ function* testSidebar(toolbox) { }); } -function checkResults(Telemetry) { - let result = Telemetry.prototype.telemetryInfo; - - for (let [histId, value] of Iterator(result)) { - if (histId.startsWith("DEVTOOLS_INSPECTOR_")) { - // Inspector stats are tested in browser_telemetry_toolboxtabs.js so we - // skip them here because we only open the inspector once for this test. - continue; - } - - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId === "DEVTOOLS_TOOLBOX_OPENED_BOOLEAN") { - is(value.length, 1, histId + " has only one entry"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); - } - } +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_ANIMATIONINSPECTOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_ANIMATIONINSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_ANIMATIONINSPECTOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_COMPUTEDVIEW_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_COMPUTEDVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_COMPUTEDVIEW_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_PROTOCOLDESCRIPTION_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_FONTINSPECTOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_FONTINSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_FONTINSPECTOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_LAYOUTVIEW_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_LAYOUTVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_LAYOUTVIEW_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,3,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); } diff --git a/browser/devtools/shared/test/browser_telemetry_toolbox.js b/browser/devtools/shared/test/browser_telemetry_toolbox.js index 366f64699ab..fbd7cdfdacb 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolbox.js +++ b/browser/devtools/shared/test/browser_telemetry_toolbox.js @@ -10,11 +10,28 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(3, TOOL_DELAY, "inspector"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,3,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,3,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,3,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_canvasdebugger.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_canvasdebugger.js index c9c07099a59..51ea581c692 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_canvasdebugger.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_canvasdebugger.js @@ -14,14 +14,28 @@ add_task(function*() { Services.prefs.setBoolPref("devtools.canvasdebugger.enabled", true); yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "canvasdebugger"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); info("De-activate the canvasdebugger"); Services.prefs.setBoolPref("devtools.canvasdebugger.enabled", originalPref); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_CANVASDEBUGGER_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_CANVASDEBUGGER_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_CANVASDEBUGGER_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_inspector.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_inspector.js index 61dff980af2..a3ce37a7f1c 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_inspector.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_inspector.js @@ -10,11 +10,28 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "inspector"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_INSPECTOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_RULEVIEW_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsdebugger.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsdebugger.js index a8625518351..bd85128a21a 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsdebugger.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsdebugger.js @@ -10,11 +10,29 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "jsdebugger"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETHREAD_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RESUME_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_SOURCES_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_THREADDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_JSDEBUGGER_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_JSDEBUGGER_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_JSDEBUGGER_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsprofiler.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsprofiler.js index afe2aeb29ea..98b666870de 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsprofiler.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_jsprofiler.js @@ -9,11 +9,25 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "jsprofiler"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_JSPROFILER_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_JSPROFILER_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_JSPROFILER_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_netmonitor.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_netmonitor.js index e7554e5492a..e0ede2069d5 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_netmonitor.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_netmonitor.js @@ -9,12 +9,25 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "netmonitor"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_NETMONITOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_NETMONITOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_NETMONITOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_options.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_options.js index 14256814e49..a437e3fa868 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_options.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_options.js @@ -9,11 +9,25 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "options"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_OPTIONS_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_OPTIONS_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_OPTIONS_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_shadereditor.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_shadereditor.js index 476fbd320d9..0ee1bb16a32 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_shadereditor.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_shadereditor.js @@ -20,14 +20,28 @@ add_task(function*() { Services.prefs.setBoolPref("devtools.shadereditor.enabled", true); yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "shadereditor"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); info("De-activate the sharer editor"); Services.prefs.setBoolPref("devtools.shadereditor.enabled", originalPref); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_SHADEREDITOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_SHADEREDITOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_SHADEREDITOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_storage.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_storage.js index 93348b96df7..081ed993d98 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_storage.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_storage.js @@ -12,14 +12,28 @@ add_task(function*() { Services.prefs.setBoolPref("devtools.storage.enabled", true); yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "storage"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); info("De-activating the storage inspector"); Services.prefs.clearUserPref("devtools.storage.enabled"); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_STORAGE_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_STORAGE_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_STORAGE_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_styleeditor.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_styleeditor.js index 15c4a9c08ac..8a1690a0f87 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_styleeditor.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_styleeditor.js @@ -9,12 +9,25 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "styleeditor"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_STYLEEDITOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_STYLEEDITOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_STYLEEDITOR_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webaudioeditor.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webaudioeditor.js index 033791a7235..a9471641527 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webaudioeditor.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webaudioeditor.js @@ -13,14 +13,28 @@ add_task(function*() { Services.prefs.setBoolPref("devtools.webaudioeditor.enabled", true); yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "webaudioeditor"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); info("De-activating the webaudioeditor"); Services.prefs.setBoolPref("devtools.webaudioeditor.enabled", originalPref); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_WEBAUDIOEDITOR_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_WEBAUDIOEDITOR_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_WEBAUDIOEDITOR_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webconsole.js b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webconsole.js index b989a14269a..2b68fb57f33 100644 --- a/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webconsole.js +++ b/browser/devtools/shared/test/browser_telemetry_toolboxtabs_webconsole.js @@ -9,11 +9,25 @@ const TOOL_DELAY = 200; add_task(function*() { yield promiseTab(TEST_URI); - let Telemetry = loadTelemetryAndRecordLogs(); + + startTelemetry(); yield openAndCloseToolbox(2, TOOL_DELAY, "webconsole"); - checkTelemetryResults(Telemetry); + checkResults(); - stopRecordingTelemetryLogs(Telemetry); gBrowser.removeCurrentTab(); }); + +function checkResults() { + // For help generating these tests use generateTelemetryTests("DEVTOOLS_") + // here. + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_LISTTABS_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_RECONFIGURETAB_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_DEBUGGER_RDP_LOCAL_TABDETACH_MS", null, "hasentries"); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS", null, "hasentries"); + checkTelemetry("DEVTOOLS_WEBCONSOLE_OPENED_BOOLEAN", [0,2,0]); + checkTelemetry("DEVTOOLS_WEBCONSOLE_OPENED_PER_USER_FLAG", [0,1,0]); + checkTelemetry("DEVTOOLS_WEBCONSOLE_TIME_ACTIVE_SECONDS", null, "hasentries"); +} diff --git a/browser/devtools/shared/test/head.js b/browser/devtools/shared/test/head.js index 121f75f6900..32e1912ce1b 100644 --- a/browser/devtools/shared/test/head.js +++ b/browser/devtools/shared/test/head.js @@ -6,11 +6,15 @@ let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}); let {TargetFactory, require} = devtools; let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); let {gDevTools} = Cu.import("resource:///modules/devtools/gDevTools.jsm", {}); +let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); const {DOMHelpers} = Cu.import("resource:///modules/devtools/DOMHelpers.jsm", {}); const {Hosts} = require("devtools/framework/toolbox-hosts"); +let oldCanRecord = Services.telemetry.canRecord; + gDevTools.testing = true; -SimpleTest.registerCleanupFunction(() => { +registerCleanupFunction(() => { + _stopTelemetry(); gDevTools.testing = false; }); @@ -150,75 +154,126 @@ let createHost = Task.async(function*(type = "bottom", src = "data:text/html;cha return [host, iframe.contentWindow, iframe.contentDocument]; }); -/** - * Load the Telemetry utils, then stub Telemetry.prototype.log in order to - * record everything that's logged in it. - * Store all recordings on Telemetry.telemetryInfo. - * @return {Telemetry} - */ -function loadTelemetryAndRecordLogs() { - info("Mock the Telemetry log function to record logged information"); +function reportError(error) { + let stack = " " + error.stack.replace(/\n?.*?@/g, "\n JS frame :: "); - let Telemetry = require("devtools/shared/telemetry"); - Telemetry.prototype.telemetryInfo = {}; - Telemetry.prototype._oldlog = Telemetry.prototype.log; - Telemetry.prototype.log = function(histogramId, value) { - if (!this.telemetryInfo) { - // Can be removed when Bug 992911 lands (see Bug 1011652 Comment 10) - return; - } - if (histogramId) { - if (!this.telemetryInfo[histogramId]) { - this.telemetryInfo[histogramId] = []; - } + ok(false, "ERROR: " + error + " at " + error.fileName + ":" + + error.lineNumber + "\n\nStack trace:" + stack); - this.telemetryInfo[histogramId].push(value); - } - }; + if (finishUp) { + finishUp(); + } +} - return Telemetry; +function startTelemetry() { + Services.telemetry.canRecord = true; } /** - * Stop recording the Telemetry logs and put back the utils as it was before. + * This method is automatically called on teardown. */ -function stopRecordingTelemetryLogs(Telemetry) { - Telemetry.prototype.log = Telemetry.prototype._oldlog; - delete Telemetry.prototype._oldlog; - delete Telemetry.prototype.telemetryInfo; -} +function _stopTelemetry() { + let Telemetry = devtools.require("devtools/shared/telemetry"); + let telemetry = new Telemetry(); -/** - * Check the correctness of the data recorded in Telemetry after - * loadTelemetryAndRecordLogs was called. - */ -function checkTelemetryResults(Telemetry) { - let result = Telemetry.prototype.telemetryInfo; + telemetry.clearToolsOpenedPref(); - for (let [histId, value] of Iterator(result)) { - if (histId.endsWith("OPENED_PER_USER_FLAG")) { - ok(value.length === 1 && value[0] === true, - "Per user value " + histId + " has a single value of true"); - } else if (histId.endsWith("OPENED_BOOLEAN")) { - ok(value.length > 1, histId + " has more than one entry"); + Services.telemetry.canRecord = oldCanRecord; - let okay = value.every(function(element) { - return element === true; - }); - - ok(okay, "All " + histId + " entries are === true"); - } else if (histId.endsWith("TIME_ACTIVE_SECONDS")) { - ok(value.length > 1, histId + " has more than one entry"); - - let okay = value.every(function(element) { - return element > 0; - }); - - ok(okay, "All " + histId + " entries have time > 0"); + // Clean up telemetry histogram changes + for (let histId in Services.telemetry.histogramSnapshots) { + try { + let histogram = Services.telemetry.getHistogramById(histId); + histogram.clear(); + } catch(e) { + // Histograms is not listed in histograms.json, do nothing. } } } +/** + * Check the value of a given telemetry histogram. + * + * @param {String} histId + * Histogram id + * @param {Array|Number} expected + * Expected value + * @param {String} checkType + * "array" (default) - Check that an array matches the histogram data. + * "hasentries" - For non-enumerated linear and exponential + * histograms. This checks for at least one entry. + */ +function checkTelemetry(histId, expected, checkType="array") { + let actual = Services.telemetry.getHistogramById(histId).snapshot().counts; + + switch (checkType) { + case "array": + is(JSON.stringify(actual), JSON.stringify(expected), histId + " correct."); + break; + case "hasentries": + let hasEntry = actual.some(num => num > 0); + ok(hasEntry, histId + " has at least one entry."); + break; + } +} + +/** + * Generate telemetry tests. You should call generateTelemetryTests("DEVTOOLS_") + * from your result checking code in telemetry tests. It logs checkTelemetry + * calls for all changed telemetry values. + * + * @param {String} prefix + * Optionally limits results to histogram ids starting with prefix. + */ +function generateTelemetryTests(prefix="") { + dump("=".repeat(80) + "\n"); + for (let histId in Services.telemetry.histogramSnapshots) { + if (!histId.startsWith(prefix)) { + continue; + } + + let snapshot = Services.telemetry.histogramSnapshots[histId]; + let actual = snapshot.counts; + + switch (snapshot.histogram_type) { + case Services.telemetry.HISTOGRAM_EXPONENTIAL: + case Services.telemetry.HISTOGRAM_LINEAR: + let total = 0; + for (let val of actual) { + total += val; + } + + if (histId.endsWith("_ENUMERATED")) { + if (total > 0) { + dump("checkTelemetry(\"" + histId + "\", " + JSON.stringify(actual) + ");\n"); + } + continue; + } + + dump("checkTelemetry(\"" + histId + "\", null, \"hasentries\");\n"); + break; + case Services.telemetry.HISTOGRAM_BOOLEAN: + actual = JSON.stringify(actual); + + if (actual !== "[0,0,0]") { + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + } + break; + case Services.telemetry.HISTOGRAM_FLAG: + actual = JSON.stringify(actual); + + if (actual !== "[1,0,0]") { + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + } + break; + case Services.telemetry.HISTOGRAM_COUNT: + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + break; + } + } + dump("=".repeat(80) + "\n"); +} + /** * Open and close the toolbox in the current browser tab, several times, waiting * some amount of time in between. @@ -230,7 +285,7 @@ function* openAndCloseToolbox(nbOfTimes, usageTime, toolId) { for (let i = 0; i < nbOfTimes; i ++) { info("Opening toolbox " + (i + 1)); let target = TargetFactory.forTab(gBrowser.selectedTab); - yield gDevTools.showToolbox(target, toolId) + yield gDevTools.showToolbox(target, toolId); // We use a timeout to check the toolbox's active time yield new Promise(resolve => setTimeout(resolve, usageTime)); diff --git a/browser/devtools/storage/ui.js b/browser/devtools/storage/ui.js index 52a0ca12b3d..1e1ee0ce974 100644 --- a/browser/devtools/storage/ui.js +++ b/browser/devtools/storage/ui.js @@ -21,8 +21,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ViewHelpers", XPCOMUtils.defineLazyModuleGetter(this, "VariablesView", "resource:///modules/devtools/VariablesView.jsm"); -let Telemetry = require("devtools/shared/telemetry"); - /** * Localization convenience methods. */ @@ -87,9 +85,6 @@ this.StorageUI = function StorageUI(front, target, panelWin) { this.handleKeypress = this.handleKeypress.bind(this); this._panelDoc.addEventListener("keypress", this.handleKeypress); - - this._telemetry = new Telemetry(); - this._telemetry.toolOpened("storage"); } exports.StorageUI = StorageUI; @@ -102,7 +97,6 @@ StorageUI.prototype = { destroy: function() { this.front.off("stores-update", this.onUpdate); this._panelDoc.removeEventListener("keypress", this.handleKeypress); - this._telemetry.toolClosed("storage"); }, /** diff --git a/browser/devtools/webaudioeditor/controller.js b/browser/devtools/webaudioeditor/controller.js index 2f51b69266a..66c2c77533a 100644 --- a/browser/devtools/webaudioeditor/controller.js +++ b/browser/devtools/webaudioeditor/controller.js @@ -42,7 +42,6 @@ let WebAudioEditorController = { * Listen for events emitted by the current tab target. */ initialize: Task.async(function* () { - telemetry.toolOpened("webaudioeditor"); this._onTabNavigated = this._onTabNavigated.bind(this); this._onThemeChange = this._onThemeChange.bind(this); @@ -69,7 +68,6 @@ let WebAudioEditorController = { * Remove events emitted by the current tab target. */ destroy: function() { - telemetry.toolClosed("webaudioeditor"); gTarget.off("will-navigate", this._onTabNavigated); gTarget.off("navigate", this._onTabNavigated); gFront.off("start-context", this._onStartContext); diff --git a/browser/devtools/webaudioeditor/includes.js b/browser/devtools/webaudioeditor/includes.js index 2e6b8ece4ea..acfbe87278c 100644 --- a/browser/devtools/webaudioeditor/includes.js +++ b/browser/devtools/webaudioeditor/includes.js @@ -19,10 +19,9 @@ let { EventTarget } = require("sdk/event/target"); const { Task } = Cu.import("resource://gre/modules/Task.jsm", {}); const { Class } = require("sdk/core/heritage"); const EventEmitter = require("devtools/toolkit/event-emitter"); -const STRINGS_URI = "chrome://browser/locale/devtools/webaudioeditor.properties" +const STRINGS_URI = "chrome://browser/locale/devtools/webaudioeditor.properties"; const L10N = new ViewHelpers.L10N(STRINGS_URI); -const Telemetry = require("devtools/shared/telemetry"); -const telemetry = new Telemetry(); + devtools.lazyImporter(this, "LineGraphWidget", "resource:///modules/devtools/Graphs.jsm"); diff --git a/browser/devtools/webide/test/head.js b/browser/devtools/webide/test/head.js index 7953a766738..3a565b355e1 100644 --- a/browser/devtools/webide/test/head.js +++ b/browser/devtools/webide/test/head.js @@ -14,6 +14,8 @@ const {require} = devtools; const promise = require("promise"); const {AppProjects} = require("devtools/app-manager/app-projects"); +let oldCanRecord = Services.telemetry.canRecord; + let TEST_BASE; if (window.location === "chrome://browser/content/browser.xul") { TEST_BASE = "chrome://mochitests/content/browser/browser/devtools/webide/test/"; @@ -32,6 +34,8 @@ Services.prefs.setCharPref("devtools.webide.templatesURL", TEST_BASE + "template SimpleTest.registerCleanupFunction(() => { + _stopTelemetry(); + Services.prefs.clearUserPref("devtools.webide.enabled"); Services.prefs.clearUserPref("devtools.webide.enableLocalRuntime"); Services.prefs.clearUserPref("devtools.webide.autoinstallADBHelper"); @@ -207,3 +211,112 @@ function handleError(aError) { ok(false, "Got an error: " + aError.message + "\n" + aError.stack); finish(); } + +function startTelemetry() { + Services.telemetry.canRecord = true; +} + +/** + * This method is automatically called on teardown. + */ +function _stopTelemetry() { + let Telemetry = devtools.require("devtools/shared/telemetry"); + let telemetry = new Telemetry(); + + telemetry.clearToolsOpenedPref(); + + Services.telemetry.canRecord = oldCanRecord; + + // Clean up telemetry histogram changes + for (let histId in Services.telemetry.histogramSnapshots) { + try { + let histogram = Services.telemetry.getHistogramById(histId); + histogram.clear(); + } catch(e) { + // Histograms is not listed in histograms.json, do nothing. + } + } +} + +/** + * Check the value of a given telemetry histogram. + * + * @param {String} histId + * Histogram id + * @param {Array|Number} expected + * Expected value + * @param {String} checkType + * "array" (default) - Check that an array matches the histogram data. + * "hasentries" - For non-enumerated linear and exponential + * histograms. This checks for at least one entry. + */ +function checkTelemetry(histId, expected, checkType="array") { + let actual = Services.telemetry.getHistogramById(histId).snapshot().counts; + + switch (checkType) { + case "array": + is(JSON.stringify(actual), JSON.stringify(expected), histId + " correct."); + break; + case "hasentries": + let hasEntry = actual.some(num => num > 0); + ok(hasEntry, histId + " has at least one entry."); + break; + } +} + +/** + * Generate telemetry tests. You should call generateTelemetryTests("DEVTOOLS_") + * from your result checking code in telemetry tests. It logs checkTelemetry + * calls for all changed telemetry values. + * + * @param {String} prefix + * Optionally limits results to histogram ids starting with prefix. + */ +function generateTelemetryTests(prefix="") { + dump("=".repeat(80) + "\n"); + for (let histId in Services.telemetry.histogramSnapshots) { + if (!histId.startsWith(prefix)) { + continue; + } + + let snapshot = Services.telemetry.histogramSnapshots[histId]; + let actual = snapshot.counts; + + switch (snapshot.histogram_type) { + case Services.telemetry.HISTOGRAM_EXPONENTIAL: + case Services.telemetry.HISTOGRAM_LINEAR: + let total = 0; + for (let val of actual) { + total += val; + } + + if (histId.endsWith("_ENUMERATED")) { + if (total > 0) { + dump("checkTelemetry(\"" + histId + "\", " + JSON.stringify(actual) + ");\n"); + } + continue; + } + + dump("checkTelemetry(\"" + histId + "\", null, \"hasentries\");\n"); + break; + case Services.telemetry.HISTOGRAM_BOOLEAN: + actual = JSON.stringify(actual); + + if (actual !== "[0,0,0]") { + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + } + break; + case Services.telemetry.HISTOGRAM_FLAG: + actual = JSON.stringify(actual); + + if (actual !== "[1,0,0]") { + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + } + break; + case Services.telemetry.HISTOGRAM_COUNT: + dump("checkTelemetry(\"" + histId + "\", " + actual + ");\n"); + break; + } + } + dump("=".repeat(80) + "\n"); +} diff --git a/browser/devtools/webide/test/test_telemetry.html b/browser/devtools/webide/test/test_telemetry.html index 163fd67a344..42f9449fb67 100644 --- a/browser/devtools/webide/test/test_telemetry.html +++ b/browser/devtools/webide/test/test_telemetry.html @@ -15,7 +15,6 @@