Updating extensions for Firefox 3

  • Revision slug: Updating_extensions_for_Firefox_3
  • Revision title: Updating extensions for Firefox 3
  • Revision id: 114713
  • Created:
  • Creator: Ikonst
  • Is current revision? No
  • Comment 114 words removed

Revision Content

{{ Fx_minversion_header("3") }} This article provides information that will be useful to developers that wish to update their extensions to work properly under Firefox 3.

Before going further, there's one helpful hint we can offer: if the only change your extension requires is a bump to the maxVersion field in its install manifest, and you host your extension at addons.mozilla.org, you don't actually need to upload a new version of your extension! Simply use the Developer Control Panel at AMO to adjust the maxVersion. You can avoid having to have your extension re-reviewed this way.

Step 1: Update the install manifest

The first step -- and, for most extensions, the only one that will be needed -- is to update the install manifest file, install.rdf, to indicate compatibility with Firefox 3.

Simply find the line indicating the maximum compatible version of Firefox (which, for Firefox 2, might look like this):

 <em:maxVersion>2.0.*</em:maxVersion>

Change it to indicate compatibility with Firefox 3:

 <em:maxVersion>3.0.*</em:maxVersion> 

Then reinstall your extension.

Note that Firefox 3 does away with the extra ".0" in the version number, so instead of using "3.0.0.*, you only need to use "3.0.*".

There have been (and will continue to be) a number of API changes that will likely break some extensions. We're still working on compiling a complete list of these changes.

{{ Note("If your extension still uses an Install.js script instead of an install manifest, you need to make the transition to an install manifest now. Firefox 3 no longer supports install.js scripts in XPI files.") }}

Add localizations to the install manifest

Firefox 3 supports new properties in the install manifest to specify localized descriptions. The old methods still work however the new allow Firefox to pick up the localizations even when the add-on is disabled and pending install. See Localizing extension descriptions for more details.

Step 2: Ensure you are providing secure updates

If you are hosting addons yourself and not on a secure add-on hosting provider like addons.mozilla.org then you must provide a secure method of updating your add-on. This will either involve hosting your updates on an SSL website, or using cryptographic keys to sign the update information. Read Securing Updates for more information.

Step 3: Deal with changed APIs

Several APIs have been changed in significant ways. The most significant of these, which will likely affect a large number of extensions, are:

DOM

{{ :en/DOM/WRONG_DOCUMENT_ERR_note() }}

Bookmarks & History

If your extension accesses bookmark or history data in any way, it will need substantial work to be compatible with Firefox 3. The old APIs for accessing this information have been replaced by the new Places architecture. See the Places migration guide for details on updating your existing extension to use the Places API.

Download Manager

The Download Manager API has changed slightly due to the transition from an RDF data store to using the Storage API. This should be a pretty easy transition to make. In addition, the API for monitoring download progress has changed to support multiple download manager listeners. See {{ Interface("nsIDownloadManager") }}, {{ Interface("nsIDownloadProgressListener") }}, and Monitoring downloads for more information.

Password Manager

If your extension accesses user login information using the Password Manager, it will need to be updated to use the new Login Manager API.

  • The article Using nsILoginManager includes examples, including a demonstration of how to write your extension to work with both the Password Manager and the Login Manager, so it will work with both Firefox 3 and earlier versions.
  • nsILoginInfo
  • nsILoginManager

You can also override the built-in password manager storage if you want to provide your own password storage implementation in your extensions. See Creating a Login Manager storage module for details.

Popups (Menus, Context Menus, Tooltips and Panels)

The XUL Popup system was heavily modified in Firefox 3. The Popup system includes main menus, context menus and popup panels. A guide to using Popups has been created, detailing how the system works. One thing to note is that popup.{{ XULMeth("showPopup") }} has been deprecated in favor of new popup.{{ XULMeth("openPopup") }} and popup.{{ XULMeth("openPopupAtScreen") }}.

Autocomplete

The {{ Interface("nsIAutoCompleteController") }} interface's handleEnter() method has been changed to accept an argument that indicates whether the text was selected from the autocomplete popup or by the user pressing enter after typing text.

