2009-05-18 15:47:08 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=493187
|
|
|
|
-->
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<title>Bug 493187 - enter HAVE_FUTURE_DATA when seeking within buffered data even if new data isn't arriving</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
2010-05-30 15:02:06 -07:00
|
|
|
<script type="text/javascript" src="manifest.js"></script>
|
2009-05-18 15:47:08 -07:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=493187">Mozilla Bug 493187</a>
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
|
2014-09-10 22:24:00 -07:00
|
|
|
// Decrease parallelism for this test requires decent decoding performance in
|
|
|
|
// order to pass the test.
|
|
|
|
PARALLEL_TESTS = 1;
|
2013-02-27 10:37:19 -08:00
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
var manager = new MediaTestManager;
|
2010-05-30 15:02:06 -07:00
|
|
|
|
2014-09-10 22:24:00 -07:00
|
|
|
function finish(v) {
|
|
|
|
v.onerror = null;
|
|
|
|
removeNodeAndSource(v);
|
|
|
|
manager.finished(v.token);
|
2009-05-18 15:47:08 -07:00
|
|
|
}
|
|
|
|
|
2014-09-10 22:24:00 -07:00
|
|
|
function timeupdate(e) {
|
2010-05-30 15:02:06 -07:00
|
|
|
var v = e.target;
|
2014-09-10 22:24:00 -07:00
|
|
|
var b = v.buffered;
|
|
|
|
var start = b.start(0);
|
|
|
|
var end = b.end(0);
|
|
|
|
// We got enough data buffered, try to seek within the buffered range.
|
|
|
|
if (end - start >= v.duration / 2) {
|
|
|
|
info("[" + v._name + "] buffered start=" + start + " end=" + end);
|
|
|
|
v.ontimeupdate = null;
|
|
|
|
// Seek to the middle of the buffered range.
|
|
|
|
var t = (start + end) / 2;
|
|
|
|
info("[" + v._name + "] seeking to " + t);
|
|
|
|
v.currentTime = t;
|
2009-05-18 15:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-17 22:07:02 -07:00
|
|
|
function seeked(e) {
|
|
|
|
var v = e.target;
|
2014-09-10 22:24:00 -07:00
|
|
|
info("[" + v._name + "] seeked currentTime=" + v.currentTime + " readyState=" + v.readyState);
|
|
|
|
// Having seeked within the buffered range, readyState should be at least
|
|
|
|
// HAVE_FUTURE_DATA now or later (buffered data becoming decoded data).
|
|
|
|
if (v.readyState >= v.HAVE_FUTURE_DATA) {
|
|
|
|
finish(v);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
v.oncanplay = function() {
|
|
|
|
info("[" + v._name + "] oncanplay currentTime=" + v.currentTime + " readyState=" + v.readyState);
|
|
|
|
// Pass the test when we receive "oncanplay". Don't check |readyState >= HAVE_FUTURE_DATA|
|
|
|
|
// for "oncanplay" is dispatched asynchronously, readyState could be changed
|
|
|
|
// before "oncanplay" is received.
|
|
|
|
v.oncanplay = null;
|
|
|
|
v.onended = null;
|
|
|
|
finish(v);
|
|
|
|
}
|
|
|
|
v.onended = function() {
|
|
|
|
v.oncanplay = null;
|
|
|
|
v.onended = null;
|
|
|
|
ok(false, "[" + v._name + "] readyState=" + v.readyState + " not reaching HAVE_FUTURE_DATA before ended");
|
|
|
|
finish(v);
|
|
|
|
}
|
2014-06-17 22:07:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function error(e) {
|
|
|
|
var v = e.target;
|
2014-09-10 22:24:00 -07:00
|
|
|
info("[" + v._name + "] error=" + v.error.code);
|
|
|
|
finish(v);
|
2014-06-17 22:07:02 -07:00
|
|
|
}
|
|
|
|
|
2010-08-26 19:11:46 -07:00
|
|
|
function startTest(test, token) {
|
2010-05-30 15:02:06 -07:00
|
|
|
var v = document.createElement('video');
|
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;
|
2014-09-10 22:24:00 -07:00
|
|
|
v.ontimeupdate = timeupdate;
|
|
|
|
v.onseeked = seeked;
|
|
|
|
v.onerror = error;
|
2010-05-30 15:02:06 -07:00
|
|
|
document.body.appendChild(v);
|
2014-09-10 22:24:00 -07:00
|
|
|
v.play();
|
2010-05-30 15:02:06 -07:00
|
|
|
}
|
|
|
|
|
2013-06-14 15:13:44 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
|
|
|
|
function beginTest() {
|
|
|
|
manager.runTests(gSeekTests, startTest);
|
|
|
|
}
|
2009-05-18 15:47:08 -07:00
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|