Firefox 57 has reached Beta, and a bevy of new APIs and improvements have landed that will put us in a good place for the Firefox Quantum launch in November.
Legacy add-ons no longer load in Firefox 57, but there is still time to migrate (almost 5,000 have migrated so far!), and you can do so even after it lands in release. Just update your listing with the new code and your users will automatically update to the compatible version. When you do, be sure to tell them about it.
Documentation for the APIs discussed here can be found on MDN Web Docs.
API changes
Tabs and Sessions APIs
Tabs now have a discarded state added to the Tab
object. It will be set to true
if the tab is not loaded with content, for example when restored from a previous session. This is part of getting ready for a tabs.discard
API.
The tabs.opener
API has now been implemented which means that openerTabId
is available to the update and create methods and on the Tab
object. This allows extensions to track the opener of tabs.
Also, the tabs API can now open URLs that are view-source:
links and do a “load replace” which changes the page and replaces the current history so that the back button is unaffected.
The session API now has some APIs for setting, getting and removing data on a per tab or per window basis. This allows information about tabs or windows to survive session restores without the data needing to be stored by individual extensions.
webRequest API
The webRequest
details object now includes proxy information. This proxy information will let webRequest
listeners determine how the request interacted with a proxy.
A major new API for webRequest
is now available which allows an extension to filter the HTTP response bodies as they come in. The code below alters the text on example.com. You could do this through a content script, but being able to alter the HTTP response body gives a whole new set of possibilities:
function listener(details) { let filter = browser.webRequest.filterResponseData(details.requestId); let decoder = new TextDecoder("utf-8"); let encoder = new TextEncoder(); filter.ondata = event => { let str = decoder.decode(event.data, {stream: true}); str = str.replace(/Example/g, 'WebExtension Example'); filter.write(encoder.encode(str)); filter.disconnect(); } return {}; } browser.webRequest.onBeforeRequest.addListener( listener, {urls: ["https://example.com/*"], types: ["main_frame"]}, ["blocking"] );
Storage API
A basic implementation of chrome.storage.managed
has landed. This allows administrators or other applications to configure extensions for users. In Firefox you can place a JSON file in a directory, just like for native messaging. For example, a file called favourite-colour-examples@mozilla.org.json
could be placed in the appropriate place:
{ "name": "favourite-colour-examples@mozilla.org", "description": "ignored", "type": "storage", "data": { "colour": "blue!" } }
Then in the favourite-colour-examples@mozilla.org extension:
browser.storage.managed.get('colour').then((colour) => { console.log(colour); });
Would output “blue!”.
Clipboard API
A new clipboard API has been added to allow the copying of images to the clipboard. The clipboard.setImageData
allows you to populate the clipboard with image data. This API is compatible with the Chrome apps API, but at this point it should be considered experimental. This API requires the clipboardWrite
permission.
Developer Tools API
The developer tools gained the panels.elements.createSidebarPane
API and a panels.elements sidebar.setExpression
method. This lets extensions create sidebars in the developer tools. Here’s an example extension that parses jQuery variables:
Find API
A find
API has landed in Firefox. This allows extensions to call the Firefox find API on a tab and get information about the results. It can then add or remove syntax highlighting from that tab, based on the previous search.
This example extension uses the API to search across multiple tabs and highlights them:
Miscellaneous changes
- Content scripts that that are at the
document_end
can no longer run before the scripts that run atdocument_start
. A bug where some pages usingdocument.write
conflicted with content scripts has been resolved. - Some search engine configuration support has been added. Extensions can now set the default search engine to one of the built in choices for search engines through
chrome_settings_overrides
in the manifest. This will not require a prompt. If a search engine that is not shipped with Firefox is requested as default, the user will be prompted to accept the new default. Extensions can now also set asuggest_url
for a search engine. - The privacy API has some additions:
trackingProtection
lets extensions to toggle tracking protection for normal and private browsing mode.allowPopupsForUserEvents
lets extensions change if popups are allowed.imageAnimationBehavior
lets extensions control how images are animated in the browser.
- Other APIs that have changed include:
- Download API now supports
estimatedEndTime
in theDownloadItem
object. - Bookmarks now have separator support.
- BrowsingData API now allows you to clear
localStorage
.
- Download API now supports
- Extensions can now open the
browserAction
, thepageAction
and the open or close the sidebar programmatically. However, this can only be done when some user interaction, such as clicking a link or button, has been done in the browser. - Container support has improved by no longer requiring a user to flip a preference. If a user installs an extension that uses
contextualIdentities
then it is automatically flipped on. This will show up in the users about:preferences (see later). There are now events that allow extensions to find out when containers change. - The theming API has added a few more properties which allow the theming of: the URL bar and search input and the text and background colour of the toolbar. Further, the dynamic theme.update API can now be applied to a specific window.
- Finally, permissions have been added to the installation prompt for the following APIs:
browsingData
,downloads.open
,proxy
and alsodevtools_page
.
Android
There have been multiple bugs fixed to ensure that pageActions
and browserActions
work well on Android. There has been multiple options_ui
fixes and some additions. The runtime.openOptionsPage
API has been added, and for those pages the activeTab
permission takes effect. The browser_action.default_popup
manifest property along with setPopup
and getPopup
has been added.
Firefox for Android now has support for installation permission prompts from the user, closely matching Desktop. When a user installs an add-on, they will be given a permission prompt.
Here’s an example when installing uBlock Origin:
If an extension chooses not to use installation permissions, the optional permission prompts have also been implemented which enable permission prompts at runtime.
Startup check
Firefox has had a brief compatibility check that occurs each time Firefox upgrades a major release. Because there are some extension that might update from legacy extensions sometime after Firefox 57 is released, we wanted to ensure that we could update users to new WebExtensions version when we can.
We took the opportunity to streamline this. The new check is quick and will only occur each time you upgrade to a major version (for example 56 to 57) and have legacy extensions:
User notification
There’s an ongoing project to show Firefox users what changes extensions make to their browser. Often it’s not clear to a user what an extension has done. It can be especially confusing if a user forgets what extensions are installed and finds changes they don’t understand later on.
An API was added that allows extensions to read the home page and new page values so extensions can tell if a user or another extension has changed the values. Along with this API, we’re now surfacing changes through to the about:preferences pages. If an extension uses the provided APIs to change: the home page, the new tab or contextual identities in Firefox 57, then a message will displayed to the user.
Here’s an example where an extension changes the home page:
An example where an extension enables contextual identities:
Long running scripts in an extension will now generate a warning that mentions the extension name, so users can choose what to do with extensions that might be taking a long time.
If an extension changes the new tab through the API, the URL bar will be empty when the new tab page is opened. This allows keyboard users to quickly navigate to new URLs. We’ve also fixed a bug where the identity was not shown in the URL bar for new tabs.
Over the coming releases we plan to add in more information into about:preferences for more and more APIs.
Contributors
Thank you once again to our many contributors for this release, especially our volunteers including: Adam Hillier, angelsl, dw-dev, Jan Henning, Kevin Jones, Lee Bousfield, Tomislav Jovanovic and Tushar Saini. This release marked a record 171 bugs fixed.
Max England wrote on
Jim Kirk wrote on
Max England wrote on
Jim Kirk wrote on
Max England wrote on
Jim Kirk wrote on
Thrawn wrote on
LWChris wrote on
tommi_p wrote on
Thrawn wrote on
Michael T wrote on
Lurtz wrote on
Max England wrote on
Lurtz wrote on
NYB wrote on
Thrawn wrote on
B.O.f.H wrote on
Basil wrote on
Kees wrote on
Bernhard H wrote on
k wrote on
Max England wrote on
Lurtz wrote on
Marius Rickenbacher wrote on
Tahorg wrote on
Thrawn wrote on
Mick wrote on
Lurtz wrote on
Thrawn wrote on
Idiot wrote on
Nick wrote on
Michael Buckley wrote on
Kees wrote on
Trevor Olsson wrote on
Beavis and Butthead wrote on
Henry R wrote on
Bob wrote on
David Hopkins wrote on
Mandingo wrote on
Mad Mike wrote on
Pete wrote on
Piro / YUKI Hiroshi wrote on
daniel wilianto wrote on
Santi wrote on
Tahorg wrote on
Richard Paul wrote on
Duven wrote on
Mirgran wrote on
slumbergod wrote on
torenson wrote on
Jan van Diemen wrote on
Richard Paul wrote on
Rami Nagrobis wrote on
Upset wrote on
Santi wrote on
Caitlin Neiman wrote on
sciuro wrote on
Caitlin Neiman wrote on
torenson wrote on
Alex wrote on
p1nky wrote on
Sara wrote on
Mitu wrote on
Niobe S wrote on
Alex W wrote on
Keiya wrote on
Dave C wrote on
Steve S wrote on
Brad M wrote on
Michael T wrote on
Mike Diack wrote on
Bogdan wrote on
Michael T wrote on
Nate Edel wrote on
Kjemmo wrote on
DEADMC wrote on
Mats Svensson wrote on
Zorba wrote on
Mark wrote on
mansfun wrote on
Jeff wrote on
Zorba wrote on
Jorge Villalobos wrote on
Zorba wrote on
Zorba wrote on
Sublime wrote on
Amy Tsay wrote on
wolfwar wrote on