Skip to content

mv3-examples/firefox-addon-dev-notes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 

Repository files navigation

Firefox Addon dev notes

Notes for issues and gotchas encountered when developing and testing Firefox extensions.

Testing

  • If the test machine does not have the correct time set, attempting to install a recent version of an extension from addons.mozilla.org may show an error "this addon may be corrupt" and won't install it even if the addon does work and installs successfully from the debugging menu.

    Takeaway: Take care to make sure the time is synced correctly in VM snapshots when testing.

  • Firefox for Android browserAction popup extensions will not open when the active tab is on addons.mozilla.org . The addon should be tested with another website or file tab open.

WebExtensions API

Context Menu Extensions

Legacy Compatibility

browser.menus vs. chrome.contextMenus:

The last two constructs have examples that are tested and working in older versions of Firefox, like 48.0 (the minimum for WebExtensions support) and 52esr.

The first construct works in recent (mv2) versions of Firefox, but not earlier versions like 48.0 and 52: browser.menus is undefined

Takeaway: use of chrome.contextMenus.create is preferred, and also works with mv3 chrome extensions.

executeScript and host types

The permissions error "Missing host permissions for the tab" is present on view-source, PDF view (pdf.js), and reader view pages when trying to run {scripting|tabs}.executeScript().

The "missing host permissions" error has also been observed when using the tabs permission and loading executeScript on a local file (file://) URI.

Using the activeTab manifest permission instead of tabs was found to fix host permissions errors on file:// pages.

Takeaway: activeTab is preferred, but view-source, PDF viewer, and reader view pages still won't load executeScript behaviors.

Manifest V3 migration

Permissions and host access in MV3

In MV3, host_permissions access is "optional", meaning host permissions do not run by default, and must be set by the user, requested by the addon or enabled using activeTab with a user input handler. <all_urls> host_permission has no effect, whether or not this is by design.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/host_permissions#requested_permissions_and_user_prompts

https://stackoverflow.com/questions/76083327/firefox-extension-manifest-v3-request-permission-to-access-your-data-for-all

permissions.request cannot be called via chrome.runtime.onInstalled.AddListener, and must be called from a user input handler.

Ex: https://github.com/ipfs/ipfs-companion/blob/7ca6433418909d43ec8801f27e417514614a164c/add-on/src/lib/on-installed.js#L24

About

Notes for issues and gotchas encountered when developing and testing Firefox extensions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published