I have a background page and a content script. the content script has this code:
chrome.runtime.sendMessage({ getSetting: { setting: "hideAuth" } }, function (hide) {
// this should be executed after 'respond(setting)' in the backgroud page
});
The background page has this code:
chrome.runtime.onMessage.addListener(function (msg, sender, respond) {
if (msg["getSetting"]) {
chrome.storage.sync.get(msg.getSetting.setting, function (setting) {
respond(setting); // this should callback to the content script
});
});
}
});
However, the response callback in the content script is never executed. I've tried the run-around of querying the current tab and sending a message back manually but the tab still does not receive the message. Has anyone dealt with this before? Is there another way to to do this?