Hi I am trying to execute a function in background.js from popup.js but chrome.extension.getBackgroundPage();
always returns null :
popup.js
var bkg = chrome.extension.getBackgroundPage();
bkg.test(function(result) {
alert(result);
});
background.js
function test(func) {
alert('test');
func.apply(this, ['bar']);
}
and my manifest :
{
"name": "Get pages source",
"background": {
"scripts": ["background.js"],
"persistent": true
},
"version": "1.0",
"manifest_version": 2,
"description": "Get pages source from a popup",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["tabs", "<all_urls>",
"downloads","http://*/*", "https://*/*","background"
]
}
someone knows why?