gecko/content/media/test/test_seek-1.html
Syd Polk b215c6a77c Bug 1036992 - Split up test_seek.html into multiple tests. r=cpearce
--HG--
rename : content/media/test/test_seek2.html => content/media/test/test_invalid_seek.html
2014-07-31 14:37:00 -04:00

95 lines
2.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Media test: seek tests</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
<script type="text/javascript" src="seek_support.js"></script>
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
// The data being used in these tests is specified in manifest.js.
// The functions to build the test array and to run a specific test are in
// seek_support.js.
const SEEK_TEST_NUMBER = 1;
function test_seek1(v, seekTime, is, ok, finish) {
var startPassed = false;
var endPassed = false;
var seekFlagStart = false;
var seekFlagEnd = false;
var readonly = true;
var completed = false;
function startTest() {
if (completed)
return;
ok(!v.seeking, "seeking should default to false");
try {
v.seeking = true;
readonly = v.seeking === false;
}
catch(e) {
readonly = "threw exception: " + e;
}
is(readonly, true, "seeking should be readonly");
v.play();
v.currentTime=seekTime;
seekFlagStart = v.seeking;
}
function seekStarted() {
if (completed)
return;
ok(v.currentTime >= seekTime - 0.1,
"Video currentTime should be around " + seekTime + ": " + v.currentTime + " (seeking)");
v.pause();
startPassed = true;
}
function seekEnded() {
if (completed)
return;
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 >= seekTime - 0.1, "Video currentTime should be around " + seekTime + ": " + t + " (seeked)");
v.play();
endPassed = true;
seekFlagEnd = v.seeking;
}
function playbackEnded() {
if (completed)
return;
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");
finish();
}
v.addEventListener("ended", playbackEnded, false);
v.addEventListener("loadedmetadata", startTest, false);
v.addEventListener("seeking", seekStarted, false);
v.addEventListener("seeked", seekEnded, false);
}
manager.runTests(createTestArray(), startTest);
</script>
</pre>
</body>
</html>