Chrome 消息:chrome.runtime.sendMessage 在最新版本 49 上不起作用

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

本文关键字:新版本 最新版 不起作用 sendMessage 消息 chrome runtime Chrome      更新时间:2023-09-26

我有一个Chrome扩展程序,在版本48上运行良好,但由于某种原因,无法在版本49上运行,并且无法在他们的发布/更改日志中找到任何内容。

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

背景页面:

chrome.runtime.onMessage.addListener(function(msg, sender){
console.log(msg);
});
chrome.runtime.sendMessage({info:"this is a test"});

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

我该如何解决这个问题?

这是

预期的行为。发送页面不应接收消息。旧的行为是一个错误。这在以下错误报告中进行了讨论:479425 479951。