gecko/content/media/video/test/test_onloadedmetadata.html

90 lines
2.1 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=467972
-->
<head>
<title>Test for Bug 467972</title>
<script type="application/javascript" src="/MochiKit/MochiKit.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");
is(video().videoWidth, 320, "width is available");
is(video().videoHeight, 240, "height is available");
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"
src="320x240.ogv"
onloadedmetadata="return loadedMetaData();"
onended="playbackEnded();"
onloadeddata="return loadedData();"
onseeking="seekStarted();"
onseeked="seekEnded();"
controls></video>
</body>
</html>