Closed Bug 1464674 Opened 3 years ago Closed 3 years ago

WebExtension API for getting cached favicons (from tabs)


(WebExtensions :: General, enhancement)

Not set


(Not tracked)



(Reporter: c4609174, Unassigned)


(Whiteboard: enhancement)

User story:
As a WebExtension developer I want to be able to get cached favicons of sites/tabs, because these are more reliable and have other advantages. (see below)

Many add-ons are about tabs and thus display a list of tabs or so in their pane. To make it visually appealing, I think it is a common requirement of WebExtensions to display a favicon next to the URL/title/… of the site/tab.

Current behaviour:
Currently we have the Tabs API[1], which can return a "favIconUrl". The first issue here is "can", because sometimes the tab is still loading as the docs note, or other things.
To use the icon, we have to embed it into the HTML of the extension and thus it triggers a new network request when shown in the popup.

Issues with the current behaviour:
* The network request is just not necessary, if the icon is e.g. from a currently shown tab, it is already loaded in Firefox.
* The network request may be blocked by Firefox' tracking blocker, e.g. Twitter's favicon is blocked.
* Generally, websites may track user's by this unnecessary request. When a web extension requests/needs many favicons, it may have a very specific pattern.
* It introduces latency respectively the user may not see it instantly when the popup of the add-on is e.g. shown.
* If the add-on has a locked down CSP, it does not work. Instead it needs to whitelist img-src, at least.
* It is generally not reliable, I sometimes just did not got an icon although the tab is loaded.

Of course, the more favicons it requests, the worse are the effects.

* Add-ons may implement something like Bug 467828.
* My add-on:

What I propose:
* There should be a way to get the cached favicon of a tab, at least. Firefox should maybe just return a base64 string for the 16x16 favicon. Or, of course, it may return the 32x32 version for HiDPI screens.
* It would be even more useful, if there is a way to get the favicon for any site – not only for tabs. This would likely cover more use cases and allows a fallback in case the method for the tab (respectively the current "favIconUrl") fails.

As for the reliable thing: I think this happened, because the tab was "discarded". It does not seem to return an icon then.
Component: Untriaged → Tabbed Browser
Whiteboard: enhancement
Ever confirmed: true
Component: Tabbed Browser → WebExtensions: General
Product: Firefox → Toolkit
Closed: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1315616
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.