blob: bade84628b5dbcc97e5eb4c3858b298872cda61e [file] [log] [blame]
commit-queue@webkit.orge4497322017-12-02 05:39:30 +00001<!DOCTYPE html>
2<html>
3<head>
4 <title>media-source-range-ends</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 initSegment;
11 var samples;
12 var bufferedSamples;
13
14 if (window.internals)
15 internals.initializeMockMediaSource();
16
17 function runTest()
18 {
19 findMediaElement();
20
21 source = new MediaSource();
22 waitForEventOn(source, 'sourceopen', sourceOpen);
23 run('video.src = URL.createObjectURL(source)');
24 }
25
26 function sourceOpen()
27 {
28 run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
29 waitForEventOn(sourceBuffer, 'updateend', loadSamples1, false, true);
30 initSegment = makeAInit(6, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
31 run('sourceBuffer.appendBuffer(initSegment)');
32 }
33
34 function loadSamples1()
35 {
36 samples = concatenateSamples([
aboya@igalia.comace40032018-10-31 21:04:07 +000037 makeASample(3, 3, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
38 makeASample(4, 4, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
39 makeASample(5, 5, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
commit-queue@webkit.orge4497322017-12-02 05:39:30 +000040 ]);
41 waitForEventOn(sourceBuffer, 'updateend', loadSamples2, false, true);
42 run('sourceBuffer.appendBuffer(samples)');
43 }
44
45 function loadSamples2()
46 {
47 samples = concatenateSamples([
aboya@igalia.comace40032018-10-31 21:04:07 +000048 makeASample(0, 0, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
49 makeASample(1, 1, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
50 makeASample(2, 2, 1, 1, 1, SAMPLE_FLAG.SYNC, 0),
commit-queue@webkit.orge4497322017-12-02 05:39:30 +000051 ]);
52 waitForEventOn(sourceBuffer, 'updateend', samplesAdded, false, true);
53 run('sourceBuffer.appendBuffer(samples)');
54 }
55
56 function samplesAdded()
57 {
58 bufferedSamples = internals.bufferedSamplesForTrackID(sourceBuffer, 1);
59 testExpected("bufferedSamples.length", 6);
60 bufferedSamples.forEach(consoleWrite);
61
62 testExpected("sourceBuffer.buffered.length", 1);
63 testExpected("sourceBuffer.buffered.start(0)", 0);
64 testExpected("sourceBuffer.buffered.end(0)", 6);
65
66 endTest();
67 }
68 </script>
69</head>
70<body onload="runTest()">
71 <video></video>
72</body>