On Sun, Sep 23, 2012 at 1:36 PM, <zhengxin
...@gmail.com> wrote:
in background.js
> ==================
> chrome.webRequest.onBeforeRequest.addListener(function(req){
> chrome.extension.sendMessage({test:123});
> });
[...]
in chrome21 , devtools.html page can’t receive the message from
> background.js
> and background.js get an error message : {"message":"Could not establish
> connection. Receiving end does not exist."}
> is anything wrong here?
You can't use chrome.extension.sendMessage() to send a message to an
extension page running in the context of DevTools (this call is for sending
to listeners running in the extension process, i.e. background page,
options page etc). The best way to communicate from background page to
DevTools is to open a port from the DevTools page using
chrome.extension.connect (and a chrome.extension.onConnect listener in the
background page) and use port.postMessage() in the background page later.
Best regards,
Andrey.