Bug 550565: Calling history.pushState during onDOMContentLoaded drops a favicon. r=dao

This commit is contained in:
Justin Lebar 2010-03-24 10:22:13 +01:00
parent ecbe0b409d
commit 968d7bb30d
5 changed files with 40 additions and 2 deletions

View File

@ -437,9 +437,13 @@
if (this.mBrowser.userTypedClear > 0)
this.mBrowser.userTypedValue = null;
// Don't clear the favicon if this onLocationChange was triggered
// by a pushState or a replaceState. See bug 550565.
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow &&
aWebProgress.isLoadingDocument)
this.mTabBrowser.getBrowserForTab(this.mTab).mIconURL = null;
aWebProgress.isLoadingDocument &&
!(this.mBrowser.docShell.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE)) {
this.mBrowser.mIconURL = null;
}
// changing location, clear out the missing plugins list
this.mBrowser.missingPlugins = null;

View File

@ -49,7 +49,10 @@ _BROWSER_TEST_FILES = \
browser_bug388121-2.js \
browser_bug441169.js \
browser_bug503832.js \
browser_bug550565.js \
file_bug503832.html \
file_bug550565_popup.html \
file_bug550565_favicon.ico \
$(NULL)
# the tests below use FUEL, which is a Firefox-specific feature

View File

@ -0,0 +1,19 @@
function test() {
waitForExplicitFinish();
let testPath = "chrome://mochikit/content/browser/docshell/test/browser/";
let tab = gBrowser.addTab(testPath + "file_bug550565_popup.html");
tab.linkedBrowser.addEventListener('DOMContentLoaded', function() {
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.");
gBrowser.removeTab(tab);
finish();
}, true);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test file for bug 550565.</title>
<!--Set a favicon; that's the whole point of this file.-->
<link rel="icon" href="chrome://mochikit/content/browser/docshell/test/browser/file_bug550565_favicon.ico" />
</head>
<body>
Test file for bug 550565.
</body>
</html>