我正在开发一个 Chrome 插件,其中从多个域加载外部脚本。我已经查看了有关如何允许这些域的文档和一些教程。
我检查过的文档:
- http://developer.chrome.com/extensions/contentSecurityPolicy.html
- http://www.html5rocks.com/en/tutorials/security/content-security-policy/
- http://dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html#syntax
一切都是一样的,我在 manifest.json 中创建了这条规则:
{
// .. general settings
"content_security_policy": "script-src 'self' https://ajax.googleapis.com http://mysite.com; object-src 'self'"
}
对此 Chrome 做出以下回应:
Could not load extension from '/Users/itarato/Desktop/DRC Tutorial Client'.
Invalid value for 'content_security_policy': Both 'script-src' and 'object-src' directives must be specified (either explicitly, or implicitly via 'default-src'), and both must whitelist only secure resources.
You may include any of the following sources: "'self'", "'unsafe-eval'", "http://127.0.0.1", "http://localhost", or any "https://" or "chrome-extension://" origin.
For more information, see http://developer.chrome.com/extensions/contentSecurityPolicy.html
当然,我尝试了几种组合,但都失败了。只有当我只使用一个域时它才有效。我怎样才能添加更多?