Mozilla Firefox 本机消息传递错误:没有此类本机应用程序

问题描述 投票:0回答:2

我正在使用 Windows 10 64 位、Mozilla Firefox 76.0.1 并构建一个本机消息插件。在 Chrome 上完美运行,但在 Firefox 中则不然。

现在,当我点击此错误报告描述我的 64 位 Windows 和 Firefox 问题时 https://bugzilla.mozilla.org/show_bug.cgi?id=1494709 我找到了这个文档https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Native_manifests#Windows

所以,我将注册脚本调整为:

:: Change HKCU to HKLM if you want to install globally.
:: %~dp0 is the directory containing this bat script and ends with a backslash.
REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.testapp" /ve /t REG_SZ /d "%~dp0com.testapp.json" /f
REG ADD "HKCU\Software\Mozilla\NativeMessagingHosts\com.testapp" /ve /t REG_SZ /d "%~dp0com.testapp.json" /f
REG ADD "HKLM\Software\WOW6432Node\Mozilla\NativeMessagingHosts\com.testapp" /ve /t REG_SZ /d "%~dp0com.testapp.json" /f

我检查了注册表中的值,它们是正确的。它们具有正确的名称并指向具有完整路径和文件扩展名的清单文件。我使用以下本机消息传递清单:

{
    "name": "com.testapp",
    "description": "Test FF/Chrome plugin",
    "path": "C:\\Temp\\NativeHost.exe",
    "type": "stdio",
    "allowed_origins": [
        "chrome-extension://inommcgcdahcocksfinofjgoeaodehnbno/"
    ],
    "allowed_extensions": [
        "[email protected]"
    ]
}

出于某种原因,Firefox 仍然给我这个错误:

错误:“没有这样的本机应用程序 com.testapp”

我错过了什么?

firefox browser-extension browser-plugin
2个回答
0
投票

您的主机清单 json 文件中可能有注释。

删除评论并尝试,对我来说这就是解决方案......


0
投票

我在 Mac 上遇到了同样的问题,检查 Firefox 浏览器控制台(在 mac 上为 Shift+CMD+J),错误是

Value must either: match the pattern /^\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\}$/i, not contain an unexpected "allowed_origins" property, or contain the required "data" property

只需删除主机应用程序清单中的

allowed_origins
,只保留
allowed_extensions
,然后它对我有用

© www.soinside.com 2019 - 2024. All rights reserved.