gecko/content/media/video/test/test_seek1.html
2009-05-18 12:25:05 +12:00

88 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: seek test 1</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
var startPassed = false;
var endPassed = false;
var seekFlagStart = false;
var seekFlagEnd = false;
var readonly = true;
var completed = false;
function startTest() {
if (completed)
return false;
var v = document.getElementById('v');
ok(!v.seeking, "seeking should default to false");
try {
v.seeking = 1;
readonly = false;
}
catch(e) {
readonly = true;
}
ok(readonly, "seeking should be readonly");
v.play();
v.currentTime=2;
seekFlagStart = v.seeking;
return false;
}
function seekStarted() {
if (completed)
return false;
var v = document.getElementById('v');
v.pause();
startPassed = true;
return false;
}
function seekEnded() {
if (completed)
return false;
var v = document.getElementById('v');
var t = v.currentTime;
// Since we were playing, and we only paused asynchronously, we can't be
// sure that we paused before the seek finished, so we may have played
// ahead arbitrarily far.
ok(t >= 1.9, "Video currentTime should be around 2: " + t);
v.play();
endPassed = true;
seekFlagEnd = v.seeking;
return false;
}
function playbackEnded() {
if (completed)
return false;
completed = true;
ok(startPassed, "seeking event");
ok(endPassed, "seeked event");
ok(seekFlagStart, "seeking flag on start should be true");
ok(!seekFlagEnd, "seeking flag on end should be false");
SimpleTest.finish();
return false;
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<video id='v'
src='seek.ogv'
onended='return playbackEnded();'
onloadedmetadata='return startTest();'
onseeking='return seekStarted();'
onseeked='return seekEnded();'></video>
</body>
</html>