Reverting preferences when extension is disabled (XUL)

Talk about add-ons and extension development.
Posts: 181
Joined: January 20th, 2015, 12:29 pm

Post Posted February 21st, 2017, 8:41 am

What's the best way to revert an about:config preference to its initial value when an XUL overlay extension is disabled or uninstalled? (It's an extension for SeaMonkey only which is why I'm not using WebExtensions.)

Posts: 3660
Joined: September 15th, 2010, 9:03 am

Post Posted February 21st, 2017, 9:59 am

Are you talking about an application preference or an addon preference? It would be difficult to know whether an application preference is set to a non-default value because of the addon or not, hence questionable whether it should be set back to a default value when the addon is disabled. For preferences specific to the addon, it isn't really necessary to set them back to their default values, although it might be nice to tidy up.

For the technical details, you would use an AddonListener to receive notifications including when the addon is (about to be) disabled. Then you can do what you need to do. Make sure you use onDisabling(), not onDisabled(), or you won't be called until after the addon has been disabled - ie. never.

Posts: 181
Joined: January 20th, 2015, 12:29 pm

Post Posted February 21st, 2017, 11:00 am


This is one of the guidelines (my add-on was denied because of it):
Modifications to internal Firefox preferences need to be reverted to the previous value when the add-on gets uninstalled or disabled.

I'm not going to complain, it makes sense. I just gotta figure out how to do it.

Also, I'm trying to rewrite the add-on to use an XPCOM component written in JavaScript, but I'm having some problems with the component's preference listener seeming to stop working after I open the browser toolbox. EDIT: never mind - found an exception that wasn't being logged until I imported resource://gre/modules/Console.jsm.

Return to Extension Development

Who is online

Users browsing this forum: No registered users and 2 guests