GET 在后台脚本上失败,chrome 应用程序 -

GET fails on background script, chrome app -

后台脚本(background-services.js)

chrome.runtime.onMessage.addListener(
    function (message, sender, sendResponse) {
        "use strict";
        if (message.request === "retrieve_url") {
            alert("Received file retrieval demand for file " + message.fileName);
            var url = chrome.extension.getUrl(message.fileName); 
            alert("url calculated: " + url);
         }
    }
);

内容脚本(google-translate.js)

chrome.runtime.sendMessage({
    request: "retrieve_url",
    fileName: "templates/toast.html"
});

清单

...
"permissions": [
    "*://translate.google.com/*"
],
"background": {
    "scripts": [
        "src/common/jquery-2.1.3.min.js",
        "src/background/background-services.js"
    ]
},
"content_scripts": [
    {
        "matches": ["*://translate.google.com/*"],
        "js": ["src/common/jquery-2.1.3.min.js", "src/scripts/google-translate.js"],
        "run_at": "document_end"
    }
],
"web_accessible_resources": ["templates/toast.html"]

我收到有关收到的文件检索请求的警报,但没有任何反应,也没有记录到控制台或扩展开发人员工具。

var url = chrome.extension.getUrl(message.fileName); 

正确的形式是var url = chrome.extension.getURL(message.fileName);

有时编码过热。