Closed Bug 408415 Opened 16 years ago Closed 8 years ago

favicon reverts to default if location.href is modified while loading


(Firefox :: Tabbed Browser, defect)

Not set



Firefox 47
Tracking Status
firefox47 --- fixed


(Reporter: bella.spam, Assigned: Gijs)




(1 file)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20071127 Firefox/
Build Identifier: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv: Gecko/20071127 Firefox/

For the sake of the example, assume the following code is in /Users/bella/Desktop/test.html
and here is the content:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="" type="image/x-icon">
<script type="text/javascript">
function reload() { 
  if (window.location.href != "file:///Users/bella/Desktop/test.html#") {

So what I'm trying to do is redirect the user to the original url plus the # sign.

Reproducible: Always

Steps to Reproduce:
1. Go to file:///Users/bella/Desktop/test.html
Actual Results:  
The favicon is shown while the page is loading, but as soon as it gets to the redirect, the favicon reverts to the default (favicon.ico  in the server's root dir).

Expected Results:  
The favicon specified in the <link> tag should be used.
We discovered this issue in Firefox 3.6.8. The following html-code allows to reproduce the issue:

<title> The Demo Store </title>
<link rel="shortcut icon" type="image/x-icon" href="">

<script type="text/javascript" src=""></script>
<script type="text/javascript"> xProductBrowser("categoriesPerRow=3","views=grid(3,3) list(10) table(20)","categoryView=grid","searchView=list","style=");</script>
<noscript>Your browser does not support JavaScript.<a href="">HTML version of this store</a></noscript>

if (!document.location.hash) {
var ecwid_amp = String.fromCharCode(38);
document.location.hash = 'ecwid:category=0' + ecwid_amp + 'mode=product' + ecwid_amp + 'product=1178205';

We hope the new information will help you to fix the issue.

Thank you in advance.
Reporter, are you still seeing this issue with Firefox 3.6.13 or later in safe mode? If not, please close. These links can help you in your testing.
Whiteboard: [CLOSEME 2011-1-30]
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Whiteboard: [CLOSEME 2011-1-30]
I can confirm this issue for both 3.6.15pre and 4.0b13pre (2011-03-01).

Changing href or in fact any modification of the address url using location.replace() or location.assign(), causes the favicon change, but in a different manner in 3 and 4 versions.

1. In 3.6.15pre, favicon just disappears. No requests are made back to the server.

2. In 4.0b13pre, FF calls the server back for GET /favicon.ico and it does not respect existing <link rel="shortcut icon" />.

Here is the test page. Put any favicon.ico in images/ directory:

<!DOCTYPE html>
<link type="image/x-icon" rel="shortcut icon" href="images/favicon.ico"/>
<script type="text/javascript" src=""></script>
<script type="text/javascript">$(document).ready(function() { location.href="#test"; });</script>

If you comment out location.href="#test";, then everything is fine. This example does not cause a GET in version 4, if the page is viewed directly from the file system, but will cause it, if served from the server.

I don't know if this is related, but some of the Wikia-hosted wikis will revert the saved custom bookmark favicon to the generic wikia "W" at random -- even while displaying the correct favicon at the address bar. A reload will refresh the saved icon, but sometime later it will again revert to the Wikia "W".

Custom wiki favicons are loaded by a meta tag, while the generic blue W seems to be loaded from the server root at
i've noticed this problem on my personal site as well. hoping to hear a workaround/fix in this thread...

icons work normally on all of

a link with a # such as makes the icon disappear. previously going to the next photo in the slideshow did not update the hash and the icon stayed there just fine. in other words once each photo updated the hash, the favicon disappeared.
This bug might explain why my WAR application's favicon (href=http://location:8080/myapp/favicon.ico) keeps getting replaced by JBoss's default favicon (href=http://location:8080/favicon.ico).

In my case, I have a GWT application that uses the class with a complex #fragment. Basically, I split the fragment up into parameters (c.f. a query string) with each parameter controlling the state of a particular GWT widget. And I have noticed that the favicon changes to the JBoss default one unless the #fragment's string value stays *exactly* the same while the module is loading.

I have observed this bug using Firefox 12 on both Win7 and Linux. However, neither IE9 nor Chrome is affected.
Confirmed for Firefox 31. Wow, this bug 7 years old!

I created testcase
Load it. favicon is disappear because of location.replace().

Now load it with hash, for example
Green favicon is shown.
Ever confirmed: true
See Also: → 519028

::: browser/base/content/tabbrowser.xml:768
(Diff revision 1)
> -                if (this.mTab.hasAttribute("soundplaying") &&
> +                if (this.mTab.hasAttribute("soundplaying") && !isSameDocument) {
> -                    (!this.mBrowser.lastURI ||
> -                     this.mBrowser.lastURI.spec != aLocation.spec)) {

Note that this is a subtle behaviour change. We will now:

- clear the soundplaying attribute if you refresh the same URL
- not clear it if you pushState() or use location.hash to change the location of the page.

I believe that both of those changes are correct, but I could be wrong. Probably worth testing on e.g. youtube, which I believe uses pushState to navigate from the homepage to individual videos. I did some naive testing and didn't see issues, but part of why I asked you (Jared) for review here is because ISTR you reviewed some of the other patches for this functionality.
Assignee: nobody → gijskruitbosch+bugs
Component: DOM → Tabbed Browser
Product: Core → Firefox
See Also: 519028
Comment on attachment 8717897 [details]
MozReview Request: Bug 408415 - fix favicon disappearance for hash changes during load, r?jaws

Yes, this looks fine.

::: browser/base/content/test/general/browser_bug408415.js:11
(Diff revision 1)
>      let expectedIcon = testPath + "file_bug550565_favicon.ico";

Considering you copied file_bug550565_popup.html to file_bug408415_popup.html but didn't change anything, you might as well copy file_bug550565_favicon.ico to file_bug408415_favicon.ico.

Alternatively, and preferably, you should just rename file_bug550565_favicon.ico to generic_favicon.ico (since there is nothing special about the favicon itself like invalid encoding etc).

I'm assuming you copied the support files so in the future people don't assume they only affected the test for bug 550565.
Attachment #8717897 - Flags: review?(jaws) → review+

This is a very different approach than I expected based on when I started to debug this many years ago in bug 519028. IIRC the issue was that a URI with a fragment was getting passed to some C++ (either docshell or Places favicon related) and that method would give an error since it couldn't handle the fragment (perhaps constructing a principal?).

Perhaps this higher-level fix works, assuming we still listen for <link> changes after a hash change. If we're still passing a fragment to that lower-level function it could still cause other problems.

This is at least moving in the right direction so I'm fine with landing and thanks for fixing this bug that has annoyed me for years :)
Now if only we could get bug 798249 fixed ;)
(In reply to (Limited internet connection 2/12) Jared Wein [:jaws] (please needinfo? me) from comment #11)
> Alternatively, and preferably, you should just rename
> file_bug550565_favicon.ico to generic_favicon.ico (since there is nothing
> special about the favicon itself like invalid encoding etc).
> I'm assuming you copied the support files so in the future people don't
> assume they only affected the test for bug 550565.

I renamed both files and changed their contents to make it clear they were not just used by the test for bug 550565.

Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 47
Depends on: 1260701
No longer depends on: 1260701
You need to log in before you can comment on or make changes to this bug.