javascript - Bug with chrome.tabs.captureVisibleTab -


i building chrome extension , trying send message event background.js page inside of chrome.tabs.capturevisibletab(). reason message not send content script...

chrome.runtime.onmessage.addlistener(  function(request, sender, sendresponse) {  var responseobj = new object();  if(request.screenshotrequest == true){   chrome.tabs.capturevisibletab({ format: "png"}, function(dataurl){     responseobj.screenshotrequest = dataurl;     alert(sendresponse);     sendresponse(responseobj);    });   } }); 

my manifest.json allows correct permissions allow message passing happen. when try , pass messages using sendresponse() outside of chrome.tabs.capturevisibletab() message passes correctly , can access content script. idea why isn't passing?

update: alert(sendresponse); proves chrome.tabs.capturevisibletabs() has access sendresponse because object correctly displayed in alert message.

i dug console of unpacked extension (apparently different regular extension's console: where read console messages background.js in chrome extension?) , said chrome.runtime.onmessage.addlistener needed return true if sendresponse called inside of callback in function. worked!


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -