Making your add-ons compatible with Firefox 5 and 6

Update: moved bullet point about Bug 656331 from Firefox 6 section to Firefox 5. Thanks, Nils!

The new rapid release schedule for Firefox is in effect, and you can already get preview versions of Firefox 5 and Firefox 6 in the Beta and Aurora channels, respectively. Firefox 5 will most likely be released in a couple of weeks, and Firefox 6 should follow 6 weeks later.

Because of the fast-paced schedule, these new releases are less problematic for add-on developers given that they include very few compatibility-breaking changes. This post covers all known add-on compatibility issues with Firefox 5 and 6. If you have run into other issues and don’t see them mentioned here or documented anywhere else, please let us know.

We have already done an automatic compatibility upgrade to Firefox 5 for all add-ons that qualified for it, and we will do a similar upgrade for 6 sometime this week, maybe later today.

How do we select which add-ons to upgrade? They need to be compatible with the previous Firefox version, they must not have binary components (since they usually need to be rebuilt) and they need to pass special compatibility tests that we create based on the known breaking changes, which are listed below.

Firefox 5

  • The value of navigator.language no longer reflects the language of the Firefox UI (Bug 55366). To obtain the UI language you can use the general.useragent.locale preference instead.
  • The default behavior of setTimeout and setInterval when no wait time is set has changed (Bug 610077). If you set the timer to a very low value the actual wait time would be rounded to 10ms before. Now, that minimum has changed, and it depends on where the code is running.
  • A number of words are now reserved in JavaScript, even when not in strict mode (Bug 637204). The newly reserved words are class, enum, export, extends, import and super. You shouldn’t use these words anywhere in your code, even as object property names. Some add-ons that are affected by this might have been automatically upgraded to Firefox 5 compatibility, so please check your code and look for any errors during execution in Firefox 5.
  • Instantiating nsICertOverrideService (and perhaps others) at startup can make Firefox unusable (Bug 650858). We caught this one recently, and we’re still gauging its impact. The bug is only manifested if you try to instantiate a service before the load event. This is easy to avoid:

WRONG

var comp = Components.classes[...].getService(...);
var MyObject = {
  init: function() {},
  ...
}
window.addEventListener("load", function() { MyObject.init(); }, false);

WRONG

var MyObject = {
  comp : Components.classes[...].getService(...),
  init: function() {},
  ...
}
window.addEventListener("load", function() { MyObject.init(); }, false);

RIGHT

var MyObject = {
  comp : null,
  init: function() {
    this.comp = Components.classes[...].getService(...);
  },
  ...
}
window.addEventListener("load", function() { MyObject.init(); }, false);

Just don’t instantiate any components before the load event. Better yet, follow our performance best practices and don’t instantiate anything until it’s needed.

  • Mac OS SDK builds for the beta are missing (Bug 653971). This affects you if you build binary components for Mac OS. There are several bugs involved in this, but they are being tracked in this bug. It should be fixed within a few days.
  • XPCOM binary component registration no longer ignores Module::kVersion (Bug 656331).
  • More documented changes in Firefox 5 for developers.

Firefox 6

  • The app.update.timer preference was replaced by the app.update.timerMinimumDelay preference (Bug 614181).
  • A few interfaces (rarely) used in add-ons have been removed: IWeaveCrypto (Bug 651596), nsIDOMDocumentTraversal (Bug 655514) and nsIDOMDocumentRange (Bug 655513).
  • window.top is now read-only (Bug 654137). This affects your add-on if you use an undeclared variable called top in a chrome script.
  • javascript: and data: URLs entered into the location bar no longer inherit the principal of the currently-loaded page (Bug 656433). Maybe this won’t affect any add-ons, but there are many workarounds and odd pieces of code in the wild, so it’s better that you double check if you run any code using these types of URL.
  • New Web Developer Sub-menu in the Tools menu (Bug 653221). Because of all the new developer tools being included in Firefox, it was determined that it was best to group them in a sub-menu. This means that many overlays – those that rely on these menuitems being direct children of the Tools menu – will be affected. Your overlays will continue to work, but your items will most likely end up at the bottom of the menu instead of where you want them.
  • Reordering of the History menu (Bug 625322) and the Bookmarks menu (Bug 625325). This may affect your add-on if you overlay or work on those menus.
  • The clearUserPref method no longer throws if the pref doesn’t have a user value (Bug 487059).
  • Implement Site-Specific Privacy Preferences (Bug 573176). This should only affect add-ons that rely on certain preferences (privacy, remember passwords, and others) being in the main preferences window.
  • More documented changed in Firefox 6 for developers.

