uninstall
ブートストラップされたアドオンの一部で、いくつかの重要なことを行います。作成したファイルとすべての設定を削除します。ただし、これはいくつかのサービスを使用します。
これは私のuninstall
手順の 1 つの例です。
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);
}
テストではなく投稿する理由は、テストして機能したためですが、特別なケースはありますか? アドオンが無効になり、ブラウザが再起動され、ユーザーがアドオン マネージャを開いてアンインストールした場合と同様です。これらのような特殊なケースやその他のケースはありますか? すべてのものを再度インポートする必要がありますか?