chrome.runtime.onMessage.addListener通过iframe重复接收
/// background.js
(function () {
function toggle(tab) {
console.log('activate:', tab.url, tab.id);
chrome.tabs.sendMessage(tab.id, {action: 'hihi'});
}
chrome.browserAction.onClicked.addListener(toggle);
}());
//contents.js
(function () {
chrome.runtime.onMessage.addListener(function (request, sender,
sendResponse) {
console.log('call : ', request.action);
});
return true;
})();
// manifest.json
"all_frames": true
// console result
call : hihi
call : hihi
call : hihi