WebExtensions in Firefox 52

Firefox 52 landed in Developer Edition this week, so we have another update on WebExtensions for you. WebExtensions are becoming the standard for add-on development in Firefox.

API Parity

The sessions API was added to Firefox, with sessions.getRecentlyClosed and sessions.restore APIs. These allow you to query for recently closed tabs and windows and then restore them.

The topSites API was added to Firefox. This allows extensions to query the top sites visited by the browser.

The omnibox API was added to Firefox. Although in Firefox the omnibox is called the Awesome Bar, we’ve kept the naming the same so that extensions can easily port between Chrome and Firefox. The API allows extensions to register a unique keyword for providing their own suggestions to the Awesome Bar. The extension will be able to provide suggestions whenever its registered keyword is typed into the Awesome Bar.


Screenshot of an extension which registered the keyword ‘dxr’ for searching the Firefox source code.

The storage.sync API is now ready for testing, but not yet ready for full deployment. This API relies on a back-end service provided by Mozilla to sync add-on data between devices or re-installs. It is most commonly used to store add-on preferences that should be preserved.

Until the main production service is set up, you can test out storage.sync by making a few preference changes. To sync add-on data, a user will need to be logged into a Firefox Account. There is a limit of 100KB in the amount of data that can be stored. Before data is stored on our server, all data is encrypted in the client. By the time Firefox 52 goes into Beta we plan to have a production service ready to go. At that point we hope to remove the need to set preferences and switch users to the new servers.

Some existing APIs have also been improved. Some of the more significant bugs include:

  • The addition of browser.runtime.onInstalled and browser.runtime.onStartup which are commonly used to initialize data or provide the user with more information about the extension.
  • You can now match and attach content scripts to iframes with about:blank source, which are often used for inserting ads around the web.
  • The manifest file now supports developer information and falls back to the author if appropriate.
  • The commands API now supports _execute_browser_action, which allows you to easily map a command to synthesize a click on your browser action.
  • Bookmark events have been implemented, providing the onRemoved, onMoved, onCreated and onChanged events.

New APIs

Recently, contextual identities were added to Firefox, and these are now exposed to WebExtensions as well, in the tabs and cookie APIs. As an example, the following will query every tab in the current window and then open up a new tab at the same URL with the same contextual identity:

let tabs = browser.tabs.query({currentWindow: true});
tabs.then(tabs => {
  for (let tab of tabs) {
      url: tab.url, cookieStoreId:

This API is behind the same browser preference that the rest of the contextual identity code is, privacy.userContext.enabled. We expect the API to track that preference for the moment.

You can now suspend and resume requests using the webRequest API. This allows extensions to suspend requests, perform asynchronous checks if necessary, then resume or cancel the request when appropriate, without blocking the parent process.

Out of process extensions

The work to run extensions out of process continues, with multiple changes being made across the APIs to support this. If you are developing an extension using the WebExtensions API then this change should have no effect on you. If you are planning to develop a WebExtensions API, maybe using experiments, or committing into mozilla-central, then please check the documentation for what you need to know.


The WebExtensions examples repository keeps growing, currently standing at 26 examples. Recent additions include:

All the examples have been altered to use the browser namespace and promises instead of the chrome namespace. The MDN documentation has also been updated to reflect this change.


Web-ext is the command line tool for developing WebExtensions quickly and easily. There were versions 1.5 and 1.6 of web-ext released. Significant changes include:

  • sign can now use a proxy.
  • build uses the locale when generating a file name.
  • --firefox-binary has been shortened to --firefox.

New contributors

Over this release, we’ve had our largest influx of new contributors ever. A shout out to all the awesome contributors who have helped make this happen including the following:

For a full list of the changes to Firefox over this period please check out this Bugzilla query.

1 response

  1. Agnieszka Stellmach wrote on :

    now the following code generating an INPUT event doesn’t work any more in a content script

    var my_textbox = document.querSelectorAll(input[id=’search_expression’])
    my_textbox.value = “xxxxxxxxx”;
    var evt = document.createEvent(“HTMLEvents”);
    evt.initEvent(“input”, false, true);

    The code works in the scratchpad. So I think it is the new update but so far I found no information.