Open Bug 1524595 Opened 9 months ago Updated 9 days ago

Support using ServiceWorker‑like environment for WebExtension background pages


(WebExtensions :: General, enhancement, P5)



(Not tracked)


(Reporter: e7358d9c, Unassigned)


(Blocks 2 open bugs)


(Whiteboard: [v3])

Google Chrome will be shipping Extension Manifest V3 soon‑ish, with one of the major improvements being the conversion of background pages to ServiceWorker‑like environments.

The primary advantage of this is that it no longer requires a mostly empty Document instance to persist for the entire session per extension.

I'm pulling in this bug at a low-priority for now, because I believe at some point we will want to support service workers. However, v3 is still very much in flux, details are still very vague, and Mozilla will need to determine if we want to support service workers for extensions in the exact way that Google implements it. Interpret this as support for the general idea as put forth today, keeping in mind that things can and do change.

Severity: normal → enhancement
Priority: -- → P5
Whiteboard: [v3]

Chrome already supports Service Workers for WebExtensions in newTab in version 2. Firefox is missing that. Will this be added at some point, too?

I realise it's early days yet, but there's an annoying deficiency in Chromium's v2 non-persistent API that Firefox oughtn't also fall prey to: there's no good way to tell when the background script is running for the first time in a session (and hence onStartup will fire later) or if it's being reloaded (and hence onStartup isn't coming). If you want to do some initialisation once and only once per session, when an event that's not onStartup is the first to fire, there's no way of knowing if you should asynchronously wait for onStartup & the per-session initialisation to be performed, or if that would block forever because the initialisation's already been done.

A fix for this would be a new onResumed event, which would fire after the background script's being started for the n+1th time in a session.

Blocks: 1578286
You need to log in before you can comment on or make changes to this bug.