Open Bug 1775618 Opened 2 years ago Updated 6 months ago

Warn instead of failing hard when background SW declaration contains unrecognized properties

Categories

(WebExtensions :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: robwu, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [addons-jira])

Currently, when the background key of a Service worker-based extension contains an unrecognized key, the extension fails to load altogether.

To fix this, we should add "additionalProperties": { "$ref": "UnrecognizedProperty" } to https://searchfox.org/mozilla-central/rev/c30349265c87047a324a471d2f39a216b6749262/toolkit/components/extensions/schemas/manifest.json#158-164

This bug prevents extensions from loading if they specify the type: "module" property (which is not supported yet due to bug 1775574). If extensions ever want to use type: "module" when we finally add support, then the extension would be incompatible with earlier Firefox versions where this was not supported.

Severity: -- → N/A
Priority: -- → P5
Priority: P5 → P3
See Also: → 1811443

The whole "background" syntax at https://searchfox.org/mozilla-central/rev/75da1dd5d4b9b991f919a41594194eab93cdef62/toolkit/components/extensions/schemas/manifest.json#129-174 needs to be rewritten.

With the service worker feature enabled, there is currently ambiguity when scripts and service_worker are present: the service_worker property is not validated and neither normalized. So, with the following manifest + extensions.backgroundServiceWorker.enabled true at startup,

{
    "name": "SW + event page",
    "version": "1",
    "manifest_version": 3,
    "background": {
        "scripts": ["bg.js"],
        "service_worker": "bg.js"
    }
}

Firefox fails to load any of them, and raises the following error:

InvalidStateError: Script URL cannot be parsed

Fortunately, this validation bypass does not result in the load of arbitrary remote scripts, because only moz-extension:-URLs are allowed by the service worker registration, at https://searchfox.org/mozilla-central/rev/75da1dd5d4b9b991f919a41594194eab93cdef62/dom/serviceworkers/ServiceWorkerUtils.cpp#159. And since the host name of moz-extension:-URLs are random and unpredictable, one cannot create an extension that loads a script from a third-party extension.

Severity: N/A → S4
Type: enhancement → defect
Whiteboard: [addons-jira]

This is a blocker before enabling service_worker support, because the bug described in comment 1 prevents a service_worker from loading altogether.

See Also: → 1831417
See Also: → 1860304
See Also: → 1863034
You need to log in before you can comment on or make changes to this bug.