Im trying to pass messages between a pageMod and a content script.
I use this code with the pageMod
var gmailPageMod = pageMod.PageMod({
include: "https://mail.google.com/*",
contentScriptWhen: "ready",
contentScriptFile: [self.data.url('js/script.js')],
contentStyleFile: [
self.data.url("css/angular.min.css"),
self.data.url("css/style.css")
],
onAttach: function(worker) {
try {
console.log("adding worker");
gmail_workers.push(worker);
} catch (error) {
console.log("error", error);
}
worker.port.on("getTalentGamil_recipient_change", function(email) {
console.log(email);
});
try {
console.log("updating SS");
console.log(simpleStorage);
worker.port.emit("updateSimpleStorage", simpleStorage);
} catch (error) {
console.log("error", error);
}
});
and in script.js
self.port.on("updateSimpleStorage", function(simpleStorage) {
console.log('updateSimpleStorage from script.js', simpleStorage);
var e = new CustomEvent('updateSimpleStorage', {
'detail': simpleStorage
});
window.dispatchEvent(e);
});
However this gives me an error Message: [Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: <unknown filename> :: <TOP_LEVEL> :: line 0" data: no]
I dont understand why though? Because I think Im doing exactly whats being done here. I'd appreciate any help on the matter
I came across this and according to it, CustomEvents
no longer work, so I used a roundabout message passing route with FF Addon SDK's native messaging to get my info across.