|
|
Log in / Subscribe / Register

Development

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.

Comments (8 posted)

Brief items

Quotes of the week

One way or another you have to decide: are you going to wrap your lines with newlines? And of course the answer should be "yes" because lines that trail all the way off the edge of your terminal is a sin against the plaintext gods, who are deceptively mighty, and whose wrath is to be feared (and blessings to be embraced).
— Chris Webber ponders the theological implications of line-wrapping.

There are times when combining two implementations into one would cause more complexity for the system as a whole or violate the Single Responsibility Principle. For example, if your system’s representation of a Car and a Person have some slightly similar code, don’t solve this “problem” by combining them into a single CarPerson class.
— Max Kanat-Alexander on code simplicity.

Just then the scene faded and they were returned to the server room of today, a drab place that had no joy or good ideas anywhere you looked.

"Sigh, there are going to be two more of these bozos who come tonight I suppose. I probably won't get anything done. This will be worse than end of quarter."

— Josh Bressers channels Dickens.

Comments (none posted)

First Plasma Wayland Live Image (KDE.News)

Over at KDE.News, Jonathan Riddell has announced the availability of the first live image [1.2GB ISO] of the KDE Plasma desktop running atop Wayland. "The central component in this is our window manager, KWin, which has moved from drawing borders on the edges of windows to running the full compositor and talking the Wayland protocols which allow applications to draw on screen and be interacted with. Users of the image will notice some obvious glitches, it is certainly not ready for everyday use yet, but the advantages of more secure workspaces, easier feature extendibility and graphics free of tearing and gitches will be appreciated by everybody. Work on this has been ongoing since 2011 and is expected to take years rather than months before a completely transparent switch away from X will be possible. Find more about the project on the KWin Wayland wiki pages."

Comments (32 posted)

FreeType 2.6.2 released

FreeType 2.6.2 is now available, introducing several text-rendering changes that may be of interest to developers and users. Among them are a new default for LCD subpixel rendering and changes to hinting behavior. First, setting hinting to "slight" in Fontconfig now triggers the platform's native hinter if possible. "This decision was driven by my personal whim; I wanted native vertical grid-fitting if the font driver and font supports it, and the auto-hinter otherwise. I assume that native hints are made more carefully and take the (auto-hinting) guesswork out of the process. Instead of introducing per-format configuration in FontConfig and fighting GTK[3]/GNOME[4] that only support a single global hinting setting, it was found to make more sense to change the definition of light hinting in FreeType." Second, there is new, experimental support for stem-darkening in the FreeType auto-hinter, which works around the fact that Linux toolkits do not properly render glyphs onto the background using linear blending and gamma correction. The upshot will be that vertical stems now look somewhat darker on Linux, more accurately matching the font rendering on other platforms.

Full Story (comments: 8)

MediaWiki 1.26 released

Version 1.26 of the MediaWiki platform that powers Wikipedia and many other wiki sites has been released. Performance improvements were the focus for this cycle, notes the announcement: "All JavaScript is now delivered to the client asynchronously, significantly improving the page load time. Due to performance issues in the old implementation, syntax highlighting support was completely overhauled using the Python 'Pygments' library, and added support for several hundred new languages at the same time." In addition, a long-planned overhaul of the authentication code began in this release with the deprecation of old authentication-layer functionality.

Comments (none posted)

WebExtensions in Firefox 45

The Mozilla Add-ons blog takes a look at the work going on around the WebExtensions API. "WebExtensions is currently in an alpha state, so while this is a great time to get involved, please keep in mind that things might change if you decide to use it in its current state. Since August, we’ve closed 77 bugs and ramped up the WebExtensions team at Mozilla. With the release of Firefox 45 in March 2016, we’ll have full support for the following APIs: alarms, contextMenus, pageAction and browserAction. Plus a bunch of partially supported APIs: bookmarks, cookies, extension, i18n, notifications, runtime, storage, tabs, webNavigation, webRequest, windows."

Comments (none posted)

ReText 5.3 available

Version 5.3 of the ReText editor for Markdown documents has been released. New in this update is drag-and-drop support for reordering tabs, a document-preview mode, and fully configurable syntax-highlighting colors.

Comments (none posted)

Vagrant 1.8 available

Version 1.8 of the Vagrant development-environment configuration tool has been released. New are support for linked clones (which are created by building a differential disk image from the original, rather than duplicating a full disk image), creating and restoring from snapshots, and provisioning Ansible on guest machines.

Comments (none posted)

Newsletters and articles

Development newsletters from the past week

Comments (none posted)

Cannon: Why Python 3 exists

Brett Cannon reminds the world why the Python developers decided to create Python 3 — and acknowledges that the transition could have been done better. "This point of avoiding bugs is a big deal that people forget. The simplification of the language and the removal of the implicitness of what a str object might represent makes code less bug-prone. The Zen of Python points out that 'explicit is better than implicit' for a reason: ambiguity and implicit knowledge that is not easily communicated code is easy to get wrong and leads to bugs. By forcing developers to explicitly separate out their binary data and textual data it leads to better code that has less of a chance to have a certain class of bug."

Comments (58 posted)

Questions about Open Source and Design

At her blog, Emily Dunham reports on her recent conversations with UI and UX developers about why open-source projects struggle with design. From the replies, she identifies several pain points, such as: "Non-designers struggle to give constructive feedback on design. I can say 'that’s ugly' or 'that’s hard to use' more easily than I can say 'here’s how you can make it better'" and: "The tests which designers apply to their work are often almost impossible to automate. For instance, I gather that a lot of user interaction testing involves watching new users attempt to complete a task using a given design, and observing the challenges they encounter." No doubt there are few easy answers, but the conversation is certainly worth pursuing.

Comments (none posted)

Guidelines For Announcing Software Releases

At the Red Hat Community blog, Brian Proffitt has posted a detailed set of best-practice guidelines for release announcements. Among the topics addressed are gathering changelog data for announcements as part of the release process, properly timing announcements to be noticed by the community, and differentiating between the audiences for major, minor, and patch-level updates. Also covered is wording advice: "Avoid hyperbole ("the bestest project ever made!!!" and speculation ("the only project that can do this"). As tempting as it is, release announcements should not [be] opportunities to hype your project." And, of course, it touches on that great unsolved problem of computer science: including a few words in the announcement that mention what the software actually does.

Comments (none posted)

Page editor: Nathan Willis
Next page: Announcements>>


Copyright © 2015, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds