javascript - Chrome 应用中的内容安全政策

标签 javascript google-chrome manifest google-chrome-app content-security-policy

我的 Chrome 应用具有以下 list :

{
    "name": ",
    "version": "1.0.3",
    "manifest_version": 2,
    "description": "Chrome Extension for.",
    "icons": {
        "16": "images/test.png",
        "19": "images/test.png",
        "256": "images/test.png"
    },
    "app": {
        "background": {
            "scripts": [
                "background.js"
            ]
        }
    },

    "sandbox": {
        "js": [
            "lib/test-api.js"
        ]
    },
    "permissions": [
        "<all_urls>",
        "notifications",
        "storage",
        "videoCapture"
    ]
}

我有一个运行eval 的脚本文件。我读过 CSP和沙盒,但我仍然收到此错误:

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

最佳答案

您是否尝试过根据您的 CSP 将 CSP 行添加到您的 list 中?链接?

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

关于javascript - Chrome 应用中的内容安全政策,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21130400/

相关文章:

javascript - 构造对象数组

javascript - Chrome 和 Firefox 中的 HTML5 音频持续时间不同

windows - 如何使用 WinSxS list 重定向到旧版本的 DLL?

javascript - 当 header 中有 <base> 标记时,为什么 snapsvg mask 在 Chrome 和 Firefox 中不起作用?

Android Manifest 实现问题

c++ - 包含新的 cpp 文件后链接过程中的 MSVC++ 错误

javascript - 如何获取HH :MM:SS difference using milliseconds in javascript?

javascript - 如何检测 map 何时移动?

javascript - 如何设置多个元素的 z-index 并使用模态内的 javascript 动态更新它们?

google-chrome - 如何仅向测试人员发布新版本的 Chrome 扩展