From dcff7dfbbde0a38daed74634d1dd9574f3eb37d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Fri, 8 Feb 2013 13:15:46 +0100 Subject: [PATCH] Bug 825804 - Popup notifications and notification bars shouldn't persist across page reloads. r=gavin --- browser/base/content/browser.js | 54 ++++++++++++--------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 233f18c5d49..0865cb9833a 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -4196,7 +4196,6 @@ var XULBrowserWindow = { }, onLocationChange: function (aWebProgress, aRequest, aLocationURI, aFlags) { - const nsIWebProgressListener = Ci.nsIWebProgressListener; var location = aLocationURI ? aLocationURI.spec : ""; this._hostChanged = true; @@ -4225,38 +4224,6 @@ var XULBrowserWindow = { } } - // This code here does not compare uris exactly when determining - // whether or not the message should be hidden since the message - // may be prematurely hidden when an install is invoked by a click - // on a link that looks like this: - // - // Install Foo - // - // - which fires a onLocationChange message to uri + '#'... - var selectedBrowser = gBrowser.selectedBrowser; - if (selectedBrowser.lastURI) { - let oldSpec = selectedBrowser.lastURI.spec; - let oldIndexOfHash = oldSpec.indexOf("#"); - if (oldIndexOfHash != -1) - oldSpec = oldSpec.substr(0, oldIndexOfHash); - let newSpec = location; - let newIndexOfHash = newSpec.indexOf("#"); - if (newIndexOfHash != -1) - newSpec = newSpec.substr(0, newIndexOfHash); - if (newSpec != oldSpec) { - // Remove all the notifications, except for those which want to - // persist across the first location change. - let nBox = gBrowser.getNotificationBox(selectedBrowser); - nBox.removeTransientNotifications(); - - // Only need to call locationChange if the PopupNotifications object - // for this window has already been initialized (i.e. its getter no - // longer exists) - if (!__lookupGetter__("PopupNotifications")) - PopupNotifications.locationChange(); - } - } - // Disable menu entries for images, enable otherwise if (content.document && mimeTypeIsTextBased(content.document.contentType)) this.isImage.removeAttribute('disabled'); @@ -4290,6 +4257,18 @@ var XULBrowserWindow = { SocialShareButton.updateShareState(); } + // Filter out anchor navigation, history.push/pop/replaceState and + // tab switches. + if (aRequest) { + // Only need to call locationChange if the PopupNotifications object + // for this window has already been initialized (i.e. its getter no + // longer exists) + // XXX bug 839445: We never tell PopupNotifications about location + // changes in background tabs. + if (!__lookupGetter__("PopupNotifications")) + PopupNotifications.locationChange(); + } + // Show or hide browser chrome based on the whitelist if (this.hideChromeForLocation(location)) { document.documentElement.setAttribute("disablechrome", "true"); @@ -4332,7 +4311,7 @@ var XULBrowserWindow = { (aLocationURI.schemeIs("about") || aLocationURI.schemeIs("chrome"))) { // Don't need to re-enable/disable find commands for same-document location changes // (e.g. the replaceStates in about:addons) - if (!(aFlags & nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT)) { + if (!(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT)) { if (content.document.readyState == "interactive" || content.document.readyState == "complete") disableFindCommands(shouldDisableFind(content.document)); else { @@ -4708,12 +4687,17 @@ var TabsProgressListener = { if (aBrowser.contentWindow == aWebProgress.DOMWindow) { // Filter out any onLocationChanges triggered by anchor navigation // or history.push/pop/replaceState. - if (aRequest) { + if (!(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT)) { // Initialize the click-to-play state. aBrowser._clickToPlayPluginsActivated = new Map(); aBrowser._clickToPlayAllPluginsActivated = false; aBrowser._pluginScriptedState = gPluginHandler.PLUGIN_SCRIPTED_STATE_NONE; + + // Remove all the notifications, except for those which want to + // persist across the first location change. + gBrowser.getNotificationBox(aBrowser).removeTransientNotifications(); } + FullZoom.onLocationChange(aLocationURI, false, aBrowser); } },