【发布时间】:2012-08-30 14:23:29
【问题描述】:
我正在尝试请求 chrome 扩展清单文件(我自己的扩展)
// MAKE MANIFEST FILE AVAILABLE
chrome.manifest = (function() {
var manifestObject = false;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
manifestObject = JSON.parse(xhr.responseText);
}
};
xhr.open("GET", chrome.extension.getURL('/manifest.json'), false);
try {
xhr.send();
} catch(e) {
log('Couldn\'t load manifest.json');
}
return manifestObject;
})();
但我得到一个错误:
未捕获的错误:SECURITY_ERR:DOM 异常 18(匿名 函数)cm_background.js:46(匿名函数)
第 46 行是 xhr.open("GET", chrome.extension.getURL('/manifest.json'), false);
允许我执行此操作的适当的清单安全策略是什么,或替代的安全方式是什么?
更新
清单文件
{
"manifest_version": 2,
"name": "A plugin",
"version":"1.3.6",
"background": {
"page":"cm_background.html"
},
"page_action": {
"default_icon": "logo.png",
"default_title": "A plugin",
"default_popup": "cm_popup.html"
},
"content_scripts": [
{
"matches": ["http://mail.google.com/*", "https://mail.google.com/*"],
"js": ["jquery.js",
"underscore.js",
"sha256.js",
"utils.js",
"cm_content_script.js",
"cm_content_ui_control.js",
"cm_first_install.js"]
}
],
"permissions" : [
"tabs",
"http://mail.google.com/*",
"https://mail.google.com/*",
"http://*/*",
"https://*/*",
"chrome-extension://*/*"
],
"web_accessible_resources": [
"manifest.json",
"cm_first_install.js",
"jquery.js",
"cm_signature_editor.css",
"cm_signature_editor.html"
],
"content_security_policy": "default-src 'self'; style-src 'self' 'unsafe-inline'; img-src *;"
}
【问题讨论】:
-
您的清单看起来如何?