I’ve searched everywhere for a solution to this…even Google’s own code example doesn’t work. Someone please explain to me how to debug into event listeners or at least how to make Console.Log() work!
Looking at Google’s example : http://code.google.com/chrome/extensions/messaging.html
Here is what I’m testing…on my background.js (referenced from my background.html) I have this:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
else
sendResponse({}); // snub them.
});
On my popup.js (referenced from my popup.html) I have this:
chrome.extension.sendRequest({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
Considering I have the following permissions in my manifest:
"permissions": ["http://*/", "tabs"],
and my content scripts are defined as such:
"content_scripts":
[
{
"matches": ["http://*/*", "https://*/*"],
"js": ["scripts/background.js"],
"all_frames": true
}
]
why am I not able to get any information from console.log or debug into the event? I get the response just fine…but I can’t debug?
This is an ooooollld question, but for anyone who has the same question: go to chrome://extensions/ (or Tools->Extensions), enable debug view, and then there should be a link under your unpacked loaded extension to inspect the background.html view, which is where console messages from background.html are output.