Skip to content

Instantly share code, notes, and snippets.

With Australis entering Beta, I'm pleased to introduce four new APIs for building your add-on's user interface: the action button, the toggle button, the toolbar, and the frame.

Buttons, buttons everywhere

First up, we have two APIs for adding buttons to Firefox: action buttons and toggle buttons.

You give action button an icon, a label, and a click handler:

var { ActionButton } = require("sdk/ui/button/action");

In Firefox 31 the Add-on SDK is making a change to the execution environment for content scripts.

For most add-ons, this won't be visible. However, content scripts will no longer be able to use unsafeWindow or window.wrappedJSObject to make JavaScript objects available to content.

Instead, we've provided some new APIs that you can use to share functions and objects with content explicitly. While you're working on migrating to these new APIs, there's a mechanism you can use to switch your add-on back to the old behavior as a short-term measure.

Who's affected?

Add-on SDK-based add-ons that use unsafeWindow or window.wrappedJSObject in content scripts to share JavaScript objects with the scripts loaded by a web page will be broken by this change.

Homer Chrisensen - Permaculture and documentation

Permaculture: permanent+agriculture:

  • work with the elements
  • build a resilient system
  • use of protracted and thoughtful observation
  • observe/design/evolve

"the edge is where the action is":

Here's a report on Write the Docs 2014, Portland edition. Rather than just write up my notes from the talks I decided to write about selected interesting things. If you want to relive the talks, there are pictures, videos, and written notes online.

About the conference

The conference is 2 days, with:

const data = require("sdk/self").data;
const tabs = require("sdk/tabs");
var { ToggleButton } = require("sdk/ui/button/toggle");
var button = ToggleButton({
id: "reddinator",
label: "Reddinator",
icon: {
"16": "./red-16.png",
var child_process = require("sdk/system/child_process");
var ls = child_process.spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', function (data) {
console.log('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
console.log('stderr: ' + data);

Writing an Actor

A Simple Hello World

Here's a simple Hello World actor. It is a global actor (not associated with a given browser tab).

let protocol = require("devtools/server/protocol");

let {method, Arg, Option, RetVal} = protocol;

var content = document.getElementById("content");
window.addEventListener("message", function(event) {
var debuggee = event.ports[0];
volcan.connect(debuggee).
then(listTabs).
then(getCurrentStyleSheets).
then(writeStyleSheetsLength);
});
var tabs = require("sdk/tabs");
var { viewFor } = require("sdk/view/core");
function onOpen(tab) {
let xulTab = viewFor(tab);
let contentWindow = xulTab.ownerDocument.defaultView;
contentWindow.addEventListener("hashchange", logHashChange, false);
}
// do not do this in a real add-on, use contentScriptFile instead.
var listener = "window.addEventListener('hashchange', function() {" +
" alert(window.location.hash);" +
"}, false);"
var pageMod = require("sdk/page-mod").PageMod({
include: "*.google.ca",
contentScript: listener
});