I have been working on a context-menu that communicates with a page mod and come up against an issue.
I am able to send a communication with right click to the page
ZERO is right, the event detach is emitted on reload.
But when I open a different page in the same tab no detach-event is been emitted!
So, i.e., when I have loaded some page A in tab 1 and click on a link which opens a different page B in the same tab 1 I have to detach the worker for page A manually(?)
var workers = [];
require('page-mod').PageMod({
include: '*',
contentScriptWhen: 'end',
contentScript: [require('self').data.url('bla.js')],
onAttach: function(worker) {
var w = workers.length;
while (w--) {
if (worker.tab === workers[w].tab) {
workers.splice(w, 1);
break;
}
}
workers.push(worker);
// other stuff
}
});