DOMParser

  • When a DOMParser is instantiated, it inherits the calling code's principal and the documentURI and baseURI of the window the constructor came from.
  • If the caller has UniversalXPConnect privileges, it can pass parameters to new DOMParser(). If fewer than three parameters are passed, the remaining parameters will default to null.
    • The first parameter is the principal to use; this overrides the default principal normally inherited.
    • The second parameter is the documentURI to use.
    • The third parameter is the baseURI to use.
  • If you initialize a DOMParser using a contract, such as by calling createInstance(), and you don't call the DOMParser's init() method, attempting to initiate a parsing operation will automatically create and initialize the DOMParser with a null principal and null pointers for documentURI and baseURI.

Removed interfaces

The following interfaces were removed from Gecko 1.9, which drives Firefox 3. If your extension makes use of any of these, you'll need to update your code:

  • nsIDOMPaintListener
  • nsIDOMScrollListener
  • nsIDOMMutationListener
  • nsIDOMPageTransitionListener
  • nsICloseAllWindows (see {{ Bug("386200") }})

Step 4: Check for relevant chrome changes

There has been a minor change to the chrome that may require changes in your code. A new vbox has been added, called "browser-bottombox", which encloses the find bar and status bar at the bottom of the browser window. Although this doesn't affect the appearance of the display, it may affect your extension if it overlays chrome relative to these elements.

For example, if you previously overlaid some chrome before the status bar, like this:

<window id="main-window">
  <something insertbefore="status-bar" />
</window>

You should now overlay it like this:

<vbox id="browser-bottombox">
  <something insertbefore="status-bar" />
</vbox>

Or use the following technique to make your overlay work on both Firefox 2 and Firefox 3:

<window id="main-window">
  <vbox id="browser-bottombox" insertbefore="status-bar">
    <something insertbefore="status-bar" />
  </vbox>
</window>

Other changes

Add simple changes you had to make while updating your extension to work with Firefox 3 here.

  • chrome://browser/base/utilityOverlay.js is no longer supported for security reasons. If you were previously using this, you should switch to chrome://browser/content/utilityOverlay.js.
  • {{ Interface("nsIAboutModule") }} implementations are now required to support the getURIFlags method. See {{ Source("netwerk/protocol/about/public/nsIAboutModule.idl", "nsIAboutModule.idl") }} for documentation. This affects extensions that provide new about: URIs. ({{ Bug("337746") }})
  • The {{ XULElem("tabbrowser") }} element is no longer part of "toolkit" ({{ Bug("339964") }}). This means this element is no longer available to XUL applications and extensions. It continues to be used in the main Firefox window (browser.xul).
  • Changes to nsISupports proxies and possibly to threading-related interfaces need to be documented.
  • If you use XML processing instructions, such as <?xml-stylesheet ?> in your XUL files, be aware of the changes made in {{ Bug("319654") }}:
    1. XML PIs are now added to a XUL document's DOM. This means {{ Domxref("document.firstChild") }} is no longer guaranteed to be the root element. If you need to get the root document in your script, use {{ Domxref("document.documentElement") }} instead.
    2. <?xml-stylesheet ?> and <?xul-overlay ?> processing instructions now have no effect outside the document prolog.
  • window.addEventListener("load", myFunc, true) is not fired when loading web content (browser page loads). This is due to {{ Bug("296639") }} which changes the way inner and outer windows communicate. The simple fix here is to use gBrowser.addEventListener("load", myFunc, true) as described here and works in Firefox 2 as well.
  • content.window.getSelection() gives an object (which can be converted to a string by toString()), unlike the now deprecated content.document.getSelection() which returns a string
  • event.preventBubble() was deprecated in Firefox 2 and has been removed in Firefox 3. Use event.stopPropagation(), which works in Firefox 2 as well.
  • Timers that are initiated using setTimeout() are now blocked by modal windows due to the fix made for {{ Bug("52209") }}. You may use {{ Interface("nsITimer") }} instead.
  • If your extension needs to allow an untrusted source (e.g., a web site) to access the extension's chrome, then you must use the new contentaccessible flag.

{{ languages( { "fr": "fr/Mise_\u00e0_jour_des_extensions_pour_Firefox_3", "ja": "ja/Updating_extensions_for_Firefox_3", "pl": "pl/Aktualizacja_rozszerze\u0144_dla_Firefoksa_3", "ko": "ko/Updating_extensions_for_Firefox_3", "es": "es/Actualizar_extensiones_para_Firefox_3" } ) }}

Revision Source

