I am trying to send a message from popup to background and get message back from background.
I get the message from popup and it prints Background received: Hi
, but it doesn't print Popup received: Bye
.
background.js
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log("Background received: " + request.msg);
sendResponse({msg: "Bye"});
}
)
popup.js
chrome.runtime.sendMessage({msg: "Hello"}, function(response) {
console.log("Popup received: " + response.msg);
});
I've done this before, I'm sure, but I can't seem to find out what I'm doing wrong now. I must be overlooking something very simple. Thanks in advance!