Updating an extension to support multiple Mozilla applications

This article shows how to take an existing extension and update it so that it can be used in additional Mozilla applications. We'll build upon the stock watcher extension created in earlier articles in this series, updating it so it can also be used in Thunderbird and Sunbird (previous versions worked only in Firefox).

If you haven't already created an extension, or would like to refresh your memory, take a look at the previous articles in this series:

Download the sample

You can download this article's sample code so you can look at it side-by-side with the article, or to use it as a basis for your own extension.

Updating the install manifest

The first step is to revise the extension's install manifest to indicate that it can be installed in Thunderbird and Sunbird. This is done by adding new <targetApplication> tags to the install.rdf file, like this:

    <!-- Describe the Thunderbird versions we support -->

    <!-- Describe the Sunbird versions we support -->
        <em:id>	{718e30fb-e89b-41dd-9da7-e25a45638b28}</em:id>

These two blocks indicate that the extension supports Thunderbird versions 1.5 through 2.0.0.x, Sunbird versions 0.2 through 0.4.x.

After inserting this code, you can successfully install the extension into any (or all) of Firefox, Thunderbird, and Sunbird, but you won't see any effect in Thunderbird and Sunbird.

That's because there's nothing telling those two applications what to do with the chrome provided by the extension. That's where the chrome manifest comes into play.

Update the chrome manifest

Remember way back in the first article in this series when we created our chrome manifest, which we haven't touched since? It's time to touch it. As you may (or may not) recall, that file tells the application what XUL code your extension's interface needs to overlay onto.

For Firefox, we overlaid onto browser.xul, which describes a Firefox browser window. We need to add lines to the manifest for Thunderbird and Sunbird, like this:

# Thunderbird
overlay chrome://messenger/content/messenger.xul chrome://stockwatcher2/content/stockwatcher2.xul

# Sunbird

overlay chrome://calendar/content/calendar.xul chrome://stockwatcher2/content/stockwatcher2.xul

These lines cause the main Thunderbird message list window and the main window in Sunbird to be the target of the overlays we apply in the stockwatcher2.xul file.

With these simple tweaks, this extension will work in all three of these applications, and works exactly the same way in them all.

Document Tags and Contributors

 Contributors to this page: trevorh, Sheppy, Nickolay
 Last updated by: trevorh,