blob: 46a5a5495012af2cf253c0acf59edce95896f86d [file] [log] [blame]
<!DOCTYPE html>
<title>Test "error" event are fired on "source" elements and not on "video" while processing invalid "source" elements.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
<video>
<source id="missing-src" type="video/blahblah"></source>
<source id="bogus-type" src="content/test.mp4" type="video/blahblah"></source>
<source id="missing-file" src="content/error2.mpeg" type="video/mpeg"></source>
<source id="format-error" src="content/unsupported_track.mov"></source>
<source id="supported-format-mp4" src="content/test.mp4" type="video/mp4; codecs=&quot;avc1.4D400C&quot;"></source>
<source id="supported-format-ogv" src="content/test.ogv" type="video/ogg"></source>
</video>
<script>
// 1. Test that errors fired while evaluating/loading "source elements are
// fired at the "source" and not at the "video" element.
// 2. Verifiy that an "error" event fired while processing/loading a "source" element
// does not set the media element's "error" attribute.
async_test(function(t) {
var video = document.querySelector("video");
document.addEventListener("error", function(event) {
assert_true(event.target instanceof HTMLSourceElement);
}, true);
video.onloadstart = t.step_func(function() {});
video.onwaiting = t.step_func(function() {});
video.onratechange = t.step_func(function() {});
video.ondurationchange = t.step_func(function() {});
video.onpause = t.step_func(function() {});
video.onplay = t.step_func(function() {});
video.onplaying = t.step_func(function() {});
video.onerror = t.unreached_func();
video.onloadeddata = t.step_func_done(function() {
var url = video.currentSrc;
assert_equals(url.substr(url.lastIndexOf("/media/") + 7), findMediaFile("video", "content/test"));
});
});
</script>