Add-ons Manager API: Change in event order when restartless extensions are installed

Over in bug 727398 I’m planning on making a change to restartless extensions that could potentially affect addon authors who use the Add-ons Manager API. This only affects code that registers a AddonListener or InstallListener event listener to get notified of add-on and install events, while also interacting with the startup of restartless extensions. I couldn’t find any add-ons on AMO that would be affected by this, but I thought it would be worth blogging about anyway.

Currently, when a restartless extension is installed, it’s startup() function is called before the onInstalled and onInstallEnded events are fired. This meant that a restartless extension would run it’s initialization code before anything else thought it was installed.

However, that causes some issues. For example, if a restartless extension uninstalled itself on startup[1], then it could be uninstalled before it was installed. Unsurprisingly, the Add-ons Manager UI broke when this happened (since it uses the same APIs that add-ons use).

So bug 727398 will change the order of those operations. When a restartless extension installs, the following will happen in this order:

  1. The extension’s install() method will be called
  2. onInstalled event will fire (AddonListener)
  3. onInstallEnded event will fire (InstallListener)
  4. The extension’s┬ástartup() method will be called

 

Update: This change will ship in Firefox update 14, which is scheduled to be released on 2012-07-17.

 

[1] Why would an addon immediately uninstall itself, you ask? Imagine an add-on whose sole purpose was to flip a preference to disable a newly-shipped but buggy feature, that would get re-enabled on the next application update. This is one of the things that a hotfix add-on could do. Additionally, I’ve been playing with various ideas for restartless extensions as a user support tool – the extension installs, does some work or collects some diagnostic data, then immediately removes itself.

One thought on “Add-ons Manager API: Change in event order when restartless extensions are installed

Comments are closed.