|
|
Subscribe / Log in / New account

Deprecating XUL for WebExtensions

By Nathan Willis
December 23, 2015

Mozilla first unveiled plans to revamp the development framework offered to extension authors in August, announcing that it would deprecate XUL and XPCOM in favor of an API based on JavaScript. That API, called WebExtensions, is now available to developers in the Firefox Nightly channel. The stable release is scheduled to arrive in mid-2016, and add-ons using the API should also be usable as extensions for the Chrome and Opera browsers.

XUL is the XML-based user-interface markup language used to define windows, menus, interface widgets, and other components in Firefox, Thunderbird, and a few other Mozilla projects. XPCOM is the corresponding component model, providing access to the various libraries that make up the application (networking, security, rendering engine, etc.). Both are well over a decade old and, while it could be argued that they have served their purposes well, they are integral enough to the structure of Firefox that they make it difficult to maintain a clear separation between the browser internals and third-party add-ons.

That has serious security implications, of course, and it also makes browser extensions rather brittle—susceptible to breakage when there are minor changes to the browser code itself. Meanwhile, Google's Chrome/Chromium (and the Opera browser, which also uses Chrome's Blink engine) have both found success attracting extension developers with the JavaScript-based Chrome extension APIs. By mirroring those APIs where possible, Mozilla believes it can attract new extension developers as well as enable many Chrome extensions to work in Firefox with a minimal amount of porting effort.

WebExtensions is Mozilla's name for the new API. It is worth noting that Mozilla terminology uses "API" in the singular, while Chrome's refers to same set of interfaces as APIs, plural. But this is purely semantics, just like how Mozilla refers to extensions, plugins, and themes, collectively, as "add-ons," while Chrome calls everything "extensions." There are more than 60 APIs defined for Chrome's extensions, with more constantly under development. They include everything from hooks to build user-interface elements to security features to the manipulation of page contents. Mozilla has set up a feature-tracking page for its implementation at AreWeWebExtensionsYet.com that lists the completion status for each API and links to open bugs and relevant documentation.

A WebExtension consists of JavaScript files bundled together with a JSON manifest file and any necessary resource files. WebExtensions can run background-process scripts as well as user-visible scripts (such as those that add to the browser interface or modify page content). WebExtensions will be subjected to the same security tests and signing rules imposed on extensions using the existing APIs. They will also retain the .xpi file extension, despite the internal differences with current add-ons. There are a few example extensions available as well.

Currently, the plan is on track for Firefox 45 (which is the series currently in the Nightly channel and which will become the stable Firefox release in March 2016) to fully support the contextMenus, browserAction, pageAction, and alarms APIs. The browserAction API allows an extension to place a button or icon on the toolbar; pageAction allows an extension to place one in the location bar. Like the name implies, contextMenus lets extensions add items to the right-click context menu, while alarms lets extensions schedule tasks. It is a rather small set of features; the plan announcement also noted that there should be "a bunch of partially supported APIs" available as well, including those used to access bookmarks, cookies, storage, and outgoing HTTP requests.

Ideally, the full set of WebExtensions APIs will be available as an experimental feature with the release of Firefox 47 (slated for release at the end of May 2016), and as a stable feature in Firefox 48 (July 2016). That said, even though the advertised goal of the project is to offer an API that closely mirrors that used by the Blink-based browsers, it appears that there will always be some differences.

The Mozilla wiki lists the interfaces that differ from those in the Chrome APIs. In some cases, the likelihood is that Mozilla will never implement the full Chrome API because it is bound too tightly to Google services. For example, in Chrome, the storage API (which is on the list to be partially supported for Firefox 45) supports not only the W3C localStorage standard, but Chrome's built-in cloud synchronization service and an enterprise "managed storage" policy. The Firefox implementation supports only localStorage.

There are other APIs where Firefox and Chrome will vary due to higher-level behavioral or policy differences. For example, Chrome provides separate cookie stores for each incognito tab, and the cookies API allows extensions to access those cookies as well as cookies from the standard browser store. Firefox's private-browsing mode, which is the nearest equivalent of incognito tabs, does not allow extensions to access the private-mode cookies at all. And there may still be additions to the WebExtensions API to provide access to Firefox-only features; the Mozilla wiki notes that Firefox supports special bookmarks like the "Recently Bookmarked" and "Recently Visited" folders that have no Chrome API equivalent.

In the future, though, Mozilla does seem to be aiming to maintain compatibility between the APIs where possible. No doubt that will be seen as a plus when marketing the API to Chrome or Opera extension developers. Even if some porting effort is required, it will be substantially lower than the costs of learning XUL and XPCOM.

