我正在试验chrome.extensionAPI。
清单.json
{
    "name": "First",
    "version": "1.0",
    "manifest_version": 2,
    "description": "First extension",
    "background": {
        "scripts": ["test.js"]
    },    
    "page_action": {
        "default_icon": "icon.png",
        "default_popup": "popup.html"
    },    
    "content_scripts": [ {
        "js": [ "jquery.min.js", "display.js"  ],
        "matches": [ "http://*/*", "https://*/*" ]    
    } ],
    "permissions" : [
        "tabs",
    "http://*/*", "https://*/"
        ]
}
显示.js
alert("inside display.js");
chrome.extension.onMessage.addListener(
        function(request, sender, sendResponse){
            alert("inside msg");
            var time = request.sel_text;
            alert(time);
        });
测试.js
function check(tab_id, data, tab){
    if(tab.url.indexOf("google") > -1){
        chrome.pageAction.show(tab_id);
        chrome.tabs.executeScript(null, {"file" : "display.js"}) ;
    }
};
chrome.tabs.onUpdated.addListener(check);
popup1.js
function myfunc(){
    var x = $('#options option:selected').text();
    alert(x);
    chrome.extension.sendMessage({sel_text: x});
}
$(document).ready(function(){
    $('#options').change(myfunc);
});
现在,当我的页面加载时,我会three(3)弹出窗口说inside display.js但从chrome.extension.onMessage.addListener未被调用。
那么,我做错了什么。我们可以chrome.extension.*从内容脚本访问 API。