[MSE] Removing samples when presentation order does not match decode order can cause...
[WebKit.git] / LayoutTests / media / media-source / media-source-remove-decodeorder-crash.html
1 <!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 initSegment;
11
12     if (window.internals)
13         internals.initializeMockMediaSource();
14
15     function runTest() {
16         findMediaElement();
17
18         source = new MediaSource();
19         waitForEventOn(source, 'sourceopen', sourceOpen);
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', loadSamples, false, true);
26         initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
27         run('sourceBuffer.appendBuffer(initSegment)');
28     }
29
30     function loadSamples() {
31         samples = concatenateSamples([
32             makeASample(0, 0, 1, 1, SAMPLE_FLAG.SYNC),
33             makeASample(2, 1, 1, 1, SAMPLE_FLAG.NONE),
34             makeASample(1, 2, 1, 1, SAMPLE_FLAG.SYNC),
35         ]);
36         waitForEventOn(sourceBuffer, 'updateend', remove, false, true);
37         run('sourceBuffer.appendBuffer(samples)');
38     }
39
40     function remove() {
41         waitForEventOn(sourceBuffer, 'updateend', checkRemoved, false, true);
42         run('sourceBuffer.remove(1.9, 2)');
43     }
44
45     function checkRemoved() {
46         testExpected('sourceBuffer.buffered.length', 1);
47         testExpected('sourceBuffer.buffered.start(0)', 0);
48         testExpected('sourceBuffer.buffered.end(0)', 1);
49         endTest();
50     }
51
52     </script>
53 </head>
54 <body onload="runTest()">
55     <div>This tests the SourceBuffer.remove() API. The test removes samples where the decode and presentation orders differ. Should not crash.</div>
56     <video></video>
57 </body>
58 </html>