In Firefox 68, we are introducing a new API and some enhancements to webRequest and private browsing. We’ve also fixed a few issues in order to improve compatibility and resolve issues developers were having with Firefox.

Captivating Add-ons

At airports and cafés you may have seen Firefox asking you to log in to the network before you can access the internet. In Firefox 68, you can make use of this information in an extension. The new captive portal API will assist you in making sure your add-on works gracefully when locked behind a captive portal.

For example, you could hold off your requests until network access is available again. If you have been using other techniques for detecting captive portals, we encourage you to switch to this API so your extension uses the same logic as Firefox.

Here is an example of how to use this API:

( async function ( ) { // The current portal state, one of `unknown`, `not_captive`, `unlocked_portal`, `locked_portal`. let state = await browser . captivePortal . getState ( ) ; // Get the duration since the captive portal state was last checked let lastChecked = await browser . captivePortal . getLastChecked ( ) ; console . log ( ` The captive portal has been ${ state } since at least ${ lastChecked } milliseconds ` ) ; browser . captivePortal . onStateChanged . addListener ( ( details ) = > { console . log ( " Captive portal state is: " + details . state ) ; } ) ; browser . captivePortal . onConnectivityAvailable . addListener ( ( status ) = > { // status can be "captive" in an (unlocked) captive portal, or "clear" if we are in the open console . log ( " Internet connectivity is available: " + status ) ; } ) ; } ) ( ) ;

Note: if you use this API, be sure to add the captivePortal permission to your manifest.

Private and contained

We’ve made a few additions to the webRequest API to better support private browsing mode. You can now limit your webRequests to only include requests from private browsing mode. If instead you are interested in both types of requests it is now possible to differentiate them in the webRequest listener.

To improve the integration of containers, we’ve also added the container ID (cookieStoreId) to the webRequest listener.

Proxy new and proxy old

The two additional fields mentioned in the previous section are also available in the details object passed to the proxy.onRequest listener.

At the same time, we’d like to make you aware that we are deprecating the proxy.register , proxy.unregister and proxy.onProxyError APIs. As an alternative, you can use the proxy.onRequest API to determine how requests will be handled, and proxy.onError to handle failures. If your extension is using these APIs you will see a warning in the console. These APIs will ultimately be removed in Firefox 71, to be released on December 10th, 2019.

Timing is everything

We’ve changed the timing of tabs.duplicate for better compatibility with Chrome. The promise is now resolved immediately, before the duplicated tab finished loading. If you have been relying on this promise for a completed duplicated tab in Firefox, please adjust your code and make use of the tabs.onUpdated listener.

Miscellaneous

Since extensions cannot add bookmarks to the root folder, we’ve improved the error message you get when you try. If you’ve been trying to remove indexedDB data via browser.browsingData.remove({}, { indexedDB: true }); and it failed in some cases, we’ve fixed this on our end now. Removing cookies for IPv6 addresses has been fixed. Fixes an issue when setting cookies with an IP address in the domain field, along with the url field being set. Hard-to-debug performance issues using webRequest.onBeforeRequest with requestBody during large uploads have been solved. An issue with identity.launchWebAuthFlow hanging after authentication has been resolved. storage.onChanged is now fired when values are removed.



Thank You

We’ve had a great amount of support from the community. I’d like to thank everyone who has taken part, but especially our volunteer contributors Jan Henning, Myeongjun Go, Oriol Brufau, Mélanie Chauvel, violet.bugreport and Piro. If you are interested in contributing to the WebExtensions ecosystem, please take a look at our wiki.