Bug 995438 - Call SpecialPowers.pushPermissions() to ensure permission change is completed before continuing the rest of the tests. r=baku

This commit is contained in:
JW Wang 2014-09-30 06:45:00 -04:00
parent 52d76c7560
commit 572c687e06

View File

@ -39,7 +39,7 @@ function testAudioPlayPause() {
audio.pause();
});
navigator.mozPower.addWakeLockListener(function testAudioPlayListener(topic, state) {
function testAudioPlayListener(topic, state) {
is(topic, "cpu", "Audio element locked the target == cpu");
var locked = state == "locked-foreground" ||
state == "locked-background";
@ -58,8 +58,9 @@ function testAudioPlayPause() {
navigator.mozPower.removeWakeLockListener(testAudioPlayListener);
runTests();
}
});
};
navigator.mozPower.addWakeLockListener(testAudioPlayListener);
audio.play();
}
@ -78,7 +79,7 @@ function testAudioPlay() {
startDate = new Date();
});
navigator.mozPower.addWakeLockListener(function testAudioPlayListener(topic, state) {
function testAudioPlayListener(topic, state) {
is(topic, "cpu", "Audio element locked the target == cpu");
var locked = state == "locked-foreground" ||
state == "locked-background";
@ -101,8 +102,9 @@ function testAudioPlay() {
navigator.mozPower.removeWakeLockListener(testAudioPlayListener);
runTests();
}
});
};
navigator.mozPower.addWakeLockListener(testAudioPlayListener);
audio.play();
}
@ -117,8 +119,11 @@ function runTests() {
test();
};
SpecialPowers.addPermission("power", true, document);
SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500]]}, runTests);
SpecialPowers.pushPermissions(
[{'type': 'power', 'allow': true, 'context': document}],
function() {
SpecialPowers.pushPrefEnv({"set": [["media.wakelock_timeout", 500]]}, runTests);
});
SimpleTest.waitForExplicitFinish();