Bug 1065855 - Tests for MediaSource seekable range - r=kinetik

--HG--
extra : rebase_source : 01d29379c8e4541c72f6fcd186506ba4e9d3f28c
This commit is contained in:
Chris Double 2014-09-16 15:16:02 +12:00
parent 0b2d3d20ab
commit a30b928ab3
6 changed files with 191 additions and 1 deletions

View File

@ -8,6 +8,9 @@ support-files =
[test_BufferedSeek.html]
[test_FrameSelection.html]
[test_MediaSource.html]
[test_SeekableAfterEndOfStream.html]
[test_SeekableAfterEndOfStreamSplit.html]
[test_SeekableBeforeEndOfStream.html]
[test_SeekableBeforeEndOfStreamSplit.html]
[test_SplitAppendDelay.html]
[test_SplitAppend.html]

View File

@ -41,6 +41,11 @@ runWithMSE(function () {
v.src = o;
document.body.appendChild(v);
var loadedmetadataCount = 0;
var updatestartCount = 0;
var updateendCount = 0;
var updateCount = 0;
ms.addEventListener("sourceopen", function () {
ok(true, "Receive a sourceopen event");
is(ms.readyState, "open", "MediaSource must be in open state after sourceopen");
@ -57,11 +62,17 @@ runWithMSE(function () {
sb.addEventListener("update", function () {
is(sb.updating, false, "SourceBuffer.updating is expected value in update event");
updateCount++;
ms.endOfStream();
});
sb.addEventListener("updatestart", function () {
updatestartCount++;
});
sb.addEventListener("updateend", function () {
is(sb.updating, false, "SourceBuffer.updating is expected value in updateend event");
updateendCount++;
v.play();
});
});
@ -71,10 +82,18 @@ runWithMSE(function () {
is(ms.readyState, "ended", "MediaSource must be in ended state after sourceended");
});
v.addEventListener("loadedmetadata", function () {
loadedmetadataCount++;
});
v.addEventListener("ended", function () {
// XXX: Duration should be exactly 4.0, see bug 1065207.
is(v.duration, 4.001, "Video has correct duration");
is(v.currentTime, 4.001, "Video has played to end");
is(updateCount, 1, "update event received");
is(updateendCount, 1, "updateend event received");
is(updatestartCount, 1, "updatestart event received");
is(loadedmetadataCount, 1, "loadedmetadata event received");
v.parentNode.removeChild(v);
SimpleTest.finish();
});

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: seekable attribute after end of stream</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));
sb.addEventListener("updateend", function () {
ms.endOfStream()
});
});
var target = 2;
v.addEventListener("loadedmetadata", function () {
ok(v.seekable.length, "Resource is seekable");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: seekable attribute after end of stream with split appendBuffer</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, 25223));
var updateCount = 0;
sb.addEventListener("updateend", function () {
updateCount++;
if (updateCount == 1) {
sb.appendBuffer(new Uint8Array(arrayBuffer, 25223));
}
else {
ms.endOfStream();
}
});
});
var target = 2;
v.addEventListener("loadedmetadata", function () {
ok(v.seekable.length, "Resource is seekable");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: seekable attribute before end of stream</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));
});
var target = 2;
v.addEventListener("loadedmetadata", function () {
ok(v.seekable.length, "Resource is seekable");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
</html>

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML>
<html>
<head>
<title>MSE: seekable attribute before end of stream with split appendBuffer</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, 25223));
sb.addEventListener("updateend", function () {
sb.appendBuffer(new Uint8Array(arrayBuffer, 25223));
});
});
var target = 2;
v.addEventListener("loadedmetadata", function () {
ok(v.seekable.length, "Resource is seekable");
ok(v.seekable.length &&
target >= v.seekable.start(0) &&
target < v.seekable.end(0), "Target is within seekable range");
SimpleTest.finish();
});
});
});
</script>
</pre>
</body>
</html>