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
Application.browser.open("http://google.com/").active = true;
Open, and activate, a tab just after the current tab
var tab = Application.browser.open("http://google.com/"); Application.browser.insertBefore( tab, Application.browser.activeTab.next ); tab.active = true;
or:
var tab = Application.browser.open("http://google.com/"); tab.index = Application.browser.activeTab + 1; tab.active = true;
Move the active tab to be the first tab
Application.browser.insertBefore( Application.browser.activeTab, Application.browser.tabs[0] );
or:
Application.browser.activeTab.index = 0;
Close the active tab
Application.browser.activeTab.close();
Do something when the active tab loads
Application.browser.activeTab.events.addListener( "load", function(){ this.query("#foo div") });
Change the URL in the active tab
Application.browser.activeTab.url = "http://mozilla.org/";
Close all Google-related tabs
Application.browser.tabs.forEach(function(tab){ if ( tab.url.match(/google/) ) tab.remove(); });
Re-use a tab, or open a new one
var url = "http://google.com/"; Application.browser.tabs.some(function(tab){ if ( tab.url == url ) return tab.active = true; }) || Application.browser.open( url ).active = true;
Stop the user from opening any new tabs
Application.browser.events.addListener( "TabOpen", function(e){ e.target.close(); });
Bookmarks
Log the title of all top-level bookmarks:
Application.bookmarks.all.forEach(function(cur){ console.log( "title", cur.title ); });
Add a new bookmark:
Application.bookmarks.add("Mozilla", "http://mozilla.org/");
Remove all bookmarks that point to Google:
Application.bookmarks.all.forEach(function(cur){ if ( cur.url.match(/google.com/) ) cur.remove(); });
Add a new bookmark, if one doesn’t already exist:
var url = "http://google.com/"; Application.bookmarks.all.some(function(cur){ if ( cur.url == url ) return true; }) || 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.
pd (May 18, 2007 at 5:28 am)
Any particular reason why bookmarks are considered so important? Isn’t File I/O and other matters more important for developing substantial extensions?
Dao (May 18, 2007 at 6:15 am)
Does the Tab API extend the current tabs’ API or is it a wrapper?
In case of the latter, a reference to the actual tab element would be useful.
Setters for .prev and .next would be nice, too.
John Resig (May 18, 2007 at 10:38 am)
@pd: Ah ha! You’ve stumbled on the missing cousin of Fuel. I was going to blog about it, but held off. Neal Deakin is working on a pure-JavaScript File IO API called “Scriptable IO” (API Details). We’re probably going to merge this effort into the whole “Fuel” sub-project. The only reason that I didn’t list it in this post is that there’s currently no plans for it to land in Firefox 3.0a5 (although, it’d certainly be nice). With any luck, though, it’ll be included with Fuel and the new JavaScript Microformats code in Firefox 3.0.
@Dao – It wraps it, and it will certainly provide a reference back. There’s way too much functionality in the original objects to throw away (the Fuel stuff is just designed to make the really common stuff easy).
As far as setters for those properties go – that seems feasible – it may be easier to move tabs around in difficult ways with that available. I’ve added it to the wiki.
pd (May 19, 2007 at 8:29 am)
Thanks for the news John. Sounds exciting, hope Scriptable IO joins the FUEL family soon.
Congrats on the FUEL work so far. Hopefully it will allow web-oriented hacks like me to get further into extension development than I’ve managed thus far.
Dominic (November 7, 2007 at 3:33 am)
cohf gallery
fernanda goeth
1989 kawasaki ninja
boulonnais
international adoption photolisting
girl wedgie
math manipulative
ryan secrest
lonnie waters hardcore
semi formal hairstyles