preload-auto-to-metadata-event-order-dataurl.html
<!doctype html>
<!-- This file was generated from 'preload-auto-to-metadata-event-order.tpl' using 'tpl2tc.py'. Please do not edit manually! -->
<title>HTMLMediaElement.preload:auto event order when preload is set to metadata after loadstart is fired - wave</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/common.js"></script>
<p id="log">FAIL (script didn't run)</p>
<audio preload="auto" controls></audio>
<video preload="auto" controls></video>
<script>
var tests = init_tests("HTMLAudioElement.preload:auto event order when preload is set to metadata after loadstart is fired - wave", "HTMLVideoElement.preload:auto event order when preload is set to metadata after loadstart is fired - wave", {timeout:5000});
tests.forEach(function(vars) {
var t = vars[0];
t.step(function() {
var tag_name = vars[1];
var events_actual = '';
var node = document.getElementsByTagName(tag_name)[0];
var events = ['loadstart', 'progress', 'suspend', 'abort', 'error', 'loadedmetadata', 'loadeddata', 'canplay', 'canplaythrough'];
for (var e in events) {
node.addEventListener(events[e], handleEvent, false);
}
node.addEventListener('loadstart', startTest, false);
node.addEventListener('error', function() {
if (!node.canPlayType(tag_name + '/wave')) {
t.step(function() {
assert_unreached("Cannot play '" + tag_name + "/wave'");
t.done();
});
}
}, false);
node.src = 'data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQQAAAAAAAAA';
function startTest(e) {
node.removeEventListener('loadstart', startTest, false);
node.preload = 'metadata';
}
function handleEvent(e) {
events_actual += e.type + ' ';
if (e.type == 'canplaythrough') endTest();
}
function endTest() {
t.step(function() {
assert_regexp_match(events_actual, /^loadstart progress loadedmetadata loadeddata canplay canplaythrough $/g, 'Event order check');
assert_equals(node.preload, 'metadata', "'preload' value should be 'metadata'");
t.done();
});
}
});
});
</script>