FaviconDownloader: detect favicon MIME type if not specified in the link tag



Mozilla Labs
10 years ago
10 years ago


(Reporter: nossralf, Unassigned)




(1 attachment)



10 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b4pre) Gecko/2008021904 Minefield/3.0b4pre
Build Identifier: 

A lot of times the MIME type for the icon in a <link rel="icon"...> tag isn't specified. (This may be non-standard, but should be handled gracefully to create a nice user experience.)
Currently, this isn't handled by FaviconDownloader making it -- at best -- use the fallback to check /favicon.ico in onContentLoaded. (Worst-case, if the /favicon.ico file in turn doesn't exist, no icon at all is used.)

Reproducible: Always

Steps to Reproduce:
1. Start Prism without command line arguments
2. Try to create an application for a site which has a specified <link rel="icon"...> tag but without a MIME type specified.
Actual Results:  
Prism fails to auto-detect the MIME type and uses the fallback or fails to find an icon completely.

Expected Results:  
Prism detects the MIME type automatically, making use of the specified favicon.

Comment 1

10 years ago
Created attachment 304349 [details] [diff] [review]
auto-detect MIME type

Using the MIME service makes this a simple fix.

As an addition, it may be prudent to also test for rel="shortcut icon". This would bring the icon detection up to parity with Firefox. (Another way of snarfing the MIME type is to check the content-type on the nsIChannel used to download it, but if a server is misconfigured, that may fail indicating text/plain or similar.)
Comment on attachment 304349 [details] [diff] [review]
auto-detect MIME type

I have seen some webpages that didn't return a favicon (and did have one), so this will certainly help out.
Attachment #304349 - Flags: review+
Last Resolved: 10 years ago
Resolution: --- → FIXED

Comment 3

10 years ago
Nice. Marking as verified fixed, since it works for my test cases that failed previously.

Do notice that if the favicon is a GIF image, it still won't work. This is a problem originating in imgITools and I've filed bug 418633 for it.
You need to log in before you can comment on or make changes to this bug.