Bug 1456923 - can't switch to dev-tools add-on that is loaded temporarily r=pbro

MozReview-Commit-ID: EOw2S34zqPa

--HG--
extra : rebase_source : 36b99bb0f70b64b31d9b1c552c5b680a7972abcd
This commit is contained in:
Michael Ratcliffe 2018-04-30 15:57:39 +01:00
Родитель ed54beeab0
Коммит d01c919943
3 изменённых файлов: 37 добавлений и 15 удалений

Просмотреть файл

@ -242,7 +242,8 @@ add_task(async function test_devtools_page_panels_create() {
browser.devtools.inspectedWindow.tabId);
}
const EXTENSION_ID = "@create-devtools-panel.test";
const longPrefix = (new Array(80)).fill("x").join("");
const EXTENSION_ID = `${longPrefix}@create-devtools-panel.test`;
let extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",

Просмотреть файл

@ -1888,7 +1888,7 @@ Toolbox.prototype = {
"host": this._hostType,
"width": width,
"start_state": reason,
"panel_name": id,
"panel_name": panelName,
"cold": cold
});
@ -1899,7 +1899,7 @@ Toolbox.prototype = {
"host": this._hostType,
"width": width,
"panel_name": prevPanelName,
"next_panel": id,
"next_panel": panelName,
"reason": reason
});
}
@ -2850,7 +2850,7 @@ Toolbox.prototype = {
this._telemetry.recordEvent("devtools.main", "exit", prevPanelName, null, {
"host": host,
"width": width,
"panel_name": this.currentToolId,
"panel_name": this.getTelemetryPanelName(this.currentToolId),
"next_panel": "none",
"reason": "toolbox_close"
});

Просмотреть файл

@ -11,6 +11,7 @@
"use strict";
const Services = require("Services");
const { getNthPathExcluding } = require("devtools/shared/platform/stack");
const TOOLS_OPENED_PREF = "devtools.telemetry.tools.opened.version";
// Object to be shared among all instances.
@ -295,7 +296,8 @@ class Telemetry {
histogram.add(value);
} catch (e) {
dump(`Warning: An attempt was made to write to the ${histogramId} ` +
`histogram, which is not defined in Histograms.json\n`);
`histogram, which is not defined in Histograms.json\n` +
`CALLER: ${this.getCaller()}`);
}
}
@ -316,14 +318,16 @@ class Telemetry {
if (isNaN(value) && typeof value !== "boolean") {
dump(`Warning: An attempt was made to write a non-numeric and ` +
`non-boolean value ${value} to the ${scalarId} scalar. Only ` +
`numeric and boolean values are allowed.\n`);
`numeric and boolean values are allowed.\n` +
`CALLER: ${this.getCaller()}`);
return;
}
Services.telemetry.scalarSet(scalarId, value);
} catch (e) {
dump(`Warning: An attempt was made to write to the ${scalarId} ` +
`scalar, which is not defined in Scalars.yaml\n`);
`scalar, which is not defined in Scalars.yaml\n` +
`CALLER: ${this.getCaller()}`);
}
}
@ -344,14 +348,16 @@ class Telemetry {
if (isNaN(value)) {
dump(`Warning: An attempt was made to write a non-numeric value ` +
`${value} to the ${scalarId} scalar. Only numeric values are ` +
`allowed.\n`);
`allowed.\n` +
`CALLER: ${this.getCaller()}`);
return;
}
Services.telemetry.scalarAdd(scalarId, value);
} catch (e) {
dump(`Warning: An attempt was made to write to the ${scalarId} ` +
`scalar, which is not defined in Scalars.yaml\n`);
`scalar, which is not defined in Scalars.yaml\n` +
`CALLER: ${this.getCaller()}`);
}
}
@ -374,14 +380,16 @@ class Telemetry {
if (isNaN(value)) {
dump(`Warning: An attempt was made to write a non-numeric value ` +
`${value} to the ${scalarId} scalar. Only numeric values are ` +
`allowed.\n`);
`allowed.\n` +
`CALLER: ${this.getCaller()}`);
return;
}
Services.telemetry.keyedScalarAdd(scalarId, key, value);
} catch (e) {
dump(`Warning: An attempt was made to write to the ${scalarId} ` +
`scalar, which is not defined in Scalars.yaml\n`);
`scalar, which is not defined in Scalars.yaml\n` +
`CALLER: ${this.getCaller()}`);
}
}
@ -407,7 +415,8 @@ class Telemetry {
}
} catch (e) {
dump(`Warning: An attempt was made to write to the ${histogramId} ` +
`histogram, which is not defined in Histograms.json\n`);
`histogram, which is not defined in Histograms.json\n` +
`CALLER: ${this.getCaller()}`);
}
}
}
@ -483,7 +492,8 @@ class Telemetry {
if (expected.length === 0) {
throw new Error(`preparePendingEvent() was called without any expected ` +
`properties.`);
`properties.\n` +
`CALLER: ${this.getCaller()}`);
}
PENDING_EVENTS.set(sig, {
@ -552,7 +562,8 @@ class Telemetry {
// The property was not expected, warn and bail.
throw new Error(`An attempt was made to add the unexpected property ` +
`"${pendingPropName}" to a telemetry event with the ` +
`signature "${sig}"\n`);
`signature "${sig}"\n` +
`CALLER: ${this.getCaller()}`);
}
}
@ -618,7 +629,8 @@ class Telemetry {
throw new Error(`The property "${name}" was added to a telemetry ` +
`event with the signature ${sig} but it's value ` +
`"${val}" is longer than the maximum allowed length ` +
`of 80 characters\n`);
`of 80 characters\n` +
`CALLER: ${this.getCaller()}`);
}
}
Services.telemetry.recordEvent(category, method, object, value, extra);
@ -651,6 +663,15 @@ class Telemetry {
this.recordEvent(category, method, object, value, extra);
}
/**
* Displays the first caller and calling line outside of this file in the
* event of an error. This is the line that made the call that produced the
* error.
*/
getCaller() {
return getNthPathExcluding(0, "/telemetry.js");
}
destroy() {
for (let histogramId of this._timers.keys()) {
this.stopTimer(histogramId);