Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome extension 为什么不';选项卡';从子帧接收chrome.runtime.sendMessage的发件人对象中的属性?_Google Chrome Extension - Fatal编程技术网

Google chrome extension 为什么不';选项卡';从子帧接收chrome.runtime.sendMessage的发件人对象中的属性?

Google chrome extension 为什么不';选项卡';从子帧接收chrome.runtime.sendMessage的发件人对象中的属性?,google-chrome-extension,Google Chrome Extension,编辑:带有MCVE和堆栈屏幕截图的简化问题 我的MCVE扩展json: { "manifest_version": 2, "name": "TEST SO", "version": "0.1", "permissions": [ "<all_urls>", "tabs" ], "background": { "scripts": ["background.js"] }, "content_scripts": [ {

编辑:带有MCVE和堆栈屏幕截图的简化问题

我的MCVE扩展json:

{
    "manifest_version": 2,
    "name": "TEST SO",
    "version": "0.1",
    "permissions": [ "<all_urls>", "tabs" ],
    "background": { "scripts": ["background.js"] },
    "content_scripts": [
        {
            "matches": ["<all_urls>"],
            "js": ["content.js"],
            "all_frames": true
        }
    ]
}
My MCVE background.js:

console.log("background.js Started");
chrome.runtime.onMessage.addListener(
    function( message, sender ) {
        try {
            console.log( "The 'message' arg is : " + JSON.stringify(message) );
            console.log( "The 'sender' TAB is : " + sender.tab.id );
        } catch ( e ) {
            console.log( "Exception in OnMessage Listener : " + e.message );
        }
    }
);
当我从一个有3个框架的站点(例如,一个主框架和2个子框架)导航到一个有一个框架的简单站点时,我的后台脚本会收到3条“消息”:每个“卸载”事件一条消息

不幸的是,只有第一个(对应于主框架的“卸载”)包含带有“
tab
”属性的“sender”参数。另外两个没有“
选项卡”
”属性

如果我读得正确,文档说明“
选项卡
”属性应该在那里

这是出于设计,是一个bug,还是我这边的坏代码

堆栈显示
发送方
参数没有
选项卡
属性

注意:在测试开始时,您可以拥有正确的
sender
对象,但是如果您只是在两个站点之间来回,您很快将无法拥有
选项卡
属性(对于来自
卸载
的消息,在两个子帧中)

48.0.2564.82米
Windows 7 64位。

无法复制。您使用的是哪个版本的Chrome?你能提供一套完整的步骤来重现问题(示例扩展+URL),并检查问题是否也发生在新的Chrome配置文件中吗?重新编辑:我使用的是相同版本的Chrome(在Linux上),但无法重现你的问题。请更新该问题,并包括允许我在新的浏览配置文件中独立再现您的问题的确切步骤。@RobW谢谢。添加了步骤。@RowW simplified,MCVE。感谢您的MCVE。我做了更多的测试并创建了一个bug报告:。您可以启动该问题以跟踪其进度。无法复制。您使用的是哪个版本的Chrome?你能提供一套完整的步骤来重现问题(示例扩展+URL),并检查问题是否也发生在新的Chrome配置文件中吗?重新编辑:我使用的是相同版本的Chrome(在Linux上),但无法重现你的问题。请更新该问题,并包括允许我在新的浏览配置文件中独立再现您的问题的确切步骤。@RobW谢谢。添加了步骤。@RowW simplified,MCVE。感谢您的MCVE。我做了更多的测试并创建了一个bug报告:。您可以启动该问题以跟踪其进度。
console.log("background.js Started");
chrome.runtime.onMessage.addListener(
    function( message, sender ) {
        try {
            console.log( "The 'message' arg is : " + JSON.stringify(message) );
            console.log( "The 'sender' TAB is : " + sender.tab.id );
        } catch ( e ) {
            console.log( "Exception in OnMessage Listener : " + e.message );
        }
    }
);