From f9333ecf69d26777ea04f047957b7356d23cd73e Mon Sep 17 00:00:00 2001 From: "gavin%gavinsharp.com" Date: Mon, 6 Nov 2006 23:41:31 +0000 Subject: [PATCH] Bug 264663: don't re-open closed popup-blocked notifications when switching tabs, r=mano --- browser/base/content/browser.js | 25 +++++++++++++++++++------ toolkit/content/widgets/browser.xml | 1 + 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 9c07b920476e..c6317125be9f 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -386,8 +386,19 @@ const gPopupBlockerObserver = { if (!this._reportButton) this._reportButton = document.getElementById("page-report-button"); - if (gBrowser.selectedBrowser.pageReport) { - this._reportButton.setAttribute("blocked", "true"); + if (!gBrowser.pageReport) { + // Hide the popup blocker statusbar button + this._reportButton.removeAttribute("blocked"); + + return; + } + + this._reportButton.setAttribute("blocked", true); + + // Only show the notification again if we've not already shown it. Since + // notifications are per-browser, we don't need to worry about re-adding + // it. + if (!gBrowser.pageReport.reported) { if (!gPrefService) gPrefService = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch); @@ -396,7 +407,7 @@ const gPopupBlockerObserver = { var brandBundle = document.getElementById("bundle_brand"); var brandShortName = brandBundle.getString("brandShortName"); var message; - var popupCount = gBrowser.selectedBrowser.pageReport.length; + var popupCount = gBrowser.pageReport.length; #ifdef XP_WIN var popupButtonText = bundle_browser.getString("popupWarningButton"); var popupButtonAccesskey = bundle_browser.getString("popupWarningButton.accesskey"); @@ -428,9 +439,11 @@ const gPopupBlockerObserver = { priority, buttons); } } + + // Record the fact that we've reported this blocked popup, so we don't + // show it again. + gBrowser.pageReport.reported = true; } - else - this._reportButton.removeAttribute("blocked"); }, toggleAllowPopupsForSite: function (aEvent) @@ -490,7 +503,7 @@ const gPopupBlockerObserver = { } var foundUsablePopupURI = false; - var pageReport = gBrowser.selectedBrowser.pageReport; + var pageReport = gBrowser.pageReport; if (pageReport) { for (var i = 0; i < pageReport.length; ++i) { var popupURIspec = pageReport[i].popupWindowURI.spec; diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml index 08a9a7f3a445..51da53d68059 100644 --- a/toolkit/content/widgets/browser.xml +++ b/toolkit/content/widgets/browser.xml @@ -501,6 +501,7 @@ popupWindowName: evt.popupWindowName }; #endif this.pageReport.push(obj); + this.pageReport.reported = false; this.updatePageReport() ]]>