gecko/content/media/test/test_wav_onloadedmetadata.html

88 lines
2.1 KiB
HTML
Raw Normal View History

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
-->
<head>
<title>Wav Test for Bug 467972</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=467972">Mozilla Bug 467972</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 467972 **/
var gEnded = false;
var gSeekStarted = false;
var gSeekEnded = false;
var gLoadedDataCount = 0;
var gLoadedMetaDataCount = 0;
function get(id) {
return document.getElementById(id);
}
function video() {
return get('v');
}
function seekStarted() {
gSeekStarted = true;
}
function seekEnded() {
gSeekEnded = true;
video().play();
}
function loadedData() {
gLoadedDataCount++;
ok(gLoadedDataCount <= 1, "No more than 1 onloadeddata events");
}
function loadedMetaData() {
gLoadedMetaDataCount++;
ok(gLoadedMetaDataCount <= 1, "No more than 1 onloadedmetadata events");
ok(video().duration > 0.9 && video().duration < 1.1, "Duration should be around 1.0");
video().play();
return false;
}
function playbackEnded() {
if (!gEnded) {
video().currentTime = 0;
gEnded = true;
} else {
ok(gSeekEnded, "Should have received seekended");
ok(gSeekStarted, "Should have received seekstarted");
is(gLoadedDataCount, 1, "Should have 1 onloadeddata event");
is(gLoadedMetaDataCount, 1, "Should have 1 onloadedmetadata event");
SimpleTest.finish();
}
return false;
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<video id="v"
onloadedmetadata="return loadedMetaData();"
onended="playbackEnded();"
onloadeddata="return loadedData();"
onseeking="seekStarted();"
onseeked="seekEnded();"
src="r11025_s16_c1.wav"
controls></video>
</body>
</html>