diff --git a/browser/base/content/browser-fxaccounts.js b/browser/base/content/browser-fxaccounts.js index 76d15dbbe4c..f3bfb4dc7b3 100644 --- a/browser/base/content/browser-fxaccounts.js +++ b/browser/base/content/browser-fxaccounts.js @@ -21,6 +21,7 @@ let gFxAccounts = { }, get topics() { + // Do all this dance to lazy-load FxAccountsCommon. delete this.topics; return this.topics = [ "weave:service:sync:start", @@ -31,6 +32,16 @@ let gFxAccounts = { ]; }, + // The set of topics that only the active window should handle. + get activeWindowTopics() { + // Do all this dance to lazy-load FxAccountsCommon. + delete this.activeWindowTopics; + return this.activeWindowTopics = new Set([ + "weave:service:sync:start", + FxAccountsCommon.ONVERIFIED_NOTIFICATION + ]); + }, + get button() { delete this.button; return this.button = document.getElementById("PanelUI-fxa-status"); @@ -44,8 +55,15 @@ let gFxAccounts = { Weave.Status.login != Weave.LOGIN_SUCCEEDED; }, + get isActiveWindow() { + let mostRecentNonPopupWindow = + RecentWindow.getMostRecentBrowserWindow({allowPopups: false}); + return window == mostRecentNonPopupWindow; + }, + init: function () { - if (this._initialized) { + // Bail out if we're already initialized and for pop-up windows. + if (this._initialized || !window.toolbar.visible) { return; } @@ -74,6 +92,11 @@ let gFxAccounts = { }, observe: function (subject, topic) { + // Ignore certain topics if we're not the active window. + if (this.activeWindowTopics.has(topic) && !this.isActiveWindow) { + return; + } + switch (topic) { case FxAccountsCommon.ONVERIFIED_NOTIFICATION: Services.prefs.setBoolPref(PREF_SYNC_START_DOORHANGER, true);