FUELing the Firefox

If you’re ever spent time trying to grok Firefox Extension development (especially if you’re coming from a pure web development background). You’ll find that there’s a lot that you have to learn to get up to speed. To name a few: XPCOM, RDF, XUL, and XBL in addition to a huge number of custom APIs for the different aspects of Firefox (Bookmarks, File I/O, Adding Buttons, Menus).

My first major project at Mozilla is to work with Mark Finkle and develop a JavaScript Library for use by Extension developers. If you’re very new to extension development, then this will help you out, completely. We extrapolate out all the complex concepts into one, simple, package. The best part is that this whole thing is going to be available in the whole Mozilla platform (Firefox, Thunderbird, Seamonkey, XULRunner); and in multiple versions (for example FF 1.5-3.0).

We use very little of the actual underlying terminology and naming conventions present in the existing code base (this is bound to irk most established developers), and instead have adopted much of the terminology already present in JavaScript/DOM development. You can see evidence of this in our early API planning for versions 0.1 (Plan) and 0.2 (Plan).

In a nutshell, for 0.1, here’s what we’re tackling: Preferences, Events, Observers, Extensions, Toolbars, and Buttons; and the kind of improvement that you can expect:

Accessing a Boolean Preference

// 'Old' XPCOM way
var prefValue = false;
try {
   prefValue = gPrefService.getBoolPref(this.domain);
} catch (e) {
}

// 'New' FUEL way
var prefValue = Preferences.get(this.domain, false);

Watching for a change in a preference (obvserver).

// "Old" XPCOM way
gPrefService
    .QueryInterface(Components.interfaces.nsIPrefBranch2)
    .addObserver(this.promptDomain, this, false);

// "New" FUEL way
Preferences.addEvent( this.promptDomain, this );

Setting a unicode preference.

// "Old" XPCOM way
try {
    var str = Components.classes["@mozilla.org/supports-string;1"]
        .createInstance(Components.interfaces.nsISupportsString);
    str.data = aURL;

    gPrefService.setComplexValue("browser.startup.homepage",
        Components.interfaces.nsISupportsString, str);
} catch (ex) {
    dump("Failed to set the home page.\n"+ex+"\n");
}

// "New" FUEL way
Preferences.set("browser.startup.homepage", aURL);

We’re really excited about where this is going, and we’d love some feedback. Feel free to comment on the wiki, find us on irc, or drop us an email. Here’s Mark’s take on the project. I’m really excited to be working with him and the whole developer relations team.

Posted: January 9th, 2007


Subscribe for email updates

7 Comments (Show Comments)



Comments are closed.
Comments are automatically turned off two weeks after the original post. If you have a question concerning the content of this post, please feel free to contact me.


Secrets of the JavaScript Ninja

Secrets of the JS Ninja

Secret techniques of top JavaScript programmers. Published by Manning.

John Resig Twitter Updates

@jeresig / Mastodon

Infrequent, short, updates and links.