Firefox/Chrome Web 扩展 - 尝试通过内容脚本注入 IFrame 时出现安全错误

Firefox/Chrome Web Extension - Security Error When Trying To Inject IFrame Through Content Script

我在内容脚本中有以下非常简单的代码,只要按下我的 "popup.html" 文件中的按钮,它就会运行:

里面的代码部分"inject.js"

browser.runtime.onMessage.addListener((message) => {
    console.log("Trying to inject iFrame");
    var iframe = document.createElement("iframe");
    iframe.src = browser.extension.getURL("inject.html");
    document.body.appendChild(iframe);
});

"inject.html"的内容是:

<!DOCTYPE html>
<html>

<head>
</head>

<body>
    <p>
        Hello. This is a Test.
    </p>
</body>

</html>

但是,当此代码运行时,我在控制台中得到以下输出(使用“example.com:作为示例 URL):

Trying to inject iFrame
Security Error: Content at http://example.com/ may not load or link to moz-extension://218287b3-46eb-4cf6-a27f-45b9369c0cd9/inject.html.

这是我的 "manifest.json"

{
"manifest_version": 2,
"name": "Summarizer",
"version": "1.0",

"description": "Summarizes webpages",

"permissions": [
    "activeTab",
    "tabs",
    "storage",
    "downloads",
    "*://*.smmry.com/*"
],

"icons":
{
    "48": "icons/border-48.png"
},

"browser_action":
{
    "browser_style": true,
    "default_popup": "popup/choose_length_page.html",
    "default_icon":
    {
        "16": "icons/summarizer-icon-16.png",
        "32": "icons/summarizer-icon-32.png"
    }
}

"web_accessible_resources": [
    "inject.html"
]
}

最后,这是我的扩展的顶级文件结构:

如何修复此安全错误?

这不是这个的副本: 因为我在 manifest.json

中提供了完整路径

我漏了一个逗号。这是 manifest.json 的相关部分,逗号就位:

"browser_action":
{
    "browser_style": true,
    "default_popup": "popup/choose_length_page.html",
    "default_icon":
    {
        "16": "icons/summarizer-icon-16.png",
        "32": "icons/summarizer-icon-32.png"
    }
},

"web_accessible_resources": [
    "inject.html"
]