Bug 1227451 - chrome.alarms API doesn't check 'alarms' permission. r=billm

This commit is contained in:
Luca Greco 2016-01-04 10:21:00 -05:00
parent f3ccde98a0
commit 1a681902aa
2 changed files with 27 additions and 1 deletions

View File

@ -91,7 +91,7 @@ extensions.on("shutdown", (type, extension) => {
}); });
/* eslint-enable mozilla/balanced-listeners */ /* eslint-enable mozilla/balanced-listeners */
extensions.registerAPI((extension, context) => { extensions.registerPrivilegedAPI("alarms", (extension, context) => {
return { return {
alarms: { alarms: {
create: function(...args) { create: function(...args) {

View File

@ -13,6 +13,32 @@
<script type="text/javascript"> <script type="text/javascript">
"use strict"; "use strict";
add_task(function* test_alarm_without_permissions() {
function backgroundScript() {
let ALARM_NAME = "test_ext_alarms";
browser.test.log("running alarm script");
browser.test.assertTrue(!browser.alarms,
"alarm API should not be available if the alarm permission is not required")
browser.test.notifyPass("alarms_permission");
}
let extensionData = {
background: "(" + backgroundScript.toString() + ")()",
manifest: {
permissions: [],
},
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
yield extension.startup();
info("extension loaded");
yield extension.awaitFinish("alarms_permission");
yield extension.unload();
info("extension unloaded");
});
add_task(function* test_alarm_fires() { add_task(function* test_alarm_fires() {
function backgroundScript() { function backgroundScript() {
let ALARM_NAME = "test_ext_alarms"; let ALARM_NAME = "test_ext_alarms";