-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: inject polyfill earlier when world: MAIN
is supported
#606
Conversation
Extension builds preview
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test-e2e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timing issue for Firefox < 128 still exists right?
Yes, but it'll at least continue to work like before. We just won't need to set min supported version to 128 this way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can still discuss in this week's call if we want to drop support for older Firefox versions.
Context
Fixes #590
Without needing to sacrifice Firefox support!
Changes proposed in this pull request
If browser supports
world: MAIN
for content script, we inject directly usingscripting.registerContentScripts
API (can detect WM support immediately on page load). If not, we inject like before from contentScript (slow, requires timeout for WM support detection).We inject via
scripting.registerContentScripts
API and not directly viamanifest.json
, as we can catch the lack of support ofworld: MAIN
via this API. With this detection, we can still support Firefox versions older than 128.Update polyfill to support injecting twice - only the first injection works - as we detect if already injected.
Note: In content script, we inject polyfill from contentScript and not using
scripting.executeScript
in background as we'd otherwise need to inject it manually to each tab.What next?
When Firefox 128 is old enough, we can remove
injectPolyfill
from background.ts as well ascontentScript.ts
and register it directly in manifest.json withworld: MAIN
. When we do that, we'd updatebrowser_specific_settings.gecko.strict_min_version
in manifest.json from 110 to 128, and also removepolyfill/*
fromweb_accessible_resources
. (#607)Test results:
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/ExecutionWorld#browser_compatibility