Bug 1350324 - Be more rigorous about ignoring the initial about:blank load for tab progress listeners. r=Gijs a=gchang
authorMike Conley <mconley@mozilla.com>
Mon, 10 Apr 2017 17:45:28 -0400
changeset 395971 ed524b425f187bdd051eacffca42bb196238a176
parent 395970 4ca8d3cb1da10a5555694354d1b8817b02077abe
child 395972 8c70d11ecd10e4c26e058990848fd6464083d80a
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs, gchang
bugs1350324
milestone54.0
Bug 1350324 - Be more rigorous about ignoring the initial about:blank load for tab progress listeners. r=Gijs a=gchang The initial about:blank that we load in a new <xul:browser> is not a load we usually care about. We have code in tabbrowser.xml that ignores the state changes for that initial load, but I guess it's not perfect - there's a case where we were getting a STATE_STOP for that initial about:blank load (since the DocShell will call Stop() on itself before loading that initial about:blank), and then a STATE_START once the about:blank actually started to load. The initial STATE_STOP was ignored, but cleared the "ignore" flag for the STATE_START to come through and show the loading throbber. Then, when flipping remoteness, the "busy" state was not cleared. This patch makes it so that we ignore that initial STATE_STOP (differentiated from other STATE_STOPS because we notice that no loads were currently in progress). MozReview-Commit-ID: IPTxuVGsCYN
browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -572,21 +572,30 @@
               if ((aRequest instanceof Ci.nsIChannel) &&
                   aRequest.originalURI.schemeIs("about") &&
                   (aRequest.URI.schemeIs("jar") || aRequest.URI.schemeIs("file")))
                 return false;
 
               return true;
             },
 
-            _isForInitialAboutBlank(aWebProgress, aLocation) {
+            _isForInitialAboutBlank(aWebProgress, aStateFlags, aLocation) {
               if (!this.mBlank || !aWebProgress.isTopLevel) {
                 return false;
               }
 
+              // If the state has STATE_STOP, and no requests were in flight, then this
+              // must be the initial "stop" for the initial about:blank document.
+              const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
+              if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
+                  this.mRequestCount == 0 &&
+                  !aLocation) {
+                return true;
+              }
+
               let location = aLocation ? aLocation.spec : "";
               return location == "about:blank";
             },
 
             onProgressChange(aWebProgress, aRequest,
                              aCurSelfProgress, aMaxSelfProgress,
                              aCurTotalProgress, aMaxTotalProgress) {
               this.mTotalProgress = aMaxTotalProgress ? aCurTotalProgress / aMaxTotalProgress : 0;
@@ -619,17 +628,19 @@
               const nsIChannel = Components.interfaces.nsIChannel;
               let location, originalLocation;
               try {
                 aRequest.QueryInterface(nsIChannel)
                 location = aRequest.URI;
                 originalLocation = aRequest.originalURI;
               } catch (ex) {}
 
-              let ignoreBlank = this._isForInitialAboutBlank(aWebProgress, location);
+              let ignoreBlank = this._isForInitialAboutBlank(aWebProgress, aStateFlags,
+                                                             location);
+
               // If we were ignoring some messages about the initial about:blank, and we
               // got the STATE_STOP for it, we'll want to pay attention to those messages
               // from here forward. Similarly, if we conclude that this state change
               // is one that we shouldn't be ignoring, then stop ignoring.
               if ((ignoreBlank &&
                    aStateFlags & nsIWebProgressListener.STATE_STOP &&
                    aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) ||
                   !ignoreBlank && this.mBlank) {