Fuel 0.2 Progress


In case you missed it, Fuel 0.1 recently landed in Firefox 3.0a4.

Fuel 0.1 focused on building a solid foundation for further development; laying a good application and events layer, and building out Preference management. Much of our original plan was scaled back due to the nature of how JavaScript APIs need to be written using XPCOM and IDLs. In a nutshell: Dynamically-generated properties are out, as are optional arguments, and arguments that contains non-primitive objects (arrays, objects, regexps, etc.).

The plan for Fuel 0.2 is pretty well defined at this point. We’re on track to have it land in Firefox 3.0a5.

Specifically, Fuel 0.2 is going to be dealing with two things: Browser tabs and Bookmarks. We have a fairly-complete version of the Fuel 0.2 API up, this will be on top of the existing Fuel 0.1 API.

If you’re curious what this new code is going to look like, here’s some examples from our current plan:

NOTE All of the following is subject to change – please view the final plan and API before attempting to use.

Browser

Open, and activate, a new tab

  1. Application.browser.open("http://google.com/").active = true;

Open, and activate, a tab just after the current tab

  1. var tab = Application.browser.open("http://google.com/");
  2. Application.browser.insertBefore( tab, Application.browser.activeTab.next );
  3. tab.active = true;

or:

  1. var tab = Application.browser.open("http://google.com/");
  2. tab.index = Application.browser.activeTab + 1;
  3. tab.active = true;

Move the active tab to be the first tab

  1. Application.browser.insertBefore(
  2.   Application.browser.activeTab,
  3.   Application.browser.tabs[0]
  4. );

or:

  1. Application.browser.activeTab.index = 0;

Close the active tab

  1. Application.browser.activeTab.close();

Do something when the active tab loads

  1. Application.browser.activeTab.events.addListener( "load", function(){
  2.   this.query("#foo div")
  3. });

Change the URL in the active tab

  1. Application.browser.activeTab.url = "http://mozilla.org/";

Close all Google-related tabs

  1. Application.browser.tabs.forEach(function(tab){
  2.   if ( tab.url.match(/google/) )
  3.     tab.remove();
  4. });

Re-use a tab, or open a new one

  1. var url = "http://google.com/";
  2. Application.browser.tabs.some(function(tab){
  3.   if ( tab.url == url )
  4.     return tab.active = true;
  5. }) || Application.browser.open( url ).active = true;

Stop the user from opening any new tabs

  1. Application.browser.events.addListener( "TabOpen", function(e){
  2.   e.target.close();
  3. });

Bookmarks

Log the title of all top-level bookmarks:

  1. Application.bookmarks.all.forEach(function(cur){
  2.   console.log( "title", cur.title );
  3. });

Add a new bookmark:

  1. Application.bookmarks.add("Mozilla", "http://mozilla.org/");

Remove all bookmarks that point to Google:

  1. Application.bookmarks.all.forEach(function(cur){
  2.   if ( cur.url.match(/google.com/) )
  3.     cur.remove();
  4. });

Add a new bookmark, if one doesn’t already exist:

  1. var url = "http://google.com/";
  2. Application.bookmarks.all.some(function(cur){
  3.   if ( cur.url == url )
  4.     return true;
  5. }) || Application.bookmarks.add( "Google", url );

If you’re interested in tracking our progress on Fuel 0.2, feel free to CC yourself on the tracking ticket for it. If all goes well, this should be in your hands by the time the Firefox 3.0 betas are rolling out. I’m really excited to see some new applications come out that are built on this code.

Posted: May 18th, 2007


If you particularly enjoy my work, I appreciate donations given with Gittip.

5 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.

Ukiyo-e Database and Search

Ukiyo-e.org

Japanese woodblock print database and search engine.


John Resig Twitter Updates

@jeresig

Infrequent, short, updates and links.