Bug 1386255 - Switch the stop/reload button if the about: URL loaded is not top-level. r?felipe draft
authorJared Wein <jwein@mozilla.com>
Wed, 02 Aug 2017 11:11:35 -0400
changeset 619952 43440f25ee8b6413e2e66b98383339980a683ce8
parent 619581 52285ea5e54c73d3ed824544cef2ee3f195f05e6
child 640555 b1874804b1fb91681755d9c4ec8b73b42e1efd11
push id71883
push userbmo:jaws@mozilla.com
push dateWed, 02 Aug 2017 22:23:17 +0000
reviewersfelipe
bugs1386255
milestone57.0a1
Bug 1386255 - Switch the stop/reload button if the about: URL loaded is not top-level. r?felipe MozReview-Commit-ID: Ieet9wNQf9o
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5041,18 +5041,19 @@ var CombinedStopReload = {
       this.animate = Services.prefs.getBoolPref("toolkit.cosmeticAnimations.enabled") &&
                      Services.prefs.getBoolPref("browser.stopReloadAnimation.enabled");
       Services.prefs.addObserver("toolkit.cosmeticAnimations.enabled", this);
       this.stopReloadContainer.addEventListener("animationend", this);
     });
   },
 
   switchToStop(aRequest, aWebProgress) {
-    if (!this._initialized || !this._shouldSwitch(aRequest))
+    if (!this._initialized || !this._shouldSwitch(aRequest, aWebProgress)) {
       return;
+    }
 
     let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
                         aRequest instanceof Ci.nsIRequest &&
                         aWebProgress.isTopLevel &&
                         aWebProgress.isLoadingDocument &&
                         this.animate;
 
     this._cancelTransition();
@@ -5061,19 +5062,20 @@ var CombinedStopReload = {
       this.stopReloadContainer.setAttribute("animate", "true");
     } else {
       this.stopReloadContainer.removeAttribute("animate");
     }
     this.reload.setAttribute("displaystop", "true");
   },
 
   switchToReload(aRequest, aWebProgress) {
-    if (!this._initialized || !this._shouldSwitch(aRequest) ||
-        !this.reload.hasAttribute("displaystop"))
+    if (!this._initialized || !this._shouldSwitch(aRequest, aWebProgress) ||
+        !this.reload.hasAttribute("displaystop")) {
       return;
+    }
 
     let shouldAnimate = AppConstants.MOZ_PHOTON_ANIMATIONS &&
                         aRequest instanceof Ci.nsIRequest &&
                         aWebProgress.isTopLevel &&
                         !aWebProgress.isLoadingDocument &&
                         this.animate;
 
     if (shouldAnimate) {
@@ -5101,25 +5103,25 @@ var CombinedStopReload = {
     this.reload.disabled = true;
     this._timer = setTimeout(function(self) {
       self._timer = 0;
       self.reload.disabled = XULBrowserWindow.reloadCommand
                                              .getAttribute("disabled") == "true";
     }, 650, this);
   },
 
-  _shouldSwitch(aRequest) {
-    if (!aRequest ||
-        !aRequest.originalURI ||
-        aRequest.originalURI.spec.startsWith("about:reader"))
-      return true;
-
-    if (aRequest.originalURI.schemeIs("chrome") ||
-        aRequest.originalURI.schemeIs("about"))
+  _shouldSwitch(aRequest, aWebProgress) {
+    if (aRequest &&
+        aRequest.originalURI &&
+        (aRequest.originalURI.schemeIs("chrome") ||
+         (aRequest.originalURI.schemeIs("about") &&
+          aWebProgress.isTopLevel &&
+          !aRequest.originalURI.spec.startsWith("about:reader")))) {
       return false;
+    }
 
     return true;
   },
 
   _cancelTransition() {
     if (this._timer) {
       clearTimeout(this._timer);
       this._timer = 0;