diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/media/test/can_play_type_ogg.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test/can_play_type_ogg.js')
-rw-r--r-- | dom/media/test/can_play_type_ogg.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/dom/media/test/can_play_type_ogg.js b/dom/media/test/can_play_type_ogg.js new file mode 100644 index 0000000000..79bf8a554c --- /dev/null +++ b/dom/media/test/can_play_type_ogg.js @@ -0,0 +1,72 @@ +function check_ogg(v, enabled, finish) { + function check(type, expected) { + is(v.canPlayType(type), enabled ? expected : "", type); + } + + 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"); + + resolve(); + }); + } + + // Verify Opus support + function verify_opus_support() { + return new Promise(function (resolve, reject) { + var OpusEnabled = SpecialPowers.getBoolPref( + "media.opus.enabled", + undefined + ); + if (OpusEnabled != undefined) { + resolve(); + } else { + console.log( + "media.opus.enabled pref not found; skipping Opus validation" + ); + reject(); + } + }); + } + + function opus_enable() { + return SpecialPowers.pushPrefEnv({ + set: [["media.opus.enabled", true]], + }).then(function () { + check("audio/ogg; codecs=opus", "probably"); + }); + } + + function opus_disable() { + return SpecialPowers.pushPrefEnv({ + set: [["media.opus.enabled", false]], + }).then(function () { + check("audio/ogg; codecs=opus", ""); + }); + } + + 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); +} |