Convert legacy bootstrapped extension to legacy WebExtension
Switch to JSON manifest
You must switch from an RDF manifest (install.rdf) to a JSON manifest (manifest.json). Here is a basic example. This RDF manifest:
<?xml version="1.0" encoding="utf-8"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:type>2</em:type>
<em:bootstrap>true</em:bootstrap>
<em:name>Extension</em:name>
<em:description>Does a thing!</em:description>
<em:version>1.0</em:version>
<em:optionsURL>chrome://myextension/content/options.xul</em:optionsURL>
<em:optionsType>3</em:optionsType><!-- Options in a tab -->
<em:iconURL>chrome://myextension/content/icon32x32.png</em:iconURL>
<em:targetApplication>
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>60.0</em:minVersion>
<em:maxVersion>60.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>Becomes this JSON manifest:
Detailed information about the possible config options for manifest.json can be found in the MDN documentation.
The legacy key enables Thunderbird’s legacy WebExtenion support, for bootstrap extension you have to set the type key to bootstrap.
The URL for icons must no longer be full chrome URL as before, but a simple path relative to the root directory of the add-on.
The shown example also specifies an optional options key to define the options page. The key open_in_tab is optional and defaults to a value offalse. If your old RDF manifest included an em:optionsType of 3, you can set open_in_tab to true, to have your options opened again in a new tab instead of a new window.
Possible timing issues
The changes made in Thunderbird for bootstrapped add-ons to use manifest.json may have changed when your code runs relative to events or notifications you've been listening for.
Use the window mediator or window watcher services to be notified about opening and closing windows, rather than listening for notifications.
Wherever you access a window, always check if it has been completely loaded (
document.readyState == "complete"), or otherwise, wait for the load event.
In the following example, loadIntoWindow is waiting for the window to be fully loaded and eventually calls loadIntoWindowAfterWindowIsReady to actually do something with it. There is no need to listen to any other load events outside of loadIntoWindow. This example also checks the state of already open windows during startup (line 14).
So you basically have to rename your current loadIntoWindow to loadIntoWindowAfterWindowIsReady and add the new asynchronous loadIntoWindow , to make sure to access the window only after it has been fully loaded.
Last updated
Was this helpful?

