WebExtensions

From MozillaWiki
Jump to navigation Jump to search

This page is an introduction to Mozilla's implementation of WebExtensions, a new browser extension API. The goals of this API are:

  • Porting add-ons to and from other browsers should be easier.
  • Reviewing add-ons for addons.mozilla.org should be easier.
  • WebExtensions must be compatible with multiprocess Firefox (Electrolysis).
  • Changes to Firefox's internal code should be less likely to break add-ons.
  • WebExtensions should be easier to use than the existing Firefox XPCOM/XUL APIs.

Much of the specifics of the new API are similar to the Blink extension API. Google has extensive documentation on the API. So does Opera.

Experimental WebExtensions support is now available in Firefox Nightly. We are looking for developer feedback as we fix bugs and expand the set of APIs that are available. We will be listening on https://discourse.mozilla-community.org/c/add-ons/development.

Please note: we are going with the name WebExtensions because it can be used in search engines, not Web Extensions (with a space) which is almost impossible to search.

Status

Road map

A draft road map is available here.

Useful queries

Communication and meetings

Testing out the WebExtensions API

See Your first WebExtension on MDN.

Technical Details

Permission Model

We currently enforce manifest permissions for the supported APIs. We also don't enforce CSP protections.

Namespacing

At this time, all APIs are accessible through the chrome.* namespace. When we begin to add our own APIs, we expect to add them to the browser.* namespace. Developers will be able to use feature detection to determine if an API is available in browser.*.

Out-of-process Extensions

WebExtensions are compatible with Electrolysis. They run in the main Firefox process (except for content scripts, which run in the same process as web content). We are considering a plan to run extensions in a separate process (or possibly the content process) eventually, see 1190679 for more details.

Packaging

Extensions are packaged as standard Zip files, but with .xpi extensions. In the future, we're planning to use the .zip extension instead.

The manifest.json file supports the following directives, in addition to the directives supported by Blink:

"applications": {
  "gecko": {
    "id": "{the-addon-id}",
    "strict_min_version": "40.0.0",
    "strict_max_version": "50.*"
    "update_url": "https://foo/bar"
  }
}

Both version fields are Gecko versions, and allow extension to support any application built on that version of Gecko. In the case of Firefox, they correspond to the Firefox release version.

The update_url field may point to an RDF update manifest to allow automatic updates.

In the future, we hope to make all of these properties optional (which will require generating a unique ID upon installation or upload to addons.mozilla.org).

See https://developer.chrome.com/extensions/manifest for a complete list of manifest directives. Of these, we currently support the following:

  • name
  • version
  • description
  • content_scripts
  • permissions
  • web_accessible_resources
  • background
  • browser_action
  • default_locale

API support status

The list of APIs and their status is now maintained on MDN. We intend to fix any of the exceptions listed there.

Please see arewewebextensionsyet.com for an up to date list of supported APIs that is taken by parsing schemas defined in mozilla-central.

Additional APIs

We plan to add our own APIs based on the needs of existing Firefox add-ons. We also want to hear from you! Please fill out this survey to tell us which APIs you need.

  • NoScript-type functionality. This would come in the form of extensions to webRequest and possibly contentSettings.
  • Sidebars. Opera already supports sidebar functionality; Chrome may soon. We would like to be able to implement Tree Style Tabs or Vertical Tabs by hiding the tab strip and showing a tab sidebar.
  • Toolbars. Firefox has a lot of existing toolbar add-ons.
  • Better keyboard shortcut support. We'd like to support Vimperator-type functionality.
  • Ability to add tabs to about:addons.
  • Ability to modify the tab strip (Tab Mix Plus).
  • Ability to take images of frames/tabs (like canvas.drawWindow)

Contributing

Please see the hacking guide for information about contributing code to the WebExtensions project.