Bug 1376888 - pageAction popup telemetry does not report the correct times, r?kmag draft
authorBob Silverberg <bsilverberg@mozilla.com>
Wed, 28 Jun 2017 13:28:15 -0700
changeset 601510 9e1c9f8aa91cdf430c17a51a7bb54d149f4e61d5
parent 600708 dc2c2029bed52131916d1c1577ca8c3a7c7bfa32
child 635280 fb5c9844361942238ee1506cad888bfae3757de0
push id66084
push userbmo:bob.silverberg@gmail.com
push dateWed, 28 Jun 2017 21:05:40 +0000
reviewerskmag
bugs1376888
milestone56.0a1
Bug 1376888 - pageAction popup telemetry does not report the correct times, r?kmag Move the call to TelemetryStopwatch.finish to after the contentReady promise of the PanelPopup resolves. MozReview-Commit-ID: F1hfaDHVuJi
browser/components/extensions/ext-pageAction.js
--- a/browser/components/extensions/ext-pageAction.js
+++ b/browser/components/extensions/ext-pageAction.js
@@ -227,30 +227,31 @@ this.pageAction = class extends Extensio
     }
   }
 
   // Handles a click event on the page action button for the given
   // window.
   // If the page action has a |popup| property, a panel is opened to
   // that URL. Otherwise, a "click" event is emitted, and dispatched to
   // the any click listeners in the add-on.
-  handleClick(window) {
+  async handleClick(window) {
     TelemetryStopwatch.start(popupOpenTimingHistogram, this);
     let tab = window.gBrowser.selectedTab;
     let popupURL = this.tabContext.get(tab).popup;
 
     this.tabManager.addActiveTabPermission(tab);
 
     // If the widget has a popup URL defined, we open a popup, but do not
     // dispatch a click event to the extension.
     // If it has no popup URL defined, we dispatch a click event, but do not
     // open a popup.
     if (popupURL) {
-      new PanelPopup(this.extension, this.getButton(window), popupURL,
-                     this.browserStyle);
+      let popup = new PanelPopup(this.extension, this.getButton(window),
+                                 popupURL, this.browserStyle);
+      await popup.contentReady;
       TelemetryStopwatch.finish(popupOpenTimingHistogram, this);
     } else {
       TelemetryStopwatch.cancel(popupOpenTimingHistogram, this);
       this.emit("click", tab);
     }
   }
 
   handleLocationChange(eventType, tab, fromBrowse) {