Chrome 消息传递:chrome.runtime.sendMessage 不适用于最新版本 49

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

我有一个 Chrome 扩展,它在版本 48 上工作得很好,但出于某种原因,它不能在 49 上工作,而且我无法在他们的 release/change 日志中找到任何内容。

不工作的部分是消息传递。

背景页:

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

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

这不会在版本 49 上输出任何内容,但会在版本 48 上输出。

我该如何解决这个问题?

这是预期的行为。消息不应该被发送页面接收。旧的行为是一个错误。这些错误报告中对此进行了讨论:479425 479951.