Bug 1531838 - Ensure we don't set up twice on any window. r=johannh
authorNihanth Subramanya <nhnt11@gmail.com>
Sun, 14 Apr 2019 17:49:57 +0000
changeset 469655 2058918f63f0
parent 469654 d6e09cefb3c7
child 469656 ce0b0350b646
push id35878
push userapavel@mozilla.com
push dateTue, 16 Apr 2019 15:43:40 +0000
treeherdermozilla-central@258af4e91151 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1531838
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531838 - Ensure we don't set up twice on any window. r=johannh Differential Revision: https://phabricator.services.mozilla.com/D26701
browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
--- a/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
+++ b/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
@@ -236,23 +236,28 @@ this.FirefoxMonitor = {
       return;
     }
 
     await this.delayedInit();
 
     EveryWindow.registerCallback(
       this.kNotificationID,
       (win) => {
+        if (this.notificationsByWindow.has(win)) {
+          // We've already set up this window.
+          return;
+        }
+
+        this.notificationsByWindow.set(win, new Set());
+
         // Inject our stylesheet.
         let DOMWindowUtils = win.windowUtils;
         DOMWindowUtils.loadSheetUsingURIString(this.getURL("privileged/FirefoxMonitor.css"),
                                                DOMWindowUtils.AUTHOR_SHEET);
 
-        this.notificationsByWindow.set(win, new Set());
-
         // Setup the popup notification stuff. First, the URL bar icon:
         let doc = win.document;
         let notificationBox = doc.getElementById("notification-popup-box");
         // We create a box to use as the anchor, and put an icon image
         // inside it. This way, when we animate the icon, its scale change
         // does not cause the popup notification to bounce due to the anchor
         // point moving.
         let anchorBox = doc.createElementNS(XUL_NS, "box");