<p>{{ Fx_minversion_header("3") }} This article provides information that will be useful to developers that wish to update their extensions to work properly under Firefox 3.</p>
<p>Before going further, there's one helpful hint we can offer: if the only change your extension requires is a bump to the <code>maxVersion</code> field in its install manifest, and you host your extension at <a class="link-https" href="https://addons.mozilla.org">addons.mozilla.org</a>, you don't actually need to upload a new version of your extension! Simply use the Developer Control Panel at AMO to adjust the <code>maxVersion</code>. You can avoid having to have your extension re-reviewed this way.</p>
<h3 name="Step_1:_Update_the_install_manifest">Step 1: Update the install manifest</h3>
<p>The first step -- and, for most extensions, the only one that will be needed -- is to update the <a href="/en/Install_Manifests" title="en/Install_Manifests">install manifest</a> file, <a class="internal" href="/en" title="En"><code>install.rdf</code></a>, to indicate compatibility with Firefox 3.</p>
<p>Simply find the line indicating the maximum compatible version of Firefox (which, for Firefox 2, might look like this):</p>
<pre class="eval"> <span class="nowiki">&lt;em:maxVersion&gt;2.0.*&lt;/em:maxVersion&gt;</span>
</pre>
<p>Change it to indicate compatibility with Firefox 3:</p>
<pre class="eval"> <a class="internal" href="/%3Cem:maxVersion%3E3.0.*%3C/em:maxVersion%3E" title="&lt;em:maxVersion>3.0.*&lt;/em:maxVersion> "><span class="nowiki">&lt;em:maxVersion&gt;3.0.*&lt;/em:maxVersion&gt;</span></a> </pre>
<p>Then reinstall your extension.</p>
<p>Note that Firefox 3 does away with the extra ".0" in the version number, so instead of using "3.0.0.*, you only need to use "3.0.*".</p>
<p>There have been (and will continue to be) a number of API changes that will likely break some extensions. We're still working on compiling a complete list of these changes.</p>
<p>{{ Note("If your extension still uses an <code><a href='\"en/Install.js\"'>Install.js</a></code> script instead of an <a href='\"en/Install_Manifests\"'>install manifest</a>, you need to make the transition to an install manifest now. Firefox 3 no longer supports <code>install.js</code> scripts in XPI files.") }}</p>
<h4 name="Add_localizations_to_the_install_manifest">Add localizations to the install manifest</h4>
<p>Firefox 3 supports new properties in the install manifest to specify localized descriptions. The old methods still work however the new allow Firefox to pick up the localizations even when the add-on is disabled and pending install. See <a href="/en/Localizing_extension_descriptions" title="en/Localizing_extension_descriptions">Localizing extension descriptions</a> for more details.</p>
<h3 name="Step_2:_Ensure_you_are_providing_secure_updates">Step 2: Ensure you are providing secure updates</h3>
<p>If you are hosting addons yourself and not on a secure add-on hosting provider like <a class="link-https" href="https://addons.mozilla.org">addons.mozilla.org</a> then you must provide a secure method of updating your add-on. This will either involve hosting your updates on an SSL website, or using cryptographic keys to sign the update information. Read <a href="/en/Extension_Versioning,_Update_and_Compatibility#Securing_Updates" title="en/Extension_Versioning,_Update_and_Compatibility#Securing_Updates">Securing Updates</a> for more information.</p>
<h3 name="Step_3:_Deal_with_changed_APIs">Step 3: Deal with changed APIs</h3>
<p>Several APIs have been changed in significant ways. The most significant of these, which will likely affect a large number of extensions, are:</p>
<h4 name="DOM">DOM</h4>
<p>{{ :en/DOM/WRONG_DOCUMENT_ERR_note() }}</p>
<h4 name="Bookmarks_&amp;_History">Bookmarks &amp; History</h4>
<p>If your extension accesses bookmark or history data in any way, it will need substantial work to be compatible with Firefox 3. The old APIs for accessing this information have been replaced by the new <a href="/en/Places" title="en/Places">Places</a> architecture. See the <a href="/en/Places_migration_guide" title="en/Places_migration_guide">Places migration guide</a> for details on updating your existing extension to use the Places API.</p>
<h4 name="Download_Manager">Download Manager</h4>
<p>The Download Manager API has changed slightly due to the transition from an RDF data store to using the <a href="/en/Storage" title="en/Storage">Storage</a> API. This should be a pretty easy transition to make. In addition, the API for monitoring download progress has changed to support multiple download manager listeners. See {{ Interface("nsIDownloadManager") }}, {{ Interface("nsIDownloadProgressListener") }}, and <a href="/en/Monitoring_downloads" title="en/Monitoring_downloads">Monitoring downloads</a> for more information.</p>
<h4 name="Password_Manager">Password Manager</h4>
<p>If your extension accesses user login information using the Password Manager, it will need to be updated to use the new Login Manager API.</p>
<ul> <li>The article <a href="/en/Using_nsILoginManager" title="en/Using_nsILoginManager">Using nsILoginManager</a> includes examples, including a demonstration of how to write your extension to work with both the Password Manager and the Login Manager, so it will work with both Firefox 3 and earlier versions.</li> <li><code><a href="/en/nsILoginInfo" title="en/nsILoginInfo">nsILoginInfo</a></code></li> <li><code><a href="/en/nsILoginManager" title="en/nsILoginManager">nsILoginManager</a></code></li>
</ul>
<p>You can also override the built-in password manager storage if you want to provide your own password storage implementation in your extensions. See <a href="/en/Creating_a_Login_Manager_storage_module" title="en/Creating_a_Login_Manager_storage_module">Creating a Login Manager storage module</a> for details.</p>
<h4 name="Popups_.28Menus.2C_Context_Menus.2C_Tooltips_and_Panels.29">Popups (Menus, Context Menus, Tooltips and Panels)</h4>
<p>The XUL Popup system was heavily modified in Firefox 3. The Popup system includes main menus, context menus and popup panels. A guide to <a href="/en/XUL/PopupGuide" title="en/XUL/PopupGuide">using Popups</a> has been created, detailing how the system works. One thing to note is that <code>popup.{{ XULMeth("showPopup") }}</code> has been deprecated in favor of new <code>popup.{{ XULMeth("openPopup") }}</code> and <code>popup.{{ XULMeth("openPopupAtScreen") }}</code>.</p>
<h4 name="Autocomplete">Autocomplete</h4>
<p>The {{ Interface("nsIAutoCompleteController") }} interface's <code><a href="/en/nsIAutoCompleteController#handleEnter.28.29" title="en/nsIAutoCompleteController#handleEnter.28.29">handleEnter()</a></code> method has been changed to accept an argument that indicates whether the text was selected from the autocomplete popup or by the user pressing enter after typing text.</p>
<h4 name="DOMParser">DOMParser</h4>
<ul> <li>When a <code>DOMParser</code> is instantiated, it inherits the calling code's principal and the <code>documentURI</code> and <code>baseURI</code> of the window the constructor came from.</li> <li>If the caller has UniversalXPConnect privileges, it can pass parameters to <code>new DOMParser()</code>. If fewer than three parameters are passed, the remaining parameters will default to <code>null</code>. <ul> <li>The first parameter is the principal to use; this overrides the default principal normally inherited.</li> <li>The second parameter is the <code>documentURI</code> to use.</li> <li>The third parameter is the <code>baseURI</code> to use.</li> </ul> </li> <li>If you initialize a <code>DOMParser</code> using a contract, such as by calling <code>createInstance()</code>, and you don't call the <code>DOMParser</code>'s <code>init()</code> method, attempting to initiate a parsing operation will automatically create and initialize the <code>DOMParser</code> with a null principal and <code>null</code> pointers for <code>documentURI</code> and <code>baseURI</code>.</li>
</ul>
<h4 name="Removed_interfaces">Removed interfaces</h4>
<p>The following interfaces were removed from Gecko 1.9, which drives Firefox 3. If your extension makes use of any of these, you'll need to update your code:</p>
<ul> <li><code>nsIDOMPaintListener</code></li> <li><code>nsIDOMScrollListener</code></li> <li><code>nsIDOMMutationListener</code></li> <li><code>nsIDOMPageTransitionListener</code></li> <li><code>nsICloseAllWindows</code> (see {{ Bug("386200") }})</li>
</ul>
<h3 name="Step_4:_Check_for_relevant_chrome_changes">Step 4: Check for relevant chrome changes</h3>
<p>There has been a minor change to the chrome that may require changes in your code. A new <code>vbox</code> has been added, called "browser-bottombox", which encloses the find bar and status bar at the bottom of the browser window. Although this doesn't affect the appearance of the display, it may affect your extension if it overlays chrome relative to these elements.</p>
<p>For example, if you previously overlaid some chrome before the status bar, like this:</p>
<pre>&lt;window id="main-window"&gt;
  &lt;something insertbefore="status-bar" /&gt;
