In the uninstall
part of my bootstrapped addons I do some important stuff. I delete any files it created and all preferences. However this uses some services.
This is an example of one of my uninstall
procedures:
function uninstall(aData, aReason) {
if (aReason == ADDON_UNINSTALL) { //have to put this here because uninstall fires on upgrade/downgrade too
//this is real uninstall
Cu.import('resource://gre/modules/Services.jsm');
Cu.import('resource://gre/modules/devtools/Console.jsm');
Cu.import('resource://gre/modules/osfile.jsm');
//if custom images were used lets delete them now
var customImgPrefs = ['customImgIdle', 'customImgLoading'];
[].forEach.call(customImgPrefs, function(n) {
//cant check the pref i guess because its probably unintialized or deleted before i used have a `if(prefs[n].value != '') {`
//var normalized = OS.Path.normalize(prefs[n].value);
//var profRootDirLoc = OS.Path.join(OS.Constants.Path.profileDir, OS.Path.basename(normalized));
var profRootDirLoc = OS.Path.join(OS.Constants.Path.profileDir, 'throbber-restored-' + n);
var promiseDelete = OS.File.remove(profRootDirLoc);
console.log('profRootDirLoc', profRootDirLoc)
promiseDelete.then(
function() {
Services.prompt.alert(null, 'deleted', 'success on ' + n);
},
function(aRejReas) {
console.warn('Failed to delete copy of custom throbber ' + n + ' image for reason: ', aRejReas);
Services.prompt.alert(null, 'deleted', 'FAILED on ' + n);
}
);
});
Services.prefs.deleteBranch(prefPrefix);
}
The reason I post rather than test is because I tested and it worked but is there any special cases? Like what if addon was disabled, browser restarted, and then user opened addon manager then uninstalled. Special cases like these and any others? Do they require me to import all my stuff again?