Closed Bug 1860304 Opened 6 months ago Closed 6 months ago

Background page fails to load if background.service_worker and background.scripts are both present

Categories

(WebExtensions :: General, defect, P2)

defect

Tracking

(firefox-esr115 verified, firefox118 wontfix, firefox119 wontfix, firefox120 wontfix, firefox121 fixed)

VERIFIED FIXED
121 Branch
Tracking Status
firefox-esr115 --- verified
firefox118 --- wontfix
firefox119 --- wontfix
firefox120 --- wontfix
firefox121 --- fixed

People

(Reporter: robwu, Assigned: robwu)

References

(Regression)

Details

(Keywords: dev-doc-complete, regression, Whiteboard: [wecg][addons-jira])

Attachments

(2 files)

When manifest.json's background declaration contains both service_worker and an event page, the extension loads but the background page fails to start up.

The expected cross-browser behavior (as established in https://github.com/w3c/webextensions/issues/282) is to ignore scripts if service_worker is supported, but to use scripts otherwise (WECG proposal / implemented by Safari). Chrome currently fails to load the extension, but will reduce it to a non-fatal warning in crbug.com/1418934.

We currently don't support service_worker (bug 1573659). And as I explained in https://bugzilla.mozilla.org/show_bug.cgi?id=1775618#c1, there is already a bug that prevents the Service worker from loading if scripts and service_worker are both present. Fixing that was not a high priority because we haven't turned on support for service workers.

Today, I saw a report (https://github.com/w3c/webextensions/issues/282#issuecomment-1773034430) that stated that the background page fails to load if both are present. Upon investigation, it turns out that this is caused by a combination of bugs:

Set release status flags based on info from the regressing bug 1609920

Thanks for opening this! As far as I know having an unrecognised property under background would not prevent the background page/scripts to load. Unless it's the service_worker. Is it known when an extension with both scripts and service_worker started becoming unsupported?

Severity: -- → S4
Priority: -- → P2

Set release status flags based on info from the regressing bug 1609920

When a background page and service_worker are specified simultaneously,
load the background page instead of neither (i.e. the bug).

This patch only fixes the issue when
extensions.backgroundServiceWorker.enabled is false; When true, the
service worker is expected to load but doesn't due to
https://bugzilla.mozilla.org/show_bug.cgi?id=1775618#c1 . That requires
a different fix and is therefore saved for a follow-up.

Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/bf96c386d8c7
Ignore service_worker property when off by pref r=rpl
Status: NEW → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 121 Branch

Needs MDN release note entry.

Keywords: dev-doc-needed

The patch landed in nightly and beta is affected.
:robwu, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox120 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(rob)
Flags: needinfo?(rob)

Release note available for review in "Background page load fail bug fix release note" #30097

When a background page and service_worker are specified simultaneously,
load the background page instead of neither (i.e. the bug).

This patch only fixes the issue when
extensions.backgroundServiceWorker.enabled is false; When true, the
service worker is expected to load but doesn't due to
https://bugzilla.mozilla.org/show_bug.cgi?id=1775618#c1 . That requires
a different fix and is therefore saved for a follow-up.

Original Revision: https://phabricator.services.mozilla.com/D192081

Attachment #9396908 - Flags: approval-mozilla-esr115?
Attachment #9396908 - Flags: approval-mozilla-esr115?
Attachment #9396908 - Attachment description: Bug 1860304 - Ignore service_worker property when off by pref → Bug 1860304 - Ignore service_worker property when off by pref r=rpl
Attachment #9396908 - Flags: approval-mozilla-esr115?

esr115 Uplift Approval Request

  • User impact if declined: ESR115 users cannot install extensions that have been developed with cross-browser compatibility in mind. Since ESR115 is the last supported Firefox version on Windows 7/8, this could lower the number of available add-ons to them in the longer term.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: Create a directory with manifest.json and background.js from https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background#browser_support . Then try to load it at about:debugging and confirm that the test extension works as documented (a new tab opens)
  • Risk associated with taking this patch: Low
  • Explanation of risk level: Fixes very specific check, without side effects
  • String changes made/needed: no
  • Is Android affected?: yes
Attachment #9396908 - Flags: approval-mozilla-esr115? → approval-mozilla-esr115+
Flags: qe-verify+

Verified as Fixed. Tested on the latest ESR 115.11.0 (https://treeherder.mozilla.org/jobs?repo=mozilla-esr115&searchStr=build-signing%2Cshippable&fromchange=0b1b7b40dce62a5b81da7743f0d78dcf3ff3cead&selectedTaskRun=PvYBK5cXQsybruXrgiJpdQ.0) under Windows 10 x64 and Ubuntu 22.04 LTS.

Upon loading the test extension created as per the specifications mentioned in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background#browser_support, a new tab opens with the following URL - http://example.com/firstrun.html, confirming the fix.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: