Skip to content
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

Use Manifest v3 for Firefox #18

Closed
imdj opened this issue Jan 31, 2024 · 6 comments
Closed

Use Manifest v3 for Firefox #18

imdj opened this issue Jan 31, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@imdj
Copy link
Owner

imdj commented Jan 31, 2024

One hiccup in adapting manifest v3 to Firefox is host_permissions. Chrome and Firefox handle thing differently in this case, Chrome before installation will prompt the user for confirmation to 'Add extension' with a summary of what it can access, while Firefox treats these permissions as opt-in where the user is expected after installation to manually visit the extensions page and grants its permissions [0]

[0] https://blog.mozilla.org/addons/2022/11/17/unified-extensions-button-and-how-to-handle-permissions-in-manifest-v3/

MV3 treats host permissions (listed in the extension manifest) as opt-in.

@imdj imdj added the enhancement New feature or request label Jan 31, 2024
@imdj
Copy link
Owner Author

imdj commented Jan 31, 2024

At the moment, Firefox users wouldn't get a prompt for host_permissions in manifest v3 and instead have to do the following post-install:

  1. Go to about:addons
  2. Click on the extension
  3. Switch to the Permissions tab
  4. Enable the optional permissions required

@imdj
Copy link
Owner Author

imdj commented Jan 31, 2024

Another options is to programmatically request permissions using browser.permissions.request API from a user action like: browserAction popup

@imdj imdj mentioned this issue Jan 31, 2024
@imdj
Copy link
Owner Author

imdj commented Jan 31, 2024

According to this comment made by Tomislav Jovanovic (back in 26/6/2023)

Yes, we're developing an update to the install flow for MV3, that will enable users to choose which host permissions to grant, and the default will be checked (meaning granted) for extensions which ask for a limited number of hosts (likely up to 6-10).

Either way, we still need to handle the case of rejected permissions

@imdj
Copy link
Owner Author

imdj commented Feb 1, 2024

Note

During initial testing, after all permissions are granted and the extension loaded successfully, fetching results failed with an error that look like this:

Content-Security-Policy: The page’s settings blocked the loading of a resource at https://hn.algolia.com/api/v1/search... (“default-src”).

Turns out we're also required to use background.js for fetch now:

XHR and Fetch

Content scripts can continue using XHR and Fetch by first making requests to background scripts. A background script can then use Fetch to get the data and return the necessary information to the content script. To avoid privacy issues, set the “credentials” option to “omit” and cache option to “no-cache”. In the future, we may offer an API to support the make-request-on-behalf-of-a-document-in-a-tab use case.

https://blog.mozilla.org/addons/2022/10/31/begin-your-mv3-migration-by-implementing-new-features-today/

@imdj
Copy link
Owner Author

imdj commented Feb 4, 2024

Firefox's manifest v3 is ready.

But, due to to host_permissions being opt-in, which render the extension broken on first install, we'll stick with v2 on the AMO (addons.mozilla.org) listing for now to avoid any friction. Version 0.2.0 still uses manifest v2 but lays the groundwork for a smoother transition in the future by incorporating changes to permissions and using service worker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant