From b1016b8cfff19b592e781692b19dc485b13d2318 Mon Sep 17 00:00:00 2001 From: JW Wang Date: Tue, 30 Sep 2014 06:45:00 -0400 Subject: [PATCH] Bug 995438 - Call SpecialPowers.pushPermissions() to ensure permission change is completed before continuing the rest of the tests. r=baku --- .../html/content/test/test_audio_wakelock.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/content/html/content/test/test_audio_wakelock.html b/content/html/content/test/test_audio_wakelock.html index 68c2f9662bf3..e81fa3d49aa6 100644 --- a/content/html/content/test/test_audio_wakelock.html +++ b/content/html/content/test/test_audio_wakelock.html @@ -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();