Chrome messaging: chrome.runtime.sendMessage not working on the newest release 49

陌路散爱 提交于 2019-12-10 16:59:10

问题


I have a Chrome extension that works perfectly fine on version 48 but for some reason, isn't working on 49 and am not able to find anything on their release/change log.

The part that isn't working is the message passing.

Backgound page:

chrome.runtime.onMessage.addListener(function(msg, sender){
console.log(msg);
});

chrome.runtime.sendMessage({info:"this is a test"});

This will not output anything on version 49, but will on version 48.

How do I fix this?


回答1:


This is the intended behaviour. Messages were not supposed to be received by the sending page. The old behaviour was a bug. This is discussed in these bug reports: 479425 479951.



来源:https://stackoverflow.com/questions/35857606/chrome-messaging-chrome-runtime-sendmessage-not-working-on-the-newest-release-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!