Further out, Mozilla has several major changes lined up for Firefox, including the Servo rendering engine and the Electrolysis multi-process model. The August announcement of WebExtensions noted that reliance on XUL and XPCOM was an impediment to implementing both of those plans. The WebExtensions API implementation is explicitly designed to be Electrolysis-compatible.

Since they are being positioned to supplant XUL-based extensions entirely, WebExtensions will also be supported by Mozilla's Add-ons repository service. The developer documentation for the new API, which is still under construction, notes that currently WebExtensions can only be installed locally in Firefox Developer Edition or in Nightly builds. As the roll-out process continues, though, developers will be able to submit WebExtensions for testing and distribution through the Add-ons site. The announcement post that set out the timeline for WebExtensions' availability estimates that the Add-ons site will be ready for the new format by the time Firefox 44 is released—late January 2016.

If everything comes together as planned, then, extension developers can begin experimenting with the new API immediately, with an eye toward making their work available to early adopters in March. Migrating to an entirely new API can certainly seem like a daunting proposition, even if there is half a year between now and when the new API is scheduled to be declared stable. But much of that risk is mitigated by Mozilla's choice to adhere to the battle-tested interfaces used by Chrome and the other Blink-based browsers.

It is a gamble for Mozilla, one that may raise the ire of longstanding extension developers, but the move is well warranted given the long-term goals of work like Electrolysis and Servo. It is less clear whether adopting the same APIs used by Chrome will foster any cooperation on future extension development between Mozilla and the Chrome team, but at least Mozilla will have a seat at the table for such discussions—if it succeeds in bringing a sizeable number of extension developers along.


to post comments

Deprecating XUL for WebExtensions

Posted Dec 24, 2015 12:07 UTC (Thu) by stevem (subscriber, #1512) [Link] (4 responses)

I suspect this is probably going to mean the end of extension like tree style tabs and tab tree, which make managing large numbers of tabs much more workable. :-(

Deprecating XUL for WebExtensions

Posted Dec 24, 2015 21:06 UTC (Thu) by jnareb (subscriber, #46500) [Link] (1 responses)

> I suspect this is probably going to mean the end of extension like tree style tabs and tab tree, which make managing large numbers of tabs much more workable. :-(

Not necessary, there is for example "Tabs Outliner" extension for Chrome.

Deprecating XUL for WebExtensions

Posted Dec 31, 2015 2:52 UTC (Thu) by JanC_ (guest, #34940) [Link]

Which runs in a separate window, and shows tabs from all (other) browser windows. I have browser windows on multiple monitors & multiple virtual screens, so this is not practical…

Deprecating XUL for WebExtensions

Posted Jan 7, 2016 4:33 UTC (Thu) by ssokolow (guest, #94568) [Link] (1 responses)

I don't have the URL handy but posts on Planet Mozilla made it clear that:

1. WebExtensions is intended as a SUPERSET of the relevant Chrome APIs.
2. They're soliciting feedback from developers and the intent is to keep XUL around until that superset has grown to provide a viable solution for the more fundamental extensions.

Deprecating XUL for WebExtensions

Posted Jan 8, 2016 13:08 UTC (Fri) by ssokolow (guest, #94568) [Link]

I just realized the ambiguity in that phrasing. By "more fundamental extensions", I meant things like the bits of NoScript that aren't replicated by their Chrome counterparts. (Things that extend the browser at a deep, fundamental level)

Deprecating XUL for WebExtensions

Posted Dec 24, 2015 22:00 UTC (Thu) by kpfleming (subscriber, #23250) [Link]

Note also the existence of the W3C's Browser Extensions Community Group [1], where some of the major browser manufacturers plan to work on ironing out these differences so an extension will indeed be portable across browsers.

[1] https://www.w3.org/community/browserext/

Deprecating XUL for WebExtensions

Posted Dec 28, 2015 11:13 UTC (Mon) by gdt (subscriber, #6284) [Link] (1 responses)

So the optimal action for an XUL application author at this moment in time is to redevelop for Chrome (where a WebExtensions-style API is available now) and then port to Firefox once their API is ready? Interesting.

Deprecating XUL for WebExtensions

Posted Dec 28, 2015 16:05 UTC (Mon) by flussence (guest, #85566) [Link]

I don't think at any point in history has the optimal action for XUL authors been to use XUL in the first place.

Having said that, good riddance and I'm happy they finally saw some sanity. Chrome's restartless, SDK-less API is a joy to use compared to XUL or Jetpack.


Copyright © 2015, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds