background preloader

Firefox 4

Facebook Twitter

Using JavaScript code modules - MDC. JavaScript code modules are a concept introduced in Gecko 1.9 and can be used for sharing code between different privileged scopes. Modules can also be used to create global JavaScript singletons that previously required using JavaScript XPCOM objects. A JavaScript code module is simply some JavaScript code located in a registered location. The module is loaded into a specific JavaScript scope, such as XUL script or JavaScript XPCOM script, using Components.utils.import() or Components.utils["import"](). Creating a JavaScript code module A very simple JavaScript module looks like this: Notice that the module uses normal JavaScript to create functions, objects, constants, and any other JavaScript type. Components.utils.import(" alert(foo()); alert(bar.size + 3); alert(dummy); The URL for a code module As you can see from the example above, you need a URL to import a code module.

Code modules can only be loaded using a chrome: (), resource:, or file: URL. Notes. How to Improve Extension Startup Performance « Mozilla Add-ons Blog. Mozilla is fighting poor performance in Firefox on many fronts. Firefox 3.6 was already a significant improvement over 3.5, and Firefox 4 promises to be lightning fast. However, Firefox is already pretty fast. Seriously. If you download and install Firefox and run it on a clean profile, it should open quickly and be very responsive. Performance hasn’t really been a big concern for add-on authors.

Dietrich began the add-on performance conversation with his post Firefox, Extensions and Performance, and now with the help of Heather Arthur, we have a modified Talos system measuring the startup performance for the most popular extensions. I spent some time last week contacting the authors of the add-ons with the most impact on startup times, and the response has been very positive so far. I also realized that I was just as guilty with my add-on, and that I needed to work on improving its startup performance. Case Study: Fire.fm First, I needed a testing environment. Wow. Guidelines. Add-on compatibility for Firefox 4 – time to get started | BROWSERWIRE.COM. Add-on compatibility for Firefox 4 – beta 4 edition « Mozilla Add-ons Blog. A little over a month ago I posted the first compatibility notice for add-on developers. Beta 1 was just out, and there were a lot of important breaking changes that you needed to be aware of.

We’re now up to beta 4, RC1 is a couple of months away, and there even more things you should know about. First, the key documentation: Firefox 4 for Developers. This is the definitive document, but it can be a little out of date given that documentation is normally added only after bugs are finalized and somebody from the documentation team picks it up.Add-on compatibility for Firefox 4 – time to get started. The first installment in this series of posts. It contains most relevant information up to Beta 1. And now, the new stuff. New UI Features Beta 4 shipped with a new feature called Firefox Panorama (previously known as Tab Candy).

Details about the Firefox App button. Toolbar buttons are being handled very differently and have different dimensions. Development and Packaging More! Happy coding! Blog Archive » How we’re breaking some extensions in the near future. You may have read some reports about how we’re re-implementing the bulk of the extension manager in Firefox. It’s been a long running project (something like a year since I first really started planning how to do it). Things are finally started to come together and all being well we are likely to look at landing the first pieces of this on the trunk nightlies in as little as a weeks time. I’ll be up front, this isn’t going to be a perfect landing. There may be some thing that are missing and other bits where the user experience isn’t as perfect as it will be finally. Of course there may also be bugs we have to rush to fix. Despite all this we feel that we’re about at the point where exposing it to the hands of thousands of nightly testers is the best way forward.

One thing I wanted to mention is how this will affect the extensions themselves. Accessing file and version information for extensions The extension manager interface as it used to exist is gone with the new code. AddonManager - MDC. The AddonManager object is the global API used to access information about add-ons installed in the application and to manipulate them. The majority of the methods are asynchronous meaning that results are delivered through callbacks passed to the method.

The callbacks will be called just once but that may be before or after the method returns. One of the forces of the AddonManager is that it deals with any kind (type) of add-on in a generic manner. To do so many methods of the AddonManager take the add-on types as parameters. The existing add-on types are defined in XPIProvider.jsm and are, at this time, the following: extension, theme, locale, multipackage.

To import the AddonManager object, use: Components.utils.import(" Method Overview Properties Overview Callbacks InstallCallback() A callback that is passed a single AddonInstall void InstallCallback( in AddonInstall install ) Parameters install InstallListCallback() installs AddonCallback() addon addons id. Addon - MDC. This article is in need of a technical review. An Addon represents an add-on that is either installed or can be installed. Instances can be created using the many getAddon methods on the AddonManager object. The interface can represent many different kinds of add-ons and as such, some of the properties are considered "required" and others "optional," which means that the optional property may not exist on Addon instances for some types of add-ons.

API consumers should take care to verify the existence of these properties before relying on them. Method overview Required properties Optional properties Required Methods isCompatibleWith() Tests whether this add-on is known to be compatible with a particular application and platform version. void isCompatibleWith( in string appVersion, in string platformVersion ) Parameters appVersion An application version to test against platformVersion A platform version to test against findUpdates() Starts an update check for this add-on. Listener reason Optional Methods. AddonListener - MDC. InstallListener - MDC.

This article is in need of a technical review. InstallListeners are notified of an AddonInstall's progress. They may be registered to hear events from all AddonInstalls through AddonManager.addInstallListener() or to a single AddonInstall through AddonInstall.addListener(). Method Overview Methods onNewInstall() Called when a new instance of AddonInstall is created, primarily so UI can display some kind of progress for all installs. void onNewInstall( in AddonInstall install ) Parameters install The AddonInstall representing the install onDownloadStarted() Called when downloading begins for an add-on install. Void onDownloadStarted( in AddonInstall install ) onDownloadProgress() Called as data is received during a download. Void onDownloadProgress( in AddonInstall install ) onDownloadEnded() Called when downloading completes successfully for an add-on install.

Void onDownloadEnded( in AddonInstall install ) onDownloadCancelled() Called when downloading is cancelled. OnDownloadFailed() onInstallStarted() Code Samples - MDC. This article is in need of a technical review. Getting the directory where your add-on is located If you need to determine the directory in which your add-on is installed, code like the following will do the trick. Simply replace YOUREXTENSIONID with your add-on's ID. Components.utils.import(" AddonManager.getAddonByID("YOUREXTENSIONID", function(addon) { var addonLocation = addon.getResourceURI("").QueryInterface(Components.interfaces.nsIFileURL).file.path;}); Accessing file and version information Uninstall an add-on Components.utils.import(" AddonManager.getAddonByID("youraddon@youraddon.com", function(addon) { addon.uninstall();}); Disable an add-on Components.utils.import(" AddonManager.getAddonByID("youraddon@youraddon.com", function(addon) { if (addon.isActive) addon.userDisabled = addon.isActive;}); Listening for add-on uninstall.

UpdateListener - MDC. This article is in need of a technical review. An UpdateListener receives messages from an update check for a single add-on, though it is possible to pass the same UpdateListener to as many calls to Addon.findUpdates() as you like. For each individual update check, the following methods will be called on the listener: Method Overview Methods onCompatibilityUpdateAvailable() Called when the update check found compatibility information for the application and platform version that the update check was being performed for. void onCompatibilityUpdateAvailable( in Addon addon ) Parameters addon The Addon that was being checked for updates onNoCompatibilityUpdateAvailable() Called when the update check found no new compatibility information for the application and platform version that the update check was being performed for. void onNoCompatibilityUpdateAvailable( in Addon addon ) onUpdateAvailable() Called when a new version of an add-on has been found for install. install onNoUpdateAvailable() error.