зеркало из https://github.com/mozilla/gecko-dev.git
Bug 974171 - Add DEVTOOLS_TOOLBOX_* flags. r=jwalker
This commit is contained in:
Родитель
8e6e7511a7
Коммит
b2027a666b
|
@ -1223,6 +1223,7 @@ Toolbox.prototype = {
|
||||||
if (this.target.isLocalTab) {
|
if (this.target.isLocalTab) {
|
||||||
this._requisition.destroy();
|
this._requisition.destroy();
|
||||||
}
|
}
|
||||||
|
this._telemetry.toolClosed("toolbox");
|
||||||
this._telemetry.destroy();
|
this._telemetry.destroy();
|
||||||
|
|
||||||
return this._destroyer = promise.all(outstanding).then(() => {
|
return this._destroyer = promise.all(outstanding).then(() => {
|
||||||
|
|
|
@ -61,6 +61,8 @@ let {XPCOMUtils} = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
|
||||||
Telemetry.prototype = {
|
Telemetry.prototype = {
|
||||||
_histograms: {
|
_histograms: {
|
||||||
toolbox: {
|
toolbox: {
|
||||||
|
histogram: "DEVTOOLS_TOOLBOX_OPENED_BOOLEAN",
|
||||||
|
userHistogram: "DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG",
|
||||||
timerHistogram: "DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS"
|
timerHistogram: "DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS"
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
@ -212,8 +214,6 @@ Telemetry.prototype = {
|
||||||
*/
|
*/
|
||||||
log: function(histogramId, value) {
|
log: function(histogramId, value) {
|
||||||
if (histogramId) {
|
if (histogramId) {
|
||||||
let histogram;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let histogram = Services.telemetry.getHistogramById(histogramId);
|
let histogram = Services.telemetry.getHistogramById(histogramId);
|
||||||
histogram.add(value);
|
histogram.add(value);
|
||||||
|
|
|
@ -20,6 +20,7 @@ support-files =
|
||||||
[browser_telemetry_button_scratchpad.js]
|
[browser_telemetry_button_scratchpad.js]
|
||||||
[browser_telemetry_button_tilt.js]
|
[browser_telemetry_button_tilt.js]
|
||||||
[browser_telemetry_sidebar.js]
|
[browser_telemetry_sidebar.js]
|
||||||
|
[browser_telemetry_toolbox.js]
|
||||||
[browser_telemetry_toolboxtabs_inspector.js]
|
[browser_telemetry_toolboxtabs_inspector.js]
|
||||||
[browser_telemetry_toolboxtabs_jsdebugger.js]
|
[browser_telemetry_toolboxtabs_jsdebugger.js]
|
||||||
[browser_telemetry_toolboxtabs_jsprofiler.js]
|
[browser_telemetry_toolboxtabs_jsprofiler.js]
|
||||||
|
|
|
@ -73,6 +73,8 @@ function checkResults() {
|
||||||
if (histId.endsWith("OPENED_PER_USER_FLAG")) {
|
if (histId.endsWith("OPENED_PER_USER_FLAG")) {
|
||||||
ok(value.length === 1 && value[0] === true,
|
ok(value.length === 1 && value[0] === true,
|
||||||
"Per user value " + histId + " has a single value of 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")) {
|
} else if (histId.endsWith("OPENED_BOOLEAN")) {
|
||||||
ok(value.length > 1, histId + " has more than one entry");
|
ok(value.length > 1, histId + " has more than one entry");
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,103 @@
|
||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
const TEST_URI = "data:text/html;charset=utf-8,<p>browser_telemetry_toolbox.js</p>";
|
||||||
|
|
||||||
|
// Because we need to gather stats for the period of time that a tool has been
|
||||||
|
// opened we make use of setTimeout() to create tool active times.
|
||||||
|
const TOOL_DELAY = 200;
|
||||||
|
|
||||||
|
let {Promise: promise} = Cu.import("resource://gre/modules/commonjs/sdk/core/promise.js", {});
|
||||||
|
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||||
|
|
||||||
|
let require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
|
||||||
|
let Telemetry = require("devtools/shared/telemetry");
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
Telemetry.prototype.telemetryInfo = {};
|
||||||
|
Telemetry.prototype._oldlog = Telemetry.prototype.log;
|
||||||
|
Telemetry.prototype.log = function(histogramId, value) {
|
||||||
|
if (histogramId) {
|
||||||
|
if (!this.telemetryInfo[histogramId]) {
|
||||||
|
this.telemetryInfo[histogramId] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.telemetryInfo[histogramId].push(value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
openToolboxThreeTimes();
|
||||||
|
}
|
||||||
|
|
||||||
|
let pass = 0;
|
||||||
|
function openToolboxThreeTimes() {
|
||||||
|
let target = TargetFactory.forTab(gBrowser.selectedTab);
|
||||||
|
|
||||||
|
gDevTools.showToolbox(target, "inspector").then(function(toolbox) {
|
||||||
|
info("Toolbox opened");
|
||||||
|
|
||||||
|
toolbox.once("destroyed", function() {
|
||||||
|
if (pass++ === 3) {
|
||||||
|
checkResults();
|
||||||
|
} else {
|
||||||
|
openToolboxThreeTimes();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// We use a timeout to check the toolbox's active time
|
||||||
|
setTimeout(function() {
|
||||||
|
gDevTools.closeToolbox(target);
|
||||||
|
}, TOOL_DELAY);
|
||||||
|
}).then(null, console.error);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkResults() {
|
||||||
|
let result = Telemetry.prototype.telemetryInfo;
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
finishUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
function finishUp() {
|
||||||
|
gBrowser.removeCurrentTab();
|
||||||
|
|
||||||
|
Telemetry.prototype.log = Telemetry.prototype._oldlog;
|
||||||
|
delete Telemetry.prototype._oldlog;
|
||||||
|
delete Telemetry.prototype.telemetryInfo;
|
||||||
|
|
||||||
|
TargetFactory = Services = promise = require = null;
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
function test() {
|
||||||
|
waitForExplicitFinish();
|
||||||
|
gBrowser.selectedTab = gBrowser.addTab();
|
||||||
|
gBrowser.selectedBrowser.addEventListener("load", function() {
|
||||||
|
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
|
||||||
|
waitForFocus(init, content);
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
content.location = TEST_URI;
|
||||||
|
}
|
|
@ -5392,6 +5392,11 @@
|
||||||
"n_buckets": "1000",
|
"n_buckets": "1000",
|
||||||
"description": "The time (in milliseconds) that it took an 'assign' request to go round trip."
|
"description": "The time (in milliseconds) that it took an 'assign' request to go round trip."
|
||||||
},
|
},
|
||||||
|
"DEVTOOLS_TOOLBOX_OPENED_BOOLEAN": {
|
||||||
|
"expires_in_version": "never",
|
||||||
|
"kind": "boolean",
|
||||||
|
"description": "How many times has the devtool's toolbox been opened?"
|
||||||
|
},
|
||||||
"DEVTOOLS_OPTIONS_OPENED_BOOLEAN": {
|
"DEVTOOLS_OPTIONS_OPENED_BOOLEAN": {
|
||||||
"expires_in_version": "never",
|
"expires_in_version": "never",
|
||||||
"kind": "boolean",
|
"kind": "boolean",
|
||||||
|
@ -5492,6 +5497,11 @@
|
||||||
"kind": "boolean",
|
"kind": "boolean",
|
||||||
"description": "How many times has a custom developer tool been opened via the toolbox button?"
|
"description": "How many times has a custom developer tool been opened via the toolbox button?"
|
||||||
},
|
},
|
||||||
|
"DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG": {
|
||||||
|
"expires_in_version": "never",
|
||||||
|
"kind": "flag",
|
||||||
|
"description": "How many times has the devtool's toolbox been opened?"
|
||||||
|
},
|
||||||
"DEVTOOLS_OPTIONS_OPENED_PER_USER_FLAG": {
|
"DEVTOOLS_OPTIONS_OPENED_PER_USER_FLAG": {
|
||||||
"expires_in_version": "never",
|
"expires_in_version": "never",
|
||||||
"kind": "flag",
|
"kind": "flag",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче