gecko/dom/media/mediasource/test/test_SplitAppendDelay.html

48 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>MSE: append segments with delay</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="mediasource.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
runWithMSE(function (ms, v) {
ms.addEventListener("sourceopen", function () {
var sb = ms.addSourceBuffer("video/webm");
fetchWithXHR("seek.webm", function (arrayBuffer) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 0, 318));
var first = true;
sb.addEventListener("updateend", function () {
if (first) {
window.setTimeout(function () {
sb.appendBuffer(new Uint8Array(arrayBuffer, 318));
first = false;
}, 1000);
} else {
ms.endOfStream();
}
});
v.play();
});
});
v.addEventListener("ended", function () {
// XXX: Duration should be exactly 4.0, see bug 1065207.
ok(Math.abs(v.duration - 4) <= 0.002, "Video has correct duration");
ok(Math.abs(v.currentTime - 4) <= 0.002, "Video has played to end");
SimpleTest.finish();
});
});
</script>
</pre>
</body>
</html>