Closed Bug 1845035 Opened 1 year ago Closed 1 year ago

Invalid blank favicon causes the page to inherit favicon from a previously visited page

Categories

(Firefox :: Tabbed Browser, defect, P3)

Firefox 115
defect

Tracking

()

RESOLVED FIXED
122 Branch
Tracking Status
firefox122 --- fixed

People

(Reporter: rimas, Assigned: mak)

References

(Depends on 1 open bug, )

Details

Attachments

(4 files)

Attached file favicon_demo.html

+++ This bug was initially created as a clone of Bug #577447 +++

When a newly visited page specifies data:image/x-icon with no content as its favicon, it inherits the favicon from the previously visited page.

I've noticed this a while ago with https://savitarna.perlasgo.lt/, but I've just reported them that their favicon is missing, so I hope they might fix this soon, so I'm attaching a really minimal test case which illustrates the problem.

If you visit a website that has a favicon (e.g. https://www.google.com), and then open the attached file in that same tab, you'll see that the tab keeps the favicon that was previously shown.

Component: General → Tabbed Browser

The severity field is not set for this bug.
:dao, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(dao+bmo)
Attached image Screenshot of tab DOM

This is a screenshot of the Firefox tab's DOM at the time that the bug is reproduced. The src on the image looks pretty fishy - it's data:image/x-icon, which isn't a valid Data URI, and yet the old image is still displaying.

mak said he wanted to take a look at this.

Flags: needinfo?(mak)
See Also: → 1850229

Sorry for the delay. I was worried that this could be one of the reasons for which sometimes we store wrong favicons, but it's apparently only a visual problem.
The url here is parsable, so an nsIURI can be built out of it. That means for us it's valid enough (we don't want to preload the image to check if it's effectively valid, and introducing sanitization code to detect strangely built icons sounds like excessive complexity).
So we end up setting this url into mIconURL, but loading it does nothing and the previous favicon remains.

The easiest solution is to clear the image attribute before loading the new icon, then we'll properly clear the previously shown image. The small downside is that after the "pending" animation we'll briefly show empty space before the new icon appears, but I don't find it jarring or problematic as the icon is about to change anyway. By doing so we ensure only the newly loaded icon can be shown.

I'll try to see how complex is to write a test that visually checks the icon

Assignee: nobody → mak
Severity: -- → S4
Status: NEW → ASSIGNED
Flags: needinfo?(mak)
Flags: needinfo?(dao+bmo)
Priority: -- → P3
Pushed by mak77@bonardo.net: https://hg.mozilla.org/integration/autoland/rev/f53853d2c59b Invalid favicon causes the page to inherit favicon from the previously visited page. r=dao,tabbrowser-reviewers
Regressions: 1866824
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 122 Branch
See Also: 1850229
Regressions: 1874693
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: