Closed Bug 1497729 Opened 6 years ago Closed 6 years ago

Have `tabs.insertCSS(…)` return an identifier

Categories

(WebExtensions :: Frontend, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: e7358d9c, Unassigned)

References

Details

Right now, Firefox provides `browser.tabs.insertCSS(…)` and `browser.tabs.removeCSS(…)` for extensions which create dynamic stylesheets. Unfortunately, in order to remove a dynamic stylesheet or to replace it with an updated version, the extension has to keep the old version in memory so that it can call `browser.tabs.removeCSS({cssText:"…"})` before calling `browser.tabs.insertCSS({cssText:"…"})` with the updated version. This can easily increase the memory footprint by a lot. A solution would be to have `browser.tabs.insertCSS(…)` return some sort of an identifier which can be passed to `browser.tabs.insertCSS(…)` to update the stylesheet, or to `browser.tabs.removeCSS(…)` to remove the stylesheet and invalidate the identifier, thus freeing the memory taken up by said identifier. Each extension should also have its own stylesheet identifier pool, in order to avoid extensions from removing stylesheets which don’t belong to them.
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: needinfo?(lgreco)
Resolution: --- → WONTFIX
Hi ExeBoss, this kind of use case is meant to be covered by contentScripts.register, which resolves to an API object that provides an unregister method (https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/contentScripts/register). Currently the stylesheet registered/unregistered doesn't apply to the existing page until the page is navigated, which is an enhancement already tracked by Bug 1458947.
Flags: needinfo?(lgreco)
You need to log in before you can comment on or make changes to this bug.