Monday 11 July 2011

Making your add-ons compatible with Firefox 5 and 6

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.
  • 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).
  • XPCOM binary component registration no longer ignores Module::kVersion (Bug 656331).
  • 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.
Source:http://blog.mozilla.com/addons/ My themes have been automatic updated to work with Firefox 6 as well : ) 

Web Hosting



No comments:

Post a Comment