Mozilla Add-On Manager Version Difficulties



While developing the Firefox add-on we ran into a bit of a snag. Our API requires that the user-agent begin with for analytics, random-hit spam prevention, and the ability to handle any future version conflicts. This requires gathering the add-on’s version number, which is specified in install.rdf.

The problem arose when testing Gecko 2 browsers such as Firefox 4, which features a spiffy new add-on manager.


The solution was rather simple but a little difficult to track down at first, so I’ve included it here for convenience:

The difference is minor but important. The code in try is for Gecko \< 2, which grabs the extension manager from Components.classes. In Gecko > 2, the add-on manager is imported. Once you have the add-on manager object, obtaining the version is trivial.

Relatedly, we had to have the line for initializing the Charlifter (legacy name for Lifter object in both places because the version number is needed immediately upon initialization for a language list call, which the callback style of Gecko 2’s add-on manager interferes with.

← all posts

michael schade

I built out engineering and operations teams at Stripe as employee #20 from 2012 to 2019; now I'm working on something new. I like helping people, photography, reading, gym, traveling, and learning new things. Say hi! 🏳️‍🌈