Chrome消息传递:chrome.runtime.sendMessage不适用于最新版本49 [英] Chrome messaging: chrome.runtime.sendMessage not working on the newest release 49

查看:387
本文介绍了Chrome消息传递:chrome.runtime.sendMessage不适用于最新版本49的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



Backgound页面

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

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

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



我该如何解决这个问题?

解决方案

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

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?

解决方案

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.

这篇关于Chrome消息传递:chrome.runtime.sendMessage不适用于最新版本49的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