<!DOCTYPE html>
<title>Test that fallback among codecs is done correctly regardless of their order.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
// This could be made far more general, testing all permutations of
// (audio|video)Codecs and so on, but in reality we only have these 4
// test files, so simply enumerating them manually and testing they
// all hit canplaythrough is good enough. Someday when many more
// files are present, consider generalizing this.
var testInfo = [
{ element: "video", typeArray: ["video/mp4", "video/ogg"], srcArray: ["content/test.mp4", "content/test.ogv"], description: "Test video with ['video/mp4', 'video/ogg']" },
{ element: "video", typeArray: ["video/ogg", "video/mp4"], srcArray: ["content/test.ogv", "content/test.mp4"], description: "Test video with ['video/ogg', 'video/mp4']" },
{ element: "audio", typeArray: ["audio/wav", "audio/ogg"], srcArray: ["content/test.wav", "content/test.oga"], description: "Test audio with ['audio/wav', 'audio/ogg']" },
{ element: "audio", typeArray: ["audio/ogg", "audio/wav"], srcArray: ["content/test.oga", "content/test.wav"], description: "Test audio with ['audio/ogg', 'audio/wav']" },
{ element: "audio", typeArray: ["audio/mp4", "audio/ogg"], srcArray: ["content/test.m4a", "content/test.oga"], description: "Test audio with ['audio/mp4', \"audio/ogg\"]" },
{ element: "audio", typeArray: ["audio/ogg", "audio/mp4"], srcArray: ["content/test.oga", "content/test.m4a"], description: "Test audio with ['audio/ogg', \"audio/mp4\"]" },
];
testInfo.forEach(function(test) {
async_test(function(t) {
var media = document.createElement(test.element);
for (var i = 0; i < test.srcArray.length; i++) {
var source = document.createElement("source");
if (test.typeArray)
source.type = test.typeArray[i];
source.src = test.srcArray[i];
media.appendChild(source);
}
media.oncanplaythrough = t.step_func_done();
}, test.description);
});
</script>