In my experience, reinstalling an add-on with the same version number is considered a downgrade
. So save the version number in simple-storage then
const self = require('sdk/self');
const {storage} = require('sdk/simple-storage');
if (storage && storage.version===self.version && self.loadReason==='downgrade')
storage = {};
Caveats:
- The assumption here is that if you (the developer) upgrade an add-on after someone uninstalls it and before they restart Firefox, then the reinstalled add-on will run as the old version again before updating itself automatically. Which I think is a safe assumption.
- If someone uninstalls then clicks Undo, that is not a reinstall/
downgrade
but anenable
.