What’s New for Developers in Firefox OS 2.5

Share this article

Firefox OS 2.5 is scheduled for release on November 2nd, opening up a range of new possibilities, especially for developers. In this article I will show what you can expect in the next version of Firefox OS.

Early versions of Firefox OS 2.5 were codenamed 3.0. The official release version is 2.5

Introducing Add-Ons

Today, add-ons are a familiar concept in the world of web browsers, and Mozilla believes that mobile platforms should benefit from this flexibility too. As part of the Spark project, add-ons are incorporated into Firefox OS to customize the experience in a similar way to the Firefox browser.

Add-ons are app packages composed of JavaScript, CSS and other assets. However, they don’t run as standalone apps. Instead, an add-on manifest includes special declarations to define what apps to apply the add-on to. When apps launch on a Firefox OS device that has an add-on installed, the add-on is injected into any app that matches the pattern specified in the filter.

Add-ons and apps are packaged the same way, hence they have a similar installation process and are both supported in WebIDE. Although they need to be privileged apps (downloaded from marketplace, sideloaded, installed in dev mode etc.), they don’t need any special privileges once installed.

The idea of an add-on for an open web platform might raise questions on necessity, but it’s a simple concept. A single Firefox OS add-on can extend just one app, several, or all. Think of the Buffer add-on for Firefox. It integrates ‘Buffer’ buttons into the interface of social networks like Facebook or Twitter as if they were native buttons. Add-ons in Firefox OS can be used in a similar way.

Next we will have a look at the main components of an add-on. I recommend you read the official documentation on the Mozilla Developer Network for details and changes.

Note: Firefox OS Add-ons use the WebExtensions model. It’s largely based on Chrome/Blink add-ons, providing advantages in interoperability and features. Read theWebExtensions API documentation to keep track of its status.

Manifest

Let’s start with the manifest. The following is an example manifest of an add-on (the simplest possible):

{
  "manifest_version": 1,
  "name": "Add-on banner",
  "description": "Firefox OS add-on example",
  "version": "1.0",
  "author": "Chris Mills",
  "content_scripts": [{
    "matches": ["app://system.gaiamobile.org/index.html"],
    "css": ["css/style.css"],
    "js": ["js/index.js"]
  }],
  "icons": {
    "128": "/icons/128.png"
  }

Filters

Filters are regular expressions matched against the URL of the page loaded to determine if the app is affected by the add-on.

Some examples:

  • .*: Matches against all apps and pages.
  • gaiamobile.org: Matches only stock Gaia apps, not including engineering apps.
  • m.facebook.com: Matches only the Facebook app and website.

Enabling/disabling

Add-ons are enabled after installation by default. They can be enabled/disabled via Settings app -> Add-ons, or using the navigator.mozApps.mgmt.setEnabled() function.

Permissions

Add-ons inherit their permissions from their host app. Requesting permissions in the add-on manifest will have no effect, and does not expose any APIs that aren’t already available to the host app

Anything written to the window object from an add-on is unavailable to the app code, as add-ons only share a proxied version of the content window. Anything on the window object set by app code is available to add-ons. The DOM is accessible as usual.

When an add-on injects into an app while the app is launching, all add-on files are injected into the app before anything in the app initializes, including the DOM. Note that add-ons can be injected into web pages.

Currently add-ons are hosted in a repo called Hackerplace, since they’re still experimental. Plans are to distribute them via the general Firefox Marketplace soon.

This just scratches the surface of add-on related news for Firefox OS, head to the Mozilla Developer Network to dive deeper into the subject.

Speech Recognition

Mozilla has made some progress on their speech recognition implementation, called Vaani, using the power of the Web Speech API. There’s not much news as it’s messy territory with an API specification by W3C from 2012 and a unofficial draft specification from 2014.

According to Kelly Davis, lead of the speech recognition efforts at Mozilla, the following features are planned to land in Firefox OS 2.5:

  • Call [contact]
  • Call [number]
  • Set an alarm
  • Set a timer
  • Open [App]
  • Languages: English with Spanish and French post-loaded from the Firefox Marketplace
  • Settings for enabling community contributions (record samples with language/accent for Mozilla’s Amazon cloud)

Kelly Davis spoke at Mozilla Weekend Berlin in July about the speech recognition status, so check the video if you want to know more about the process.

Pin the Web

Not as interesting to developers, but still worth noting, is the new Pin the Web feature, allowing users to grab websites and turn them into home screen icons, visually similar to apps. This doesn’t mark a technical breakthrough, but users will benefit from this new feature.

Pin the Web

Presentation slides explaining the philosophy behind Pin the Web are available, together with a prototype of the features shown below:

Tracking Protection

Assuming that people who use Private Tabs don’t want to be tracked, Mozilla incorporated tracking protection in Firefox Developer Edition 42 when using Private Browsing. This feature is now included in Firefox OS 2.5 as well. While Firefox (and Firefox OS) has a ‘Do Not Track’ feature that tells websites not to monitor the user’s behavior, companies are not required to honor it. Firefox’s Tracking Protection feature actively blocks domains and sites that are known to track users.

View Source

Firefox OS 2.5 will allow users to view the source of a web app rendered. This is useful when you want to check a part of the page without the need of debugging tools. Progress on this feature is tracked in this issue.

What does the Fox say?

Firefox OS 2.5 has been designed as a completely hackable and customizable operating system, something which the Firefox browser gained ground with in 2004, introducing a new way to adapt the browser to the user’s liking. Back then, most browsers would offer customizations in form of (now) annoying toolbars. I’m glad that Mozilla has recognized their past strengths and plan to use it to their advantage in Firefox OS.

I feel with the new Ignite strategy, announced by Chris Beard, Mozilla will need to move swiftly while still being aware of the impact they have. Firefox OS is an idealistic approach to a mobile operating system, but making it work in practice is hard (low cost mobile devices, cough). I am positive that Ignite will address all these issues, and there will probably be no second chance for Firefox OS if Mozilla misses their goal with the next release. Make sure to watch this space.

What are you looking forward for in Firefox OS 2.5?

Elio QoshiElio Qoshi
View Author

Elio is a open source designer and founder of Ura Design. He coordinates community initiatives at SitePoint as well. Further, as a board member at Open Labs Hackerspace, he promotes free software and open source locally and regionally. Elio founded the Open Design team at Mozilla and is a Creative Lead at Glucosio and Visual Designer at The Tor Project. He co-organizes OSCAL and gives talks as a Mozilla Tech Speaker at various conferences. When he doesn’t write for SitePoint, he scribbles his musings on his personal blog.

chriswfirefoxfirefox osMozilla
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week