2010-05-30 15:02:06 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Media test: seeking off the end of a file</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>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2013-02-26 22:23:08 -08:00
|
|
|
if (navigator.platform.startsWith("Win")) {
|
2013-02-28 12:44:57 -08:00
|
|
|
SimpleTest.expectAssertions(0, 10);
|
2013-02-25 18:39:21 -08:00
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
var manager = new MediaTestManager;
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
// Test if the ended event works correctly.
|
|
|
|
|
|
|
|
function startTest(e) {
|
|
|
|
var v = e.target;
|
|
|
|
checkMetadata(v._name, v, v._test);
|
|
|
|
is(v._loadedMetadata, false, "Should only receive one loadedmetadata event for " + v._name);
|
|
|
|
v._loadedMetadata = true;
|
|
|
|
v.currentTime = 3.0 * v.duration;
|
|
|
|
}
|
|
|
|
|
|
|
|
function playbackEnded(e) {
|
|
|
|
var v = e.target;
|
|
|
|
// We should have dispatched an ended event when we seeked to the end of
|
|
|
|
// media, but we want the ended event which dispatches once playback has
|
|
|
|
// completed after the seek to the beginning.
|
|
|
|
if (!v._played)
|
|
|
|
return;
|
|
|
|
ok(v.ended, "Checking ended set after seeking to EOF and playing for " + v._name);
|
|
|
|
ok(!v._finished, "Should only hit the end once for " + v._name);
|
|
|
|
v._finished = true;
|
2014-01-16 21:58:48 -08:00
|
|
|
removeNodeAndSource(v);
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.finished(v.token);
|
2010-05-30 15:02:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function endSeek(e) {
|
|
|
|
var v = e.target;
|
|
|
|
if (v._seeked)
|
|
|
|
return;
|
|
|
|
v._seeked = true;
|
|
|
|
ok(Math.abs(v.duration - v.currentTime) < 0.1,
|
|
|
|
"Should be at end of media for " + v._name + " t=" + v.currentTime + " d=" + v.duration);
|
|
|
|
v.play();
|
|
|
|
}
|
|
|
|
|
|
|
|
function playing(e) {
|
|
|
|
e.target._played = true;
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
function initTest(test, token) {
|
2013-01-23 11:24:41 -08:00
|
|
|
var type = getMajorMimeType(test.type);
|
2010-05-30 15:02:06 -07:00
|
|
|
var v = document.createElement(type);
|
2014-01-16 21:58:48 -08:00
|
|
|
v.preload = "auto";
|
2010-08-26 19:11:46 -07:00
|
|
|
v.token = token;
|
|
|
|
manager.started(token);
|
2010-05-30 15:02:06 -07:00
|
|
|
v.src = test.name;
|
|
|
|
v._name = test.name;
|
|
|
|
v._finished = false;
|
|
|
|
v._test = test;
|
|
|
|
v._loadedMetadata = false;
|
|
|
|
v._seeked = false;
|
|
|
|
v._played = false;
|
|
|
|
v.addEventListener("loadedmetadata", startTest, false);
|
|
|
|
v.addEventListener("playing", playing, false);
|
|
|
|
v.addEventListener("seeked", endSeek, false);
|
|
|
|
v.addEventListener("ended", playbackEnded, false);
|
|
|
|
document.body.appendChild(v);
|
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
manager.runTests(gSmallTests, initTest);
|
2010-05-30 15:02:06 -07:00
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|