Bug 408415 - fix favicon disappearance for hash changes during load, r?jaws draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 10 Feb 2016 14:42:46 +0000
changeset 330091 f4d2a93f3c497edba0ae4321b362d04ecf9bfe19
parent 329842 683c1c3ca8321e064f7bcd2f690557ef6562bffb
child 514094 ee9d98ede81a131f4ffc4698bdb046bbd09e9b0d
push id10672
push usergijskruitbosch@gmail.com
push dateWed, 10 Feb 2016 14:46:17 +0000
reviewersjaws
bugs408415
milestone47.0a1
Bug 408415 - fix favicon disappearance for hash changes during load, r?jaws MozReview-Commit-ID: KCdXMKX5sIH
browser/base/content/tabbrowser.xml
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_bug408415.js
browser/base/content/test/general/file_bug408415_popup.html
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -742,35 +742,35 @@
 
             onLocationChange: function (aWebProgress, aRequest, aLocation,
                                         aFlags) {
               // OnLocationChange is called for both the top-level content
               // and the subframes.
               let topLevel = aWebProgress.isTopLevel;
 
               if (topLevel) {
+                let isSameDocument =
+                  !!(aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT);
                 // If userTypedClear > 0, the document loaded correctly and we should be
                 // clearing the user typed value. We also need to clear the typed value
                 // if the document failed to load, to make sure the urlbar reflects the
                 // failed URI (particularly for SSL errors). However, don't clear the value
                 // if the error page's URI is about:blank, because that causes complete
                 // loss of urlbar contents for invalid URI errors (see bug 867957).
                 // Another reason to clear the userTypedValue is if this was an anchor
                 // navigation.
                 if (this.mBrowser.userTypedClear > 0 ||
                     ((aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_ERROR_PAGE) &&
                      aLocation.spec != "about:blank") ||
-                     aFlags & Ci.nsIWebProgressListener.LOCATION_CHANGE_SAME_DOCUMENT) {
+                     isSameDocument) {
                   this.mBrowser.userTypedValue = null;
                 }
 
                 // If the browser was playing audio, we should remove the playing state.
-                if (this.mTab.hasAttribute("soundplaying") &&
-                    (!this.mBrowser.lastURI ||
-                     this.mBrowser.lastURI.spec != aLocation.spec)) {
+                if (this.mTab.hasAttribute("soundplaying") && !isSameDocument) {
                   this.mTab.removeAttribute("soundplaying");
                   this.mTabBrowser._tabAttrModified(this.mTab, ["soundplaying"]);
                 }
 
                 // If the browser was previously muted, we should restore the muted state.
                 if (this.mTab.hasAttribute("muted")) {
                   this.mTab.linkedBrowser.mute();
                 }
@@ -783,19 +783,19 @@
                     findBar.close();
                   }
 
                   // fix bug 253793 - turn off highlight when page changes
                   findBar.getElement("highlight").checked = false;
                 }
 
                 // Don't clear the favicon if this onLocationChange was
-                // triggered by a pushState or a replaceState.  See bug 550565.
-                if (aWebProgress.isLoadingDocument &&
-                    !(aWebProgress.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE)) {
+                // triggered by a pushState or a replaceState (bug 550565) or
+                // a hash change (bug 408415).
+                if (aWebProgress.isLoadingDocument && !isSameDocument) {
                   this.mBrowser.mIconURL = null;
                 }
 
                 let autocomplete = this.mTabBrowser._placesAutocomplete;
                 let unifiedComplete = this.mTabBrowser._unifiedComplete;
                 if (this.mBrowser.registeredOpenURI) {
                   autocomplete.unregisterOpenPage(this.mBrowser.registeredOpenURI);
                   unifiedComplete.unregisterOpenPage(this.mBrowser.registeredOpenURI);
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -24,16 +24,17 @@ support-files =
   bug792517.html
   bug792517.sjs
   bug839103.css
   discovery.html
   domplate_test.js
   download_page.html
   dummy_page.html
   feed_tab.html
+  file_bug408415_popup.html
   file_bug550565_favicon.ico
   file_bug550565_popup.html
   file_bug822367_1.html
   file_bug822367_1.js
   file_bug822367_2.html
   file_bug822367_3.html
   file_bug822367_4.html
   file_bug822367_4.js
@@ -159,16 +160,17 @@ skip-if = true # browser_bug321000.js is
 [browser_bug329212.js]
 skip-if = e10s # Bug 1236991 - Update or remove tests that use fillInPageTooltip
 [browser_bug331772_xul_tooltiptext_in_html.js]
 skip-if = e10s # Bug 1236991 - Update or remove tests that use fillInPageTooltip
 [browser_bug356571.js]
 [browser_bug380960.js]
 [browser_bug386835.js]
 [browser_bug406216.js]
+[browser_bug408415.js]
 [browser_bug409481.js]
 [browser_bug409624.js]
 [browser_bug413915.js]
 [browser_bug416661.js]
 [browser_bug417483.js]
 [browser_bug419612.js]
 [browser_bug422590.js]
 [browser_bug423833.js]
copy from browser/base/content/test/general/browser_bug550565.js
copy to browser/base/content/test/general/browser_bug408415.js
--- a/browser/base/content/test/general/browser_bug550565.js
+++ b/browser/base/content/test/general/browser_bug408415.js
@@ -1,21 +1,21 @@
 function test() {
   waitForExplicitFinish();
 
   let testPath = getRootDirectory(gTestPath);
 
-  let tab = gBrowser.addTab(testPath + "file_bug550565_popup.html");
+  let tab = gBrowser.addTab(testPath + "file_bug408415_popup.html");
 
   tab.linkedBrowser.addEventListener("DOMContentLoaded", function() {
     tab.linkedBrowser.removeEventListener("DOMContentLoaded", arguments.callee, true);
 
     let expectedIcon = testPath + "file_bug550565_favicon.ico";
 
-    is(gBrowser.getIcon(tab), expectedIcon, "Correct icon before pushState.");
-    tab.linkedBrowser.contentWindow.history.pushState("page2", "page2", "page2");
-    is(gBrowser.getIcon(tab), expectedIcon, "Correct icon after pushState.");
+    is(gBrowser.getIcon(tab), expectedIcon, "Correct icon before hash change.");
+    tab.linkedBrowser.contentWindow.location.href += "#foo";
+    is(gBrowser.getIcon(tab), expectedIcon, "Correct icon after hash change.");
 
     gBrowser.removeTab(tab);
 
     finish();
   }, true);
 }
copy from browser/base/content/test/general/file_bug550565_popup.html
copy to browser/base/content/test/general/file_bug408415_popup.html