blob: 787490945e7661132954a2ff5cf6371cf7558722 [file] [log] [blame]
commit-queue@webkit.orge8f13d72015-01-24 00:52:42 +00001<!DOCTYPE html>
2<html>
3<head>
4 <title>mock-media-source</title>
5 <script src="mock-media-source.js"></script>
6 <script src="../video-test.js"></script>
7 <script>
8 var source;
9 var sourceBuffer;
10 var mediaSegment;
11
12 if (window.internals)
13 internals.initializeMockMediaSource();
14
15 function runTest() {
16 findMediaElement();
17
18 source = new MediaSource();
19 waitForEventOn(source, 'sourceopen', sourceOpen, false, true);
20 run('video.src = URL.createObjectURL(source)');
21 }
22
23 function sourceOpen() {
24 run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
25 waitForEventOn(sourceBuffer, 'updateend', updateEnd1, false, true);
26 mediaSegment = concatenateSamples([
27 makeAInit(10, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]),
aboya@igalia.comace40032018-10-31 21:04:07 +000028 makeASample(0, 0, 5, 1, 1, SAMPLE_FLAG.SYNC, 0),
commit-queue@webkit.orge8f13d72015-01-24 00:52:42 +000029 ]);
30 run('sourceBuffer.appendBuffer(mediaSegment)');
31
32 }
33
34 function updateEnd1() {
35 testExpected('source.duration.toFixed(3)', 10);
36 testExpected('sourceBuffer.buffered.end(0).toFixed(3)', 5);
37
38 waitForEventOn(source, 'sourceopen', function() { failTest("Should not transit to 'open' state during endOfStream().") }, false, true);
commit-queue@webkit.orge8f13d72015-01-24 00:52:42 +000039 run('source.endOfStream()');
40 testExpected('source.duration.toFixed(3)', 5);
jer.noble@apple.comaae356e2016-09-12 21:09:15 +000041 testExpected('sourceBuffer.updating', false);
42 endTest();
commit-queue@webkit.orge8f13d72015-01-24 00:52:42 +000043 }
44
45 </script>
46</head>
47<body onload="runTest()">
48 <video></video>
49</body>
50</html>