Bug 1246291 - Don't clear transient notifications if a refresh was blocked early. r?Mossop draft
authorMike Conley <mconley@mozilla.com>
Fri, 12 Feb 2016 17:53:35 -0500
changeset 330774 d43f3659038022eebb0abcba51410a6b9f14f9cb
parent 330773 2be6fc4c4600b21696ed3f9633cbc1f73d2e9174
child 514244 bc1d961b4b8c389109ae46aeb5585cba664d70ba
push id10832
push usermconley@mozilla.com
push dateFri, 12 Feb 2016 23:01:53 +0000
reviewersMossop
bugs1246291
milestone47.0a1
Bug 1246291 - Don't clear transient notifications if a refresh was blocked early. r?Mossop A refresh can occur when reading a "refresh" key from the HTTP response headers, which will result in onRefreshAttempted firing before onLocationChange. If, however, a refresh is caused by a meta tag, this will fire after onLocationChange. We can now detect the former with a refreshWasBlocked property on the nsIWebProgress, so that the onLocationChange handler in browser.js can filter out the HTTP header cases, where onRefreshAttempted is fired earlier. MozReview-Commit-ID: DWt7qAvYwoh
browser/base/content/browser.js
toolkit/content/browser-child.js
toolkit/modules/RemoteWebProgress.jsm
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -4684,16 +4684,21 @@ var TabsProgressListener = {
       mm.sendAsyncMessage("Reader:PushState", {isArticle: gBrowser.selectedBrowser.isArticle});
       return;
     }
 
     // Filter out location changes in sub documents.
     if (!aWebProgress.isTopLevel)
       return;
 
+    // Filter out location changes that occur after a refresh was blocked;
+    // this might occur due to a refresh triggered from the HTTP header.
+    if (aWebProgress.refreshWasBlocked)
+      return;
+
     // Only need to call locationChange if the PopupNotifications object
     // for this window has already been initialized (i.e. its getter no
     // longer exists)
     if (!Object.getOwnPropertyDescriptor(window, "PopupNotifications").get)
       PopupNotifications.locationChange(aBrowser);
 
     gBrowser.getNotificationBox(aBrowser).removeTransientNotifications();
 
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -69,17 +69,18 @@ var WebProgressListener = {
         // If there is no current inner window, we'll get
         // NS_ERROR_NOT_AVAILABLE.
       }
 
       aWebProgress = {
         isTopLevel: aWebProgress.isTopLevel,
         isLoadingDocument: aWebProgress.isLoadingDocument,
         loadType: aWebProgress.loadType,
-        DOMWindowID: domWindowID
+        DOMWindowID: domWindowID,
+        refreshWasBlocked: aWebProgress.refreshWasBlocked,
       };
     }
 
     return {
       webProgress: aWebProgress || null,
       requestURI: this._requestSpec(aRequest, "URI"),
       originalRequestURI: this._requestSpec(aRequest, "originalURI"),
       documentContentType: content.document && content.document.contentType,
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -38,16 +38,17 @@ function RemoteWebProgress(aManager, aIs
 
   this._manager = aManager;
 
   this._isLoadingDocument = false;
   this._DOMWindow = null;
   this._DOMWindowID = 0;
   this._isTopLevel = aIsTopLevel;
   this._loadType = 0;
+  this._refreshWasBlocked = false;
 }
 
 RemoteWebProgress.prototype = {
   NOTIFY_STATE_REQUEST:  0x00000001,
   NOTIFY_STATE_DOCUMENT: 0x00000002,
   NOTIFY_STATE_NETWORK:  0x00000004,
   NOTIFY_STATE_WINDOW:   0x00000008,
   NOTIFY_STATE_ALL:      0x0000000f,
@@ -58,16 +59,17 @@ RemoteWebProgress.prototype = {
   NOTIFY_REFRESH:        0x00000100,
   NOTIFY_ALL:            0x000001ff,
 
   get isLoadingDocument() { return this._isLoadingDocument },
   get DOMWindow() { return this._DOMWindow; },
   get DOMWindowID() { return this._DOMWindowID; },
   get isTopLevel() { return this._isTopLevel },
   get loadType() { return this._loadType; },
+  get refreshWasBlocked() { return this._refreshWasBlocked; },
 
   addProgressListener: function (aListener) {
     this._manager.addProgressListener(aListener);
   },
 
   removeProgressListener: function (aListener) {
     this._manager.removeProgressListener(aListener);
   }
@@ -193,16 +195,17 @@ RemoteWebProgressManager.prototype = {
                                : new RemoteWebProgress(this, false);
 
       // Update the actual WebProgress fields.
       webProgress._isLoadingDocument = json.webProgress.isLoadingDocument;
       webProgress._DOMWindow = objects.DOMWindow;
       webProgress._DOMWindowID = json.webProgress.DOMWindowID;
       webProgress._loadType = json.webProgress.loadType;
       webProgress._webProgressCPOW = objects.webProgress;
+      webProgress._refreshWasBlocked = json.webProgress.refreshWasBlocked;
     }
 
     // The WebProgressRequest object however is always dynamic.
     let request = null;
     if (json.requestURI) {
       request = new RemoteWebProgressRequest(json.requestURI,
                                              json.originalRequestURI,
                                              objects.request);