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 : .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?
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./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?
Share Improve this question edited Apr 1, 2022 at 17:40 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Sep 14, 2010 at 18:00 farinafarina 3,5766 gold badges33 silver badges44 bronze badges1 Answer
Reset to default 7This 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.