title: Extensions in Firefox 59 url: https://blog.mozilla.org/addons/2018/01/26/extensions-firefox-59/ hash_url: b431025fdd5261443b3a89a3f60b4ce8
Firefox Quantum continues to make news as Mozilla incorporates even more innovative technology into the platform. The development team behind the WebExtensions architecture is no exception, landing a slew of new API and improvements that can now be found in Firefox 59 (just released to the Beta channel).
As always, documentation for the API discussed here can be found on MDN Web Docs (some of the features below are just hitting the main branch as of this post, so if you don’t find the documentation on MDN, check back in a few days).
Tab hiding is back! Since the deprecation of the legacy extension architecture, one of the most requested features has been the ability to hide tabs with the WebExtensions API. It was a key element of some very popular legacy add-ons that provided the ability to manage tab groups. Firefox 59 brings this capability back in an initial, experimental form.
The API is very straightforward:
Note that the visible state of a tab is completely independent from its discarded state. While it may make sense to keep certain tabs active and loaded in memory while hidden, we encourage you to use tabs.discard() in combination with tabs.hide() to help manage memory and resource usage.
There are certain restrictions when hiding tabs:
The reintroduction of hidden tabs to Firefox does not come without some concern. A primary motivation for moving to the WebExtensions framework is to offer users a safer extension ecosystem that can be trusted to protect their security and privacy. Obviously, tab hiding opens the door for malicious extensions to hide tabs, doing things in the background without a user’s knowledge.
To make sure we get things right, tab hiding is disabled by default. To enable the API, you must manually go to the about:config page and set extensions.webextensions.tabhide.enabled to true. This restriction will remain in place until:
To be clear, this API is currently experimental. It could change, or even go away entirely if we can’t provide it in a secure manner. Nevertheless, Firefox has a long, proud history of customization and the team is committed to upholding that tradition with tab hiding. So please give the API a try and see what you think. With your help, we will work to make tab hiding as fully functional as possible while still maintaining the security of the WebExtensions architecture.
Want to jump right in a see what it’s like? Give the Tab Hider extension a try.
While tab hiding is the big feature to land in Firefox 59, it isn’t the only thing related to tabs.
Continuing the “theme” of previous releases, Firefox 59 includes a number of additions to the Theme API that allow you to customize even more of the browser’s appearance, including:
The webRequest API now merges multiple headers with the same name rather than using only the last one. In addition, a couple of mechanisms were added to the webRequest API to allow for requests to be upgraded from HTTP to HTTPS.
Finally, to make debugging a lot easier, exceptions raised from a webRequest blocking listener now report the original error message and filename. Below is an example:
Another big feature landing with Firefox 59 is the ability to register content scripts at runtime. This is an important feature for extensions that want to support user scripting.
Using the contentScripts.register() API, extensions can dynamically associate content scripts with different URLs, lifting the previous limitation that all content scripts had to be listed statically in the manifest file.
Mozilla has always been a proponent of decentralization, recognizing that it is a key ingredient of a healthy Internet. Starting with Firefox 59, several protocols that support decentralized architectures are approved for use by extensions. The newly approved protocols are:
Firefox itself does not implement these protocols, but having them on the approved list means the browser recognizes them as valid protocols and extensions are free to provide implementations.
Browser Actions and Page Actions are two of the most popular types of extensions that we see submitted to the Firefox Add-Ons website. Accordingly, the team behind WebExtensions continues to expand and improve the API for those types of extensions.
The ability for extensions to control cookies in the browser expanded in Firefox 59, including:
Extensions can now override the proxy settings in the browser which has been another highly requested feature. Using the browserSettings.proxyConfig.set() API, the following proxy settings can be controlled:
As with previous releases, when functionality is provided via WebExtensions that allows extensions to control some aspect of the browser, Firefox will inform the user which extension controls that aspect and provide a way for them to regain control.
The ability for an extension to control the browser’s tracking protection setting was added back in Firefox 57 via the websites.trackingProtectionMode API. Firefox 59 now shows when an extension controls tracking protection.
In the above image, notice that a message is now displayed after a user disables an extension reminding them how to re-enable it, also a new feature of Firefox 59.
One of the most popular browser defaults to override is the new tab page. Firefox already shows the user when an extension has overridden that page, but starting with Firefox 59 it also informs the user of the override on the first appearance of the new tab page itself. Plus, it is smart enough to revert back to the previous new tab if the new override is declined.
To better support mouse gestures, browserSettings.contextMenuShowEvent() has been added in this version. This new API can be set to “mouseup” or “mousedown” by extensions to determine when context menus should be shown. Note that this is not supported on Android, and also calling it with a value of “mousedown” on Windows is a no-op.
Also in Firefox 59, read-only browserSettings now return false when calling set or clear and also report an accurate levelofControl.
Speaking of context menus, you can now set custom context menus for bookmarks. This will work on the bookmarks toolbar, the library menu, the bookmarks subview, and the bookmarks menu.
One of the best ways to suggest a new WebExtension API is to prototype it via an official experiment. Two major changes landed for WebExtension experiments that makes this significantly easier:
Also in Firefox 59, more detail has been added to sandbox names to aid in debugging.
A number of smaller items were also landed in the new Firefox 59 Beta, including:
Firefox 59 landed a total of 69 items for WebExtensions, the most important of which are discussed above. Thank you to everyone who had a part in getting it to Beta, especially volunteer contributors Andre Garzia, Tim Nguyen, Oriol Brufau, Javier Serrano Polo, Kevin Jones, Tushar Arora, Martin Giger, Peter Snyder, Lukas Jung. Additional changes and improvements to the WebExtensions API are already in progress for Firefox 60, so please continue to send us your feedback. And as always, thank you for using Firefox and helping ensure that individuals have the ability to shape the Internet and their own experiences on it.