Bug 1476975 - P2. Add mochitests. r=dminor

--HG--
extra : rebase_source : a24191c0bc355b69d425291a0ebdea21d962866a
This commit is contained in:
Jean-Yves Avenard 2018-07-20 10:59:20 +02:00
Родитель c219e50b81
Коммит 5fca92f302
3 изменённых файлов: 44 добавлений и 4 удалений

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

@ -1,6 +1,6 @@
function check_webm(v, enabled) { async function check_webm(v, enabled) {
function check(type, expected) { function check(type, expected) {
is(v.canPlayType(type), enabled ? expected : "", type); is(v.canPlayType(type), enabled ? expected : "", type + "='" + expected + "'");
} }
// WebM types // WebM types
@ -26,4 +26,31 @@ function check_webm(v, enabled) {
check("video/webm; codecs=xyz", ""); check("video/webm; codecs=xyz", "");
check("video/webm; codecs=xyz,vorbis", ""); check("video/webm; codecs=xyz,vorbis", "");
check("video/webm; codecs=vorbis,xyz", ""); check("video/webm; codecs=vorbis,xyz", "");
function getPref(name) {
var pref = false;
try {
pref = SpecialPowers.getBoolPref(name);
} catch(ex) { }
return pref;
}
function isWindows32() {
return navigator.userAgent.includes("Windows") &&
!navigator.userAgent.includes("Win64");
}
function isAndroid() {
return navigator.userAgent.includes("Android");
}
const haveAv1 = getPref("media.av1.enabled");
check("video/webm; codecs=\"av1\"", haveAv1 ? "probably" : "");
await SpecialPowers.pushPrefEnv({"set": [["media.av1.enabled", true]]});
// AV1 is disabled on Windows 32 bits (bug 1475564) and Android (bug 1368843)
check("video/webm; codecs=\"av1\"", (isWindows32() || isAndroid()) ? "" : "probably");
await SpecialPowers.pushPrefEnv({"set": [["media.av1.enabled", false]]});
check("video/webm; codecs=\"av1\"", "");
} }

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

@ -96,6 +96,9 @@ function check_mp4(v, enabled) {
check(codec, "probably"); check(codec, "probably");
ok(MediaSource.isTypeSupported(codec), "VP9 in MP4 should be supported in MSE"); ok(MediaSource.isTypeSupported(codec), "VP9 in MP4 should be supported in MSE");
}); });
// AV1 (disabled until bug 1417050 is fixed)
check("video/mp4; codecs=\"av1\"", "");
} }
function check_mp3(v, enabled) { function check_mp3(v, enabled) {

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

@ -21,8 +21,18 @@ a Bug 566245</a>
<pre id="test"> <pre id="test">
<script src="can_play_type_webm.js"></script> <script src="can_play_type_webm.js"></script>
<script> <script>
check_webm(document.getElementById('v'), true); async function runTest() {
mediaTestCleanup(); try {
await check_webm(document.getElementById('v'), true);
mediaTestCleanup();
} catch (e) {
info("Exception " + e.message);
ok(false, "Threw exception " + e.message);
}
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
addLoadEvent(runTest);
</script> </script>
</pre> </pre>
</body> </body>