gecko/dom/media/test/test_bug493187.html

102 lines
2.9 KiB
HTML
Raw Normal View History

<!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" />
<script type="text/javascript" src="manifest.js"></script>
</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">
// Decrease parallelism for this test requires decent decoding performance in
// order to pass the test.
PARALLEL_TESTS = 1;
var manager = new MediaTestManager;
function finish(v) {
v.onerror = null;
removeNodeAndSource(v);
manager.finished(v.token);
}
function timeupdate(e) {
var v = e.target;
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;
}
}
function seeked(e) {
var v = e.target;
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);
}
}
function error(e) {
var v = e.target;
info("[" + v._name + "] error=" + v.error.code);
finish(v);
}
function startTest(test, token) {
var v = document.createElement('video');
v.token = token;
manager.started(token);
v.src = test.name;
v._name = test.name;
v.ontimeupdate = timeupdate;
v.onseeked = seeked;
v.onerror = error;
document.body.appendChild(v);
v.play();
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["media.cache_size", 40000]]}, beginTest);
function beginTest() {
manager.runTests(gSeekTests, startTest);
}
</script>
</pre>
</body>
</html>