2012-04-02 31 views
1

我想請求Chrome擴展清單文件(我自己的分機)鉻未捕獲的錯誤:SECURITY_ERR:DOM異常18當試圖在XHR鉻擴展名的文件

// 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; 
})(); 

,但我得到一個錯誤:

Uncaught Error: SECURITY_ERR: DOM Exception 18 (anonymous function)cm_background.js:46 (anonymous function)

線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 *;" 
} 
+0

你的清單是怎樣的? – 2012-04-02 21:04:25

+0

更新了清單文件 – 2012-04-02 21:21:58

回答

1

請問這種方法給你所需要的信息?

chrome.app.getDetails() 

它似乎沒有記錄在API中,但它從清單中返回大部分數據。

相關問題