Mozilla Addons Blog: 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.
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:
browser.runtime.onInstalled
and browser.runtime.onStartup
which are commonly used to initialize data or provide the user with more information about the extension._execute_browser_action
, which allows you to easily map a command to synthesize a click on your browser action.onRemoved
, onMoved
, onCreated
and onChanged
events.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) { browser.tabs.create({ url: tab.url, cookieStoreId: tab.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.
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.
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.
https://blog.mozilla.org/addons/2016/11/18/webextensions-in-firefox-52/
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |