Firefox MV3 compatibility (background scripts + gecko settings) - #98
Open
lhero-org wants to merge 4 commits into
Conversation
…ce_worker (Chrome uses service_worker, Firefox 121+
…ce_worker (Chrome uses service_worker, Firefox 121+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the Firefox Add-ons (AMO) item on the roadmap — the next post-1.0 target, flagged there as needing "a manifest v2/v3 compatibility audit; Firefox's WebExtension surface diverges from Chromium in a few places."
Changes:
manifest.json: addsbackground.scriptsalongsideservice_worker— Chrome usesservice_worker, Firefox (121+) usesscriptsas an event page. Both keys can coexist safely per current Firefox/Chrome behavior.manifest.json: addsbrowser_specific_settings.geckofor AMO signing. Note: theidvalue (browser-extension@wordpress.org) is a placeholder — this needs to be a real, permanent identifier the WordPress Foundation controls, since AMO uses it to track the extension across updates. Please confirm the actual value before merge.background.js: guards theimportScripts()calls, sinceimportScriptsis aWorkerGlobalScopemethod unavailable in Firefox's event-page context (a plain script, not a worker). Firefox loads the two dependency files viamanifest.json'sscriptsarray instead, ahead ofbackground.js.safari/.../Resources/) synced to match, via the existingscripts/sync-safari.sh.Tested:
test/npm test),npm run buildclean.about:debugging): WordPress detection, popup, admin bar shortcuts (edit/view/profile/logout), Mobile Preview, cache-busting, Clear Site Data (Keep Login), and Highlight Blocks all confirmed working correctly.Known gap, not addressed here: Firefox for Android has no
windowsAPI, so Mobile Preview (which callschrome.windows.create) will silently no-op there rather than open a preview window. Scoping that out of this PR since it's Android-specific and this PR is focused on desktop Firefox compatibility — happy to follow up separately if that's wanted.