Good morning, wizards.
I'm trying myself in writing an extension for chromium-browser.
The version of chromium is 18.0.1025.151 (development build 130497 Linux) Built on Ubuntu 12.04, running on Ubuntu 12.10
My OS is ubuntu GNU/Linux 12.04.1 (LTS), 64bit.
The problem is: I cannot use chrome.alarms
. I get 'undefined' when access this variable.
Part of my manifest.json
:
"background": {
"scripts": ["background.js"]
},
"permissions": [
"alarms",
"tabs",
"http://*/*"
],
Part of my background.js
:
chrome.alarms.onAlarm.addListener(function(alarm) {
if (! alarm.name.match ('/^extension47_.*/'))
return;
alert ('extension47 fired an alarm!');
});
What I get:
Uncaught TypeError: Cannot read property 'onAlarm' of undefined
at the line chrome.alarms.onAlarm.addListener
.
When I go to the chromium console from the extensions page, auto-completion suggests me no chrome.alarms
. Obviously, when I type there chrome.alarms
, I really get undefined
. Why so?..
I'm totally stuck, failed to find a solution anywhere on the Internet, what am I doing wrong?
I had some trouble with this too recently and didn't see that noted anywhere in the docs (or at any relevant location).
Just make sure to also ask for the alarms
permission:
manifest.json
{
"manifest_version": 2,
"permissions": [
// ...
"alarms"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With