Chrome插件和内容安全策略错误
Chrome Plugin and Content Security Policy errors
上传未打包的Chrome扩展时,我得到以下错误:
Could not load extension from '/Users/me/example'. 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
清单如下所示:
{
"name": "Example Inc.",
"manifest_version" : 2,
"version": "0.4.4",
"content_scripts": [
{
"matches": [
"*://*.example.cc/*"
],
"js": [
"production/jquery.libs.min.js",
"https://example.cc/js/example.js"
],
"run_at": "document_end"
}
],
"permissions": [
"*://*.example.cc/*",
"tabs",
"activeTab",
"contextMenus",
"storage",
"management",
"cookies"
],
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com/ga.js https://example.cc/js/*; object-src 'self'"
}
从我看过的所有例子来看,在阅读了一些CSP文档之后,我不确定我错过了什么。我们的域名是完全https, example.js文件存在并且可以访问,等等
欢迎任何想法!
如果你只使用你的代码设置为只自我,例如
"content_security_policy";default-src‘自我’",
你应该这样做:
"content_security_policy": "script-src 'self' https://ssl.google-analytics.com/ga.js https://example.cc; object-src 'self'"
相关文章:
- 内容安全策略:页面's设置阻止加载资源
- 导致内容安全策略(CSP)冲突错误的本地jquery.js文件
- 旋转木马;启用内容安全策略时无法工作
- Extjs、Chrome扩展和内容安全策略
- 内容安全策略指令:;脚本src'self'blob:文件系统:chrome扩展资源:“;获取是否时
- 内容安全策略:无法在Chrome扩展中加载Google API
- 手动加载JQuery而不触发内容安全策略
- chrome扩展的内容安全策略问题
- WebGL CORS:试图突破用户代理的安全策略
- 创建映射时出现同源策略错误
- 在 JavaScript 中跟踪安全策略权限
- 如何打破内容安全策略
- 谷歌浏览器扩展程序制作中的内容安全政策错误
- 内容安全策略 + 表单插件
- 跨源策略错误
- REST API错误:拒绝连接到..因为它违反了以下内容安全策略指令:
- Modernizr导致内容安全策略(CSP)违反错误
- firefox OS内容安全策略错误,基于XHR的应用程序在Index.html
- Chrome插件和内容安全策略错误
- 内容安全策略:无法't在Firebug中解析无效的源chrome扩展-FB脚本错误