<!DOCTYPE html>
<html>
<head>
    <title>mock-media-source</title>
    <script src="mock-media-source.js"></script>
    <script src="../video-test.js"></script>
    <script>
    var source;
    var sourceBuffer;
    var initSegment;

    if (window.internals)
        internals.initializeMockMediaSource();

    function runTest() {
        findMediaElement();

        source = new MediaSource();
        waitForEventOn(source, 'sourceopen', sourceOpen);
        run('video.src = URL.createObjectURL(source)');
    }

    function sourceOpen() {
        run('sourceBuffer = source.addSourceBuffer("video/mock; codecs=mock")');
        waitForEventOn(sourceBuffer, 'updateend', loadSamples, false, true);
        initSegment = makeAInit(8, [makeATrack(1, 'mock', TRACK_KIND.VIDEO)]);
        run('sourceBuffer.appendBuffer(initSegment)');
    }

    function loadSamples() {
        samples = concatenateSamples([
            makeASample(0, 0, 1, 1, SAMPLE_FLAG.SYNC),
            makeASample(1, 1, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(2, 2, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(3, 3, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(4, 4, 1, 1, SAMPLE_FLAG.SYNC),
            makeASample(5, 5, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(6, 6, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(7, 7, 1, 1, SAMPLE_FLAG.NONE),
            makeASample(8, 8, 1, 1, SAMPLE_FLAG.SYNC),
        ]);
        waitForEventOn(sourceBuffer, 'updateend', remove, false, true);
        run('sourceBuffer.appendBuffer(samples)');
    }

    function remove() {
        waitForEventOn(sourceBuffer, 'updateend', checkRemoved, false, true);
        run('sourceBuffer.remove(0, 4)');
    }

    function checkRemoved() {
        testExpected('sourceBuffer.buffered.start(0)', 4);
        endTest();
    }

    </script>
</head>
<body onload="runTest()">
    <div>This tests the SourceBuffer.remove() API. The test will remove samples from the given startTime (0) up to but not including the presentation start time of the sync sample (4) after endTime (4).</div>
    <video></video>
</body>
</html>
