Bug 1405585 - Add telemetry to track console refresh time when reload a page. r=nchevobbe
MozReview-Commit-ID: 8zZyq9suJWB
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1984,18 +1984,18 @@ Toolbox.prototype = {
});
},
/**
* Fired when user just started navigating away to another web page.
*/
async _onWillNavigate() {
let toolId = this.currentToolId;
- // For now, only inspector fires "reloaded" event
- if (toolId != "inspector") {
+ // For now, only inspector and webconsole fires "reloaded" event
+ if (toolId != "inspector" && toolId != "webconsole") {
return;
}
let start = this.win.performance.now();
let panel = this.getPanel(toolId);
// Ignore the timing if the panel is still loading
if (!panel) {
return;
--- a/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
+++ b/devtools/client/webconsole/new-console-output/new-console-output-wrapper.js
@@ -298,16 +298,20 @@ NewConsoleOutputWrapper.prototype = {
// the backend has been received. This is based on
// 'FirefoxDataProvider.isQueuePayloadReady', see more
// comments in that method.
// (netmonitor/src/connector/firefox-data-provider).
// This event might be utilized in tests to find the right
// time when to finish.
this.jsterm.hud.emit("network-request-payload-ready");
}
+ if (this.throttleCallback) {
+ this.throttleCallback();
+ delete this.throttleCallback;
+ }
}, 50);
},
// Should be used for test purpose only.
getStore: function () {
return store;
}
};
--- a/devtools/client/webconsole/new-webconsole.js
+++ b/devtools/client/webconsole/new-webconsole.js
@@ -303,32 +303,56 @@ NewWebConsoleFrame.prototype = {
*
* @param string event
* Event name.
* @param object packet
* Notification packet received from the server.
*/
handleTabNavigated: function (event, packet) {
if (event == "will-navigate") {
+ this._navigationStart = this.window.performance.now();
if (this.persistLog) {
// Add a _type to hit convertCachedPacket.
packet._type = true;
this.newConsoleOutput.dispatchMessageAdd(packet);
} else {
this.clearOutput(false);
}
}
if (packet.url) {
this.onLocationChange(packet.url, packet.title);
}
if (event == "navigate" && !packet.nativeConsoleAPI) {
this.logWarningAboutReplacedAPI();
}
+
+ if (event == "navigate") {
+ let timeout = this.newConsoleOutput.throttledDispatchTimeout;
+ if (timeout) {
+ this.newConsoleOutput.throttleCallback = () => {
+ let delay = this.window.performance.now() - this._navigationStart;
+
+ // TODO - REMOVE DEBUG CODE
+ let window = this.window;
+ let canvas = window.document.createElementNS("http://www.w3.org/1999/xhtml", "html:canvas");
+ let context = canvas.getContext("2d");
+ canvas.width = window.innerWidth;
+ canvas.height = window.innerHeight;
+ context.drawWindow(window, 0, 0, canvas.width, canvas.height, "rgb(255, 255, 255)");
+ dump(">> "+canvas.toDataURL()+"\n");
+ // TODO - REMOVE DEBUG CODE
+
+ this.emit("reloaded");
+ };
+ } else {
+ this.emit("reloaded");
+ }
+ }
},
clearOutput(clearStorage) {
this.newConsoleOutput.dispatchMessagesClear();
this.webConsoleClient.clearNetworkRequests();
if (clearStorage) {
this.webConsoleClient.clearMessagesCache();
}
--- a/devtools/client/webconsole/panel.js
+++ b/devtools/client/webconsole/panel.js
@@ -76,16 +76,21 @@ WebConsolePanel.prototype = {
let webConsoleUIWindow = iframe.contentWindow.wrappedJSObject;
let chromeWindow = iframe.ownerDocument.defaultView;
return HUDService.openWebConsole(this.target, webConsoleUIWindow,
chromeWindow);
})
.then((webConsole) => {
this.hud = webConsole;
+ // Pipe 'reloaded' event from NewWebConsoleFrame to WebConsolePanel.
+ // These events are listened by the Toolbox.
+ this.hud.ui.on("reloaded", () => {
+ this.emit("reloaded");
+ });
this._isReady = true;
this.emit("ready");
return this;
}, (reason) => {
let msg = "WebConsolePanel open failed. " +
reason.error + ": " + reason.message;
dump(msg + "\n");
console.error(msg, reason);