I have noticed that after disabling a bootstrapped add-on, the removeEventListener
does not seem to remove the listener and I can't work out the reason.
let contextMenu = window.document.getElementById('contentAreaContextMenu');
if (contextMenu) {
contextMenu.addEventListener('popupshowing',
this.contextPopupShowing.bind(this), false);
// added this to make sure they refer to the same function
console.log(this.contextPopupShowing.toString());
}
And then on disabling the addon
console.log(this.contextPopupShowing.toString()); // same as above
this.contextMenu.removeEventListener('popupshowing',
this.contextPopupShowing.bind(this), false);
// just showing that 'this' is working
this.contextMenu.removeChild(this.menuitem);
Finally ...
contextPopupShowing: function() {
// logs even after removeEventListener
console.log('contextPopupShowing called');
// more code
},