2014-07-31 11:37:00 -07:00
|
|
|
<!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;
|
|
|
|
|
2009-07-09 19:03:02 -07:00
|
|
|
function test_seek1(v, seekTime, is, ok, finish) {
|
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
var startPassed = false;
|
|
|
|
var endPassed = false;
|
|
|
|
var seekFlagStart = false;
|
|
|
|
var seekFlagEnd = false;
|
|
|
|
var readonly = true;
|
|
|
|
var completed = false;
|
|
|
|
|
|
|
|
function startTest() {
|
|
|
|
if (completed)
|
2012-08-14 21:41:24 -07:00
|
|
|
return;
|
2009-01-05 17:18:40 -08:00
|
|
|
ok(!v.seeking, "seeking should default to false");
|
|
|
|
try {
|
2009-12-08 17:00:42 -08:00
|
|
|
v.seeking = true;
|
|
|
|
readonly = v.seeking === false;
|
2009-01-05 17:18:40 -08:00
|
|
|
}
|
|
|
|
catch(e) {
|
2009-12-08 17:00:42 -08:00
|
|
|
readonly = "threw exception: " + e;
|
2009-01-05 17:18:40 -08:00
|
|
|
}
|
2009-12-08 17:00:42 -08:00
|
|
|
is(readonly, true, "seeking should be readonly");
|
2009-01-05 17:18:40 -08:00
|
|
|
|
2008-10-19 00:39:21 -07:00
|
|
|
v.play();
|
2009-07-09 19:03:02 -07:00
|
|
|
v.currentTime=seekTime;
|
2009-02-19 09:23:13 -08:00
|
|
|
seekFlagStart = v.seeking;
|
2008-10-19 00:39:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function seekStarted() {
|
|
|
|
if (completed)
|
2012-08-14 21:41:24 -07:00
|
|
|
return;
|
2011-07-11 20:39:32 -07:00
|
|
|
ok(v.currentTime >= seekTime - 0.1,
|
|
|
|
"Video currentTime should be around " + seekTime + ": " + v.currentTime + " (seeking)");
|
2008-12-15 20:58:33 -08:00
|
|
|
v.pause();
|
2008-10-19 00:39:21 -07:00
|
|
|
startPassed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function seekEnded() {
|
|
|
|
if (completed)
|
2012-08-14 21:41:24 -07:00
|
|
|
return;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
var t = v.currentTime;
|
2009-05-17 17:25:05 -07:00
|
|
|
// 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.
|
2011-07-11 20:39:32 -07:00
|
|
|
ok(t >= seekTime - 0.1, "Video currentTime should be around " + seekTime + ": " + t + " (seeked)");
|
2008-12-15 20:58:33 -08:00
|
|
|
v.play();
|
2008-10-19 00:39:21 -07:00
|
|
|
endPassed = true;
|
|
|
|
seekFlagEnd = v.seeking;
|
|
|
|
}
|
|
|
|
|
|
|
|
function playbackEnded() {
|
|
|
|
if (completed)
|
2012-08-14 21:41:24 -07:00
|
|
|
return;
|
2008-10-19 00:39:21 -07:00
|
|
|
|
|
|
|
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");
|
2009-07-09 19:03:02 -07:00
|
|
|
finish();
|
2008-10-19 00:39:21 -07:00
|
|
|
}
|
|
|
|
|
2009-07-09 19:03:02 -07:00
|
|
|
v.addEventListener("ended", playbackEnded, false);
|
|
|
|
v.addEventListener("loadedmetadata", startTest, false);
|
|
|
|
v.addEventListener("seeking", seekStarted, false);
|
|
|
|
v.addEventListener("seeked", seekEnded, false);
|
|
|
|
|
|
|
|
}
|
2014-07-31 11:37:00 -07:00
|
|
|
|
|
|
|
manager.runTests(createTestArray(), startTest);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|