webextension

Stable

Provides functions for communicating with an embedded WebExtension.

This API is supported from Firefox 51 onwards, and is only available if you have set the "hasEmbeddedWebExtension" key in package.json.

Globals

Functions

startup()

This function starts the embedded WebExtension.

Returns

Promise : a promise that resolves to an object with a single property browser.

The browser object contains the runtime APIs that the embedding add-on can use to exchange messages with the embedded WebExtension:

For example:

// SDK add-on

const webExtension = require("sdk/webextension");

webExtension.startup().then(api => {
  const {browser} = api;
  browser.runtime.onMessage.addListener(handleMessage);
});

See the page on embedded WebExtensions for all the details on embedding WebExtensions in SDK add-ons.

Document Tags and Contributors

 Contributors to this page: wbamberg
 Last updated by: wbamberg,