Bug 1380377 part 1 - Calculate FX_NEW_WINDOW_MS using MozAfterPaint. r?florian
MozReview-Commit-ID: KQ6aSkw423P
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4176,38 +4176,16 @@ function toOpenWindowByType(inType, uri,
else
window.open(uri, "_blank", "chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
}
function OpenBrowserWindow(options) {
var telemetryObj = {};
TelemetryStopwatch.start("FX_NEW_WINDOW_MS", telemetryObj);
- function newDocumentShown(doc, topic, data) {
- if (topic == "document-shown" &&
- doc != document &&
- doc.defaultView == win) {
- Services.obs.removeObserver(newDocumentShown, "document-shown");
- Services.obs.removeObserver(windowClosed, "domwindowclosed");
- TelemetryStopwatch.finish("FX_NEW_WINDOW_MS", telemetryObj);
- }
- }
-
- function windowClosed(subject) {
- if (subject == win) {
- Services.obs.removeObserver(newDocumentShown, "document-shown");
- Services.obs.removeObserver(windowClosed, "domwindowclosed");
- }
- }
-
- // Make sure to remove the 'document-shown' observer in case the window
- // is being closed right after it was opened to avoid leaking.
- Services.obs.addObserver(newDocumentShown, "document-shown");
- Services.obs.addObserver(windowClosed, "domwindowclosed");
-
var handler = Components.classes["@mozilla.org/browser/clh;1"]
.getService(Components.interfaces.nsIBrowserHandler);
var defaultArgs = handler.defaultArgs;
var wintype = document.documentElement.getAttribute("windowtype");
var extraFeatures = "";
if (options && options.private) {
extraFeatures = ",private";
@@ -4242,16 +4220,20 @@ function OpenBrowserWindow(options) {
// we should "inherit" the charset menu setting in a new window
win = window.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no" + extraFeatures, defaultArgs, charsetArg);
} else {
// forget about the charset information.
win = window.openDialog("chrome://browser/content/", "_blank", "chrome,all,dialog=no" + extraFeatures, defaultArgs);
}
+ win.addEventListener("MozAfterPaint", () => {
+ TelemetryStopwatch.finish("FX_NEW_WINDOW_MS", telemetryObj);
+ }, {once: true});
+
return win;
}
/**
* Update the global flag that tracks whether or not any edit UI (the Edit menu,
* edit-related items in the context menu, and edit-related toolbar buttons
* is visible, then update the edit commands' enabled state accordingly. We use
* this flag to skip updating the edit commands on focus or selection changes