javascript - Firefox Extension port to emit from main.js -


i building firefox extension , trying communicate between main.js , contentscriptfile. want in when tab closed call function in contentscriptfile injected in other open tabs. code using port doesn't seems work

main.js

var tabs = require("sdk/tabs"); tabs.on('close', function(tab){  if(tab.url.indexof('example.com/url2') > -1) { (let tab of tabs) {   tab.attach({}).port.emit("docorn", 'eg1'); } } else if(tab.url.indexof('example.com/url1') > -1) { (let tab of tabs) {   tab.attach({}).port.emit("docorn", 'eg2'); } } }); 

contentscriptfile

self.port.on("docorn", function(msg) { console.log(msg) }); 

but doesn't seem work. so, have idea?


Popular posts from this blog