&lt;/window&gt;
</pre>
<p>You should now overlay it like this:</p>
<pre>&lt;vbox id="browser-bottombox"&gt;
  &lt;something insertbefore="status-bar" /&gt;
&lt;/vbox&gt;
</pre>
<p>Or use the following technique to make your overlay work on both Firefox 2 and Firefox 3:</p>
<pre>&lt;window id="main-window"&gt;
  &lt;vbox id="browser-bottombox" insertbefore="status-bar"&gt;
    &lt;something insertbefore="status-bar" /&gt;
  &lt;/vbox&gt;
&lt;/window&gt;
</pre>
<h3 name="Other_changes">Other changes</h3>
<p><em>Add simple changes you had to make while updating your extension to work with Firefox 3 here.</em></p>
<ul> <li><code><a class=" external" href="chrome://browser/base/utilityOverlay.js" rel="freelink">chrome://browser/base/utilityOverlay.js</a></code> is no longer supported for security reasons. If you were previously using this, you should switch to <code><a class=" external" href="chrome://browser/content/utilityOverlay.js" rel="freelink">chrome://browser/content/utilityOverlay.js</a></code>.</li> <li>{{ Interface("nsIAboutModule") }} implementations are now required to support the <code>getURIFlags</code> method. See {{ Source("netwerk/protocol/about/public/nsIAboutModule.idl", "nsIAboutModule.idl") }} for documentation. This affects extensions that provide new <code>about:</code> URIs. ({{ Bug("337746") }})</li> <li>The {{ XULElem("tabbrowser") }} element is no longer part of "toolkit" ({{ Bug("339964") }}). This means this element is no longer available to XUL applications and extensions. It continues to be used in the main Firefox window (browser.xul).</li> <li>Changes to <a href="/en/nsISupports_proxies" title="en/nsISupports_proxies">nsISupports proxies</a> <a class="external" href="http://groups.google.com/group/mozilla.dev.platform/browse_thread/thread/78236a4b312a2de4/939240fc3f5123a8?lnk=st&amp;rnum=1#939240fc3f5123a8"></a> and possibly to threading-related interfaces need to be documented.</li> <li>If you use XML processing instructions, such as <code>&lt;?xml-stylesheet ?&gt;</code> in your XUL files, be aware of the changes made in {{ Bug("319654") }}: <ol> <li>XML PIs are now added to a XUL document's DOM. This means {{ Domxref("document.firstChild") }} is no longer guaranteed to be the root element. If you need to get the root document in your script, use {{ Domxref("document.documentElement") }} instead.</li> <li><code>&lt;?xml-stylesheet ?&gt;</code> and <code>&lt;?xul-overlay ?&gt;</code> processing instructions now have no effect outside the document prolog.</li> </ol> </li> <li><code>window.addEventListener("load", myFunc, true)</code> is not fired when loading web content (browser page loads). This is due to {{ Bug("296639") }} which changes the way inner and outer windows communicate. The simple fix here is to use <code>gBrowser.addEventListener("load", myFunc, true)</code> as described <a href="/en/Code_snippets/Tabbed_browser#Detecting_page_load" title="en/Code_snippets/Tabbed_browser#Detecting_page_load">here</a> and works in Firefox 2 as well.</li> <li><code>content.window.getSelection()</code> gives an object (which can be converted to a string by <code>toString()</code>), unlike the now deprecated <code>content.document.getSelection()</code> which returns a string</li> <li><code>event.preventBubble()</code> was deprecated in Firefox 2 and has been removed in Firefox 3. Use <a href="/en/DOM/event.stopPropagation" title="en/DOM/event.stopPropagation"><code>event.stopPropagation()</code></a>, which works in Firefox 2 as well.</li> <li>Timers that are initiated using <code>setTimeout()</code> are now blocked by modal windows due to the fix made for {{ Bug("52209") }}. You may use {{ Interface("nsITimer") }} instead.</li> <li>If your extension needs to allow an untrusted source (e.g., a web site) to access the extension's chrome, then you must use the new <a href="/en/Chrome_Registration#contentaccessible" title="en/Chrome_Registration#contentaccessible"><code>contentaccessible</code> flag</a>.</li>
</ul>

<p>{{ languages( { "fr": "fr/Mise_\u00e0_jour_des_extensions_pour_Firefox_3", "ja": "ja/Updating_extensions_for_Firefox_3", "pl": "pl/Aktualizacja_rozszerze\u0144_dla_Firefoksa_3", "ko": "ko/Updating_extensions_for_Firefox_3", "es": "es/Actualizar_extensiones_para_Firefox_3" } ) }}</p>
Revert to this revision