Extending Firefox and Thunderbird
Written by Mike James   
Saturday, 20 June 2009
Article Index
Extending Firefox and Thunderbird
Getting started
Hello Toolbar
Trying it out

Trying it out

All that remains is to try it all out. When you have finished your extension you distribute it for installation as an XPI file. To create this you zip all of the directories that were created by the Wizard into a single HelloWorld.zip file - like the one you downloaded - and then change the file's extension to .xpi. This can then be loaded by Firefox either locally or from a web page and it automatically installs the extension using all of information in the XPI file.
This works well but it's a bit time consuming when you are testing an extension to have to keep on creating a zip file and renaming it each time you make any changes. To allow for development work Firefox will load an un-zipped extension directly from the development folders. All you have to do is place a text file containing the path to the development directory, the Firefox extensions directory. The first problem is finding the extensions directory. It is generally in:

C:\Documents and Settings\
User name\
Application Data\
some unique letters.default\

The file that you store in the extensions directory has to be named using the unique name that you supplied to identify the extension, i.e. helloworld@mike.james in this case. Of course if you supplied a different unique name for your extension then use it. Simply open NotePad type in the path to the helloworld directory, i.e. the directory that contains the files chrome.manifest and install.rdf among others and save it as helloworld@mike.james. (Tip: to save a file that doesn't end in .txt using NotePad surround the entire name in double quotes.)
Once you have saved the file in the appropriate directory restart FireFox - i.e. close all FireFox windows down and then open the application again. If your extension has been loaded properly you should see it in the Add-ons manager which can be opened using the menu command Tools,Add-ons. If you can't see it listed then either you haven't restarted FireFox completely, or the file specifying its path is in the wrong directory, or the path it specifies is incorrect. If you see your extension listed but there is an error message then there is something wrong with the installation files. Generally however an extension will load even if you have errors in the XUL or JavaScript file. However XUL or JavaScript files that have syntax errors will not be loaded even if it looks as if your extension has been loaded without problems. This can result in an extension that looks as if it should do something but when you try to use it - nothing much happens. You can check to see if the XUL and JavaScript files have loaded using the script debugger - see later.

The Hello World extension has been loaded!

As long as the extension has been loaded you can try it out. If you click on the Tools menu you should see the new "helloworld" menu item. Clicking on it should produce the Alert dialog box with the familiar message displayed.

The extension in action

Last Updated ( Saturday, 27 June 2009 )