I am sending a message like so from the background-script.js:
browser.tabs.executeScript(itid, {
file: "content-script.js"
}).then(() => {
// The below should run concurrently as the update script will be waiting for it...
browser.tabs.sendMessage(
itid,
{
idx: strIndex,
rst: strResult
}
).catch(onError)
});
And receiving it like so in content-script.js:
function prse(message) {
console.log(message);
}
console.log("here");
browser.runtime.onMessage.addListener(prse);
However when I do so, content-script.js launches (“here” is logged) but the message isn’t caught, instead it jumps back to the background-script and fires an undefined error…
Anyone know what I’m doing wrong here?