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
Родитель b07d2488db
Коммит b1016b8cff
1 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -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();