From 3ba92dcaa379ecfdd1e7d09b9a83c43caee9857f Mon Sep 17 00:00:00 2001 From: Alfredo Yang Date: Mon, 22 Sep 2014 02:21:00 -0400 Subject: [PATCH] Bug 1069795 - Use promise and pushEnv instead of setEnv. r=jwwang --- content/media/test/can_play_type_ogg.js | 96 +++++++++++++------ content/media/test/mochitest.ini | 1 - .../media/test/test_can_play_type_no_ogg.html | 10 +- .../media/test/test_can_play_type_ogg.html | 11 ++- 4 files changed, 84 insertions(+), 34 deletions(-) diff --git a/content/media/test/can_play_type_ogg.js b/content/media/test/can_play_type_ogg.js index 11e1dc514d8..b9678bcacf0 100644 --- a/content/media/test/can_play_type_ogg.js +++ b/content/media/test/can_play_type_ogg.js @@ -1,38 +1,78 @@ -function check_ogg(v, enabled) { + +function check_ogg(v, enabled, finish) { function check(type, expected) { is(v.canPlayType(type), enabled ? expected : "", type); } - // Ogg types - check("video/ogg", "maybe"); - check("audio/ogg", "maybe"); - check("application/ogg", "maybe"); + function basic_test() { + return new Promise(function(resolve, reject) { + // Ogg types + check("video/ogg", "maybe"); + check("audio/ogg", "maybe"); + check("application/ogg", "maybe"); - // Supported Ogg codecs - check("audio/ogg; codecs=vorbis", "probably"); - check("video/ogg; codecs=vorbis", "probably"); - check("video/ogg; codecs=vorbis,theora", "probably"); - check("video/ogg; codecs=\"vorbis, theora\"", "probably"); - check("video/ogg; codecs=theora", "probably"); + // Supported Ogg codecs + check("audio/ogg; codecs=vorbis", "probably"); + check("video/ogg; codecs=vorbis", "probably"); + check("video/ogg; codecs=vorbis,theora", "probably"); + check("video/ogg; codecs=\"vorbis, theora\"", "probably"); + check("video/ogg; codecs=theora", "probably"); + + resolve(); + }); + } // Verify Opus support - var OpusEnabled = undefined; - try { - OpusEnabled = SpecialPowers.getBoolPref("media.opus.enabled"); - } catch (ex) { - // SpecialPowers failed, perhaps because Opus isn't compiled in - console.log("media.opus.enabled pref not found; skipping Opus validation"); - } - if (OpusEnabled !== undefined) { - SpecialPowers.setBoolPref("media.opus.enabled", true); - check("audio/ogg; codecs=opus", "probably"); - SpecialPowers.setBoolPref("media.opus.enabled", false); - check("audio/ogg; codecs=opus", ""); - SpecialPowers.setBoolPref("media.opus.enabled", OpusEnabled); + function verify_opus_support() { + return new Promise(function(resolve, reject) { + var OpusEnabled = undefined; + try { + OpusEnabled = SpecialPowers.getBoolPref("media.opus.enabled"); + } catch (ex) { + // SpecialPowers failed, perhaps because Opus isn't compiled in + console.log("media.opus.enabled pref not found; skipping Opus validation"); + } + if (OpusEnabled != undefined) { + resolve(); + } else { + reject(); + } + }); } - // Unsupported Ogg codecs - check("video/ogg; codecs=xyz", ""); - check("video/ogg; codecs=xyz,vorbis", ""); - check("video/ogg; codecs=vorbis,xyz", ""); + function opus_enable() { + return new Promise(function(resolve, reject) { + SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', true]]}, + function() { + check("audio/ogg; codecs=opus", "probably"); + resolve(); + }); + }); + } + + function opus_disable() { + return new Promise(function(resolve, reject) { + SpecialPowers.pushPrefEnv({"set": [['media.opus.enabled', false]]}, + function() { + check("audio/ogg; codecs=opus", ""); + resolve(); + }); + }); + } + + function unspported_ogg() { + // Unsupported Ogg codecs + check("video/ogg; codecs=xyz", ""); + check("video/ogg; codecs=xyz,vorbis", ""); + check("video/ogg; codecs=vorbis,xyz", ""); + + finish.call(); + } + + basic_test() + .then(verify_opus_support) + .then(opus_enable) + .then(opus_disable) + .then(unspported_ogg, unspported_ogg); + } diff --git a/content/media/test/mochitest.ini b/content/media/test/mochitest.ini index 7dfa3402fea..5885237e58c 100644 --- a/content/media/test/mochitest.ini +++ b/content/media/test/mochitest.ini @@ -320,7 +320,6 @@ skip-if = buildapp == 'mulet' || os == 'win' # bug 894922 skip-if = buildapp == 'b2g' # bug 1021675 [test_can_play_type_no_ogg.html] [test_can_play_type_ogg.html] -skip-if = buildapp == 'b2g' || e10s # b2g(bug 1021675) [test_chaining.html] [test_clone_media_element.html] [test_closing_connections.html] diff --git a/content/media/test/test_can_play_type_no_ogg.html b/content/media/test/test_can_play_type_no_ogg.html index 0aa1f2aabdf..03f336b8d6f 100644 --- a/content/media/test/test_can_play_type_no_ogg.html +++ b/content/media/test/test_can_play_type_no_ogg.html @@ -24,11 +24,15 @@ a Bug 469247