Once again, if there’s anything missing in these lists, please let us know. Thank you!

53 comments on “Making your add-ons compatible with Firefox 5 and 6”

  1. Tack wrote on

    Dear Lazyweb,

    My addon calls Components.utils.import(). Since import is now reserved, what has this function been renamed to? I looked (albeit cursorily) and couldn’t find anything in the docs.

    1. Jorge Villalobos wrote on

      You should be fine with that specific method. Lots of things would break if that didn’t work as expected. To elaborate: only a few of those reserved words can’t be used as member names (like super), but it’s simpler to say none of them can.

  2. Colby Russell wrote on

    So what are you supposed to do when your add-on has no binary components, doesn’t use any deprecated APIs, uses only overlays and XUL, and is verified to be still compatible with Firefox, but AMO didn’t automatically bump anything for you and won’t let you upload your new version after you’ve twiddled install.rdf? bug 363877

    1. Jorge Villalobos wrote on

      It’s probably best not to use the toolkit compatibility format for your AMO version, given that it isn’t fully supported on our site. This would fix pretty much every problem you mentioned.

      1. Colby Russell wrote on

        …and introduces the problem of being incompatible with… everything.

        To put it another way, there would no longer be a reason for the add-on to exist.

  3. Sean Kerner wrote on

    You should double check the auto-upgrade …it looks like it has failed on a bunch of add-ons. One specific case is for Sage (http://sagerss.com/blog/2011/05/sage-1-4-11-released/) which was auto-updated but still does not work for Firefox 5 or 6.

  4. Kohei Yoshino wrote on

    Japanese translation goes here:
    https://dev.mozilla.jp/2011/06/making-compatible-with-firefox-5-and-6/

    Jorge: please use , not , in the post properly :)

    1. Kohei wrote on

      (oh, tags are trimmed)

      I mean: please use <code> instead of <em>

      1. Jorge Villalobos wrote on

        I used “pre” actually, just because I was in a bit of a hurry when writing it and it wasn’t in the default format list. Sorry for the trouble.

  5. cfl wrote on

    For a few more compatibility-affecting changes in Firefox 6, see ‘Breaking Changes’ at
    http://www.oxymoronical.com/blog/2011/05/Creating-custom-add-on-types-just-got-easier

  6. Kohei Yoshino wrote on

    Where can we see the results of, or manually run your compatibility tests? I have not received any email from AMO and don’t know why my add-ons have not been bumped to 5.*.

    1. Jorge wrote on

      If your add-on was compatible with 4.0.* at the moment of the automatic run (May 20th), then you should have received an email explaining why it was or wasn’t bumped up. There were a few bugs in the system on this first run, so there’s a possibility that you never got the message. However, it’s best that you check your spam filters just in case.

      The only reasons we didn’t upgrade add-ons to 5.* were: 1) if they had any binary components, and 2) if they used navigator.language.

  7. error wrote on

    >Firefox 5 will most likely be released in a couple of weeks,
    > and Firefox 6 should follow 6 weeks later.
    O rly? I thought that FF5 was on a faster shedule, thus, 8 weeks later.

  8. Luckyrat wrote on

    My add-on (KeeFox) passed validation for Firefox 5 and 6 but fails to work in FF6 (a2). I get the following exception:
    setTransport failed: [Exception… “Not enough arguments [nsISocketTransport.isAlive]” nsresult: “0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)” …]

    This appears to be related to bug #654201 but the bug ends on a note of uncertainty regarding whether this change will remain in the final FF6 release and I can’t find any documentation that announces this API change. Any idea whether I should be passing in true or false?

    Does the automated FF6 upgrade test need to be updated to test for this API change?

    1. Jorge Villalobos wrote on

      Thank you for the notice, we’re investigating it. We’ll look into any uses of these interfaces, but I doubt that we’ll back out or re-run our automatic upgrade. Most likely we’ll notify all affected developers in person.

      Judging by the comment in the patch, you should be calling isAlive with the parameter set to true.

  9. Matthew Tuck wrote on

    My extension (Internote) was compatible with 4.0, and does not use navigator.language or binary components. As best as I can tell, I didn’t get any emails either.

    When is this second run with the bugs fixed occurring?

    1. Jorge Villalobos wrote on

      There won’t be a second run as far as I know. I recommend you test your add-on on Beta (5.0) and Aurora (6.0), and manually upgrade its compatibility on AMO if you don’t see any problems. Your add-on will only qualify for the 7.* bump if it’s compatible with 6.* at the moment we run the validation, which should happen in a couple of weeks.

  10. Nils Maier wrote on

    > Firefox 6
    > XPCOM binary component registration no longer ignores Module::kVersion (Bug 656331).

    Actually it already applies to Firefox 5 (which was Aurora back when this got checked in).

    1. Jorge Villalobos wrote on

      You are correct. I updated the article. Thanks!

  11. jophnston80 wrote on

    will you send Firefox 5.0 beta and Firefox 6.0 beta t-shirts to developers whose add-ons are compatible with the new versions?
    I am proud of having the Firefox 4.0 beta t-shirt, and would like to update my t-shirt too 🙂

    1. Jorge Villalobos wrote on

      I don’t think this will happen for Firefox 5, but maybe in the future. Having such a rapid release pace means that sending t-shirts for every one would be hard to manage.

  12. Kohei Yoshino wrote on

    I’ve noticed the following error in Firefox 5. This seems to be an undocumented change.

    gBrowser.addProgressListener was called with a second argument, which is not supported. See bug 608628.

    1. Jorge Villalobos wrote on

      My understanding of this error is that it only functions as a warning, and the second argument is ignored. That’s the reason it isn’t documented as a breaking change.

      1. Michael Kaply wrote on

        It should be documented because add-ons get denied AMO review if they write extraneous things to the console.

  13. Robert Smith wrote on

    Our jetpack extension is giving an NS_ERROR_NOT_AVAILABLE error on XMLHttpRequest.send in firefox 5, even after compiling with the latest jetpack SDK. Have there been any changes to cross-domain ajax security? I didn’t see any mention of such changes. We are doing the ajax request in the content-script of a page-mod module. It works fine on firefox 4.

    1. Jorge Villalobos wrote on

      We haven’t heard any reports of this. Can you send me a build of your add-on to give it a look? jorge AT mozilla DOT com.

      1. Robert Smith wrote on

        It’s ok I’ve solved the problem. The issue was that we were doing a cross-domain ajax request inside a jetpack content-script. This worked in FF4 but not in FF5. I’m not sure why it worked in FF4 because you shouldn’t be able to do cross-domain ajax calls in the context of a web page. The fix was just to modify the code to do the ajax call in the context of the add-on and send messages between the worker and the content script using port.on and port.emit. I’m guessing this is just a security issue that was plugged in FF5.

        1. GJ wrote on

          Hi Robert,

          I am running into the same problem. I am trying to do a AJAX query using Jquery from my content script and it returns nothing. It is not even a cross -domain Ajax request. You said you solved it by moving your Ajax call to the context of the add-on. I guess you mean you moved it to min.js. Are you able to use a library like Jquery in the add-on context?

  14. Jonathon Hill wrote on

    I have a self-hosted extension that only required tweaking the install.rdf file to be fully compatible with FF5. My extension installs and runs fine; however, if you install the extension into FF4, and then _upgrade_ to FF5, my extension is flagged during the install process as being incompatible!

    If I then uninstall the extension in FF5 and reinstall it, it works fine.

    I am using the following in install.rdf:

    <em:minVersion>3.6</em:minVersion>
    <em:maxVersion>5.0.*</em:maxVersion>

    Is this a bug in FF5, and is there anything I can do to work around it?

    1. Jorge Villalobos wrote on

      Firstly, the correct maxVersion should be 5.*, but I don’t think that’s the problem here. Is your extension hosted on AMO as well? Does it have an updateURL in install.rdf? If the add-on doesn’t have an updateURL, it checks with AMO for updates and metadata updates, so that could be the data that is overriding your compatibility info. That’s just a guess though. I can look into it if you send me an email.

      1. Jonathon Hill wrote on

        Thanks Jorge for the response. The extension is self-hosted, not on AMO, and there is an updateURL set. I will email you the details.

      2. Jonathon Hill wrote on

        Actually, browsing to the updateURL revealed the obvious cause – I forgot to update the maxVersion *there*. Thanks anyway!

  15. Keith wrote on

    Hi Jorge.

    I’m hesitant to download Firefox 5 to my home PC because when I did so on my work PC it rendered my Evernote add-on non-functional, and I can’t have that. I need my Evernote. Also, my Google bookmarks totally disappeared. I had created a long list of bookmarks very important to me and if it wasn’t for the fact that I’m still running the earlier version of Firefox on my home PC I would have lost all my bookmarks. When are these issues going to be resolved, because I really cannot afford to make the switch until I’m assured this won’t be a problem.

    1. Jorge Villalobos wrote on

      Evernote is already compatible. I don’t know about your “Google bookmarks”. If this is the Google toolbar you’re talking about, it’s currently incompatible. If you’re referring to a different add-on, please let me know and I’ll look into it.

  16. Stuart wrote on

    After upgrading to FF 5 and reinstalling my extension, my javascript code no longer finds the mimetype in the list…navigator.mimeTypes[]. The extension is an xpcom extension in c++ and has the chrome.manifest and install.rdf files included in the .xpi file.
    The extension is loaded using InstallTrigger.install and seems to be loaded correctly with no errors and shows up in the list under Tools/Add ons/Extensions.
    However, my code keeps trying to reload it, since the navigator.mimeTypes[] no longer has it. The mimetype is in the .rc file when building it using Visual Studio 8. FF4 did have the mimetype in the navigator.mimeTypes[] list.

    1. Jorge Villalobos wrote on

      Can you be more specific. What isn’t it finding in the mimetype list? Are you registering a plugin or something?

      1. Stuart wrote on

        Thanks for the quick response Jorge. Yes, I wrote (actually took over code) for a plugin that launches some webdav stuff when a link to a WORD document on our server is clicked. I had javascript code going through the navigator.mimeTypes[i].type list looking for “application/x-otbluefield” which is the mimetype of my installed plugin(extension) I wrote. Anyways, I changed the maxversion from 9.0 to 5.* in the install.rdf file and that seemed to do the trick. However, while it worked great in FF 3, it still seems that with the changes for FF4, the code in my DLL no longer gets called, so I must be missing something in the C++ code of the DLL. Will keep hunting. Again, thanks for the quick reply.

        1. Jorge Villalobos wrote on

          The changes to Firefox 4 were massive, yes. There’s a bunch of info about it on this blog, but nothing specific about plugins, IIRC.

  17. Rob_heri wrote on

    Too complex for me. I just use this http://classictutorials.com/2011/05/enable-incompatable-plugin-on-firefox-5-the-easiest-way/

  18. GISSELLE wrote on

    ANTES QUE NADA, GRAX POR EXISTIR, ME HAN FACILITADO LA VIDA!!!, JAAAAAAAAA
    QUIERO AGREGAR EL CONTROL ACTIVE X PARA ENTRAR Y PARTICIPAR A SALAS DE CHAT Y NO ENCUENTRO COMO, ADEMAS ESYOY BUSCANDO EL PLUYING Y NO LO ENCUENTRO, TAMPOCO LO ENCONTRE COMO COMPLEMENTO.
    PUES QUIERO ENTRAR A UNA SALA DE CHAT Y NO TUEDO
    MUCHAS GRAXXXXXXX
    BESITOS DE CHOKOLATE
    GISSE

    1. Jorge Villalobos wrote on

      Gisselle, las preguntas en español se pueden hacer en el foro de Mozilla Hispano: http://www.mozilla-hispano.org/foro/

  19. Paul wrote on

    I’ve been trying to get the xpcom example from the source tree working, and I keep ending up with a Components.classes[“@mozilla.org/sample;1”].name is undefined error in the Error Console. There wasn’t any error compiling the binary component at all. Any thoughts on what could be going on?

  20. eppie wrote on

    What I am strongly missing is that i can not use Google Startpage, because i use this often to automaticly translate another language site in my own language.
    That was very easy.
    Therefore I only use the older Firefox version 3.6.13.
    Unless there is no solution for my problem, I will only use version 3

    Greetings

    eppie

  21. wembley wrote on

    Is there any way of making Accessibar compatible with Firefox 5?

  22. Mike wrote on

    FireFox 6: Why does the Norton Tool bar not work. First time when I changed FF5 it was the same.

  23. PDT wrote on

    My plugins which are working on FF6 has stopped working on FF5. Why is that behavior? Is gecko 6.0 is not compatible with fFF5??

  24. Melissa wrote on

    Hi, firefox 6 won’t be compatible with avg safe search and I enjoy using avg. I’m wondering if this will be solved or if i have to change to another internet browser and which one should i choose. Before firefox I was using internet explorer btw.

  25. Mook wrote on

    This showed up recently for multiple people, so:

    The IID of nsIURI changed; this means that if you have any custom interfaces that derive from it (less likely) or use it as a parameter / attribute (much more likely), you will need to rebuild the xpt in order for it to work. Otherwise you get a confusing XPConnect error when you use it from JS (I think nothing happens if you’re in a binary component, other than potentially crashing).

  26. Robert Bruce wrote on

    I started with Firefox 6 and then downgraded to Version. 5 in order to get (cache viewer plug-in), but it was also incompatible with Version. 5. also. Where do I go from here. As i was downloading version 5 I was getting popups telling me, i was downloading an outdated version of Firefox, now I realize that i can no longer drop and drag files from the temporary internet file to a different folder. I’m ready to go back to IE and put up with their non-sense. Bottom line , IS THERE A FIREFOX THAT WORKS WITH ALL THE PLUG IN’S Wow there’s a drop and drag plug-in.

    one of my favorite saying is DO IT RIGHT THE FIRST TIME, yeah, I know, that’s to simple and would put a lot of people out of work..

  27. David wrote on

    In the future could we have a list of the breaking changes for Addon-SDK developers? Thanks.

    1. Jorge Villalobos wrote on

      That’s a good idea, David. However, your breaking changes are dependent on the version of the Add-on SDK, which changes independently from the Firefox version. Theoretically there shouldn’t be any breaking changes, but I’m sure they happen on occasion.

      SDK releases are announced on this same blog, so I recommend that you use their channels to ask questions about new versions and compatibility. Unfortunately I’m still not very well versed in this platform, so I can’t help you as much.

  28. jay wrote on

    i have problem with mozila browser version 3.5 and above my site is not compatibal so, what to do ?
    its running with mozilla 3.0.

    1. Jorge Villalobos wrote on

      Can you please clarify what you mean? What doesn’t work?