fuel - firefox 3 (june '07)
Post on 07-Nov-2014
11.797 Views
Preview:
DESCRIPTION
TRANSCRIPT
FUELParis - June 23, 2007
John Resig - Mozilla Corp.
What is FUEL?
• JavaScript API for Mozilla development
• Focus on solving most common problems
• Emphasis on Firefox Extension Dev
• Improve portability
• Targeting Web Developers
Implementation
• Written in pure JavaScript
• (Users can crack it open and see how it works.)
• Wrappers around XPCOM objects
Simplify Concepts
• Provide a consistent means of doing these:
• Events
• foo.events.addListener( “test”, fn );
• Iteration
• foo.all.forEach( fn );
• Add/Remove
• foo.add( obj ) / obj.remove()
FUEL 0.1
• Preferences, Events, Storage
• In Firefox 3.0a4
• API: http://wiki.mozilla.org/FUEL/0.1/API
Application Events
• Make sure the application is ready to be interacted with (all aspects are loaded):Application.events.addListener(“ready”, fn);
• Handle when a user exits the application:Application.events.addListener(“quit”, fn);
Preferences
• Coverage of the most common preference tasks.
• Get/Set Preferences:Application.prefs.getValue(“my.pref”, default);Application.prefs.setValue(“my.pref”, “value”);
• Extension Preferences:myExt.prefs.setValue(“autosave”, true);
Preferences (cont.)
• Get all preferences that have been modified by the user:Application.prefs.all.forEach(function(p){ if ( p.modified ) // do something});
Storage
• Temporary, runtime, data storage and retrieval.
• Application-wide storage:Application.storage.set(“data”, 4);
• Extension-level storage:myExt.storage.get(“data”, 0);
FUEL 0.2
• Window/Browser Tabs, Bookmarks
• Will be in Firefox 3.0a6 (under final review)
• API: http://wiki.mozilla.org/FUEL/0.2/API
Browser
• Get the current active browser window:Application.activeWindow
• Get the URL of the active tab:Application.activeWindow.activeTab.url
Browser (cont.)
• Open and activate a new tab: Application.activeWindow .open("http://google.com/").focus();
• Close all Google-related tabs: Application.activeWindow.tabs.forEach(function(tab){ if ( tab.url.match(/google/) ) tab.remove();});
Bookmarks
• Add a new bookmark: Application.bookmarks.add("Mozilla", "http://mozilla.org/");
• Remove all Google-related bookmarks: Application.bookmarks.all.forEach(function(cur){ if ( cur.url.match(/google.com/) ) cur.remove();});
Overview
• Application Events (0.1)
• Preferences (0.1)
• Storage (0.1)
• Bookmarks (0.2)
• Window / Browser Tabs (0.2)
More Info
• All about FUEL:http://wiki.mozilla.org/FUEL
• Test Suite:http://mxr.mozilla.org/seamonkey/source/browser/fuel/test/
• Contact:
• Mark Finkle (mfinkle@mozilla.com)
• John Resig (jresig@mozilla.com)
top related