<!DOCTYPE html>
<html>
<head>
    <title>media-webm-vorbis-partial</title>
    <script src="../../media/media-source/media-source-loader.js"></script>
    <script src="../../media/video-test.js"></script>
    <script>
    var loader;
    var source;
    var sourceBuffer;

    function loaderPromise(loader) {
        return new Promise((resolve, reject) => {
            loader.onload = resolve;
            loader.onerror = reject;
        });
    }

    window.addEventListener('load', async event => {
        try {
            findMediaElement();
            loader = new MediaSourceLoader('content/test-vorbis-manifest.json');
            await loaderPromise(loader);

            source = new MediaSource();
            run('video.src = URL.createObjectURL(source)');
            await waitFor(source, 'sourceopen');
            waitFor(video, 'error').then(failTest);

            run('sourceBuffer = source.addSourceBuffer(loader.type())');
            run('sourceBuffer.appendBuffer(loader.initSegment())');
            await waitFor(sourceBuffer, 'update');

            consoleWrite('Divide the first media segment in two.');
            run('partial1 = loader.mediaSegment(0).slice(0, loader.mediaSegment(0).byteLength / 2)');
            run('partial2 = loader.mediaSegment(0).slice(loader.mediaSegment(0).byteLength / 2)');

            consoleWrite('Append a partial media segment.')
            run('sourceBuffer.appendBuffer(partial1)');
            await waitFor(sourceBuffer, 'update');
            testExpected('sourceBuffer.buffered.length', '1');
            testExpected('sourceBuffer.buffered.end(0).toFixed(2)', '0.64', '==');

            consoleWrite('Complete the partial media segment.')
            run('sourceBuffer.appendBuffer(partial2)');
            await waitFor(sourceBuffer, 'update');

            testExpected('sourceBuffer.buffered.length', '1');
            testExpected('sourceBuffer.buffered.end(0).toFixed(2)', '1.34', '==');
            testExpected('sourceBuffer.buffered.end(0) == source.duration', true);

            endTest();
        } catch (e) {
            failTest(`Caught exception: "${e}"`);
        }
    });
    </script>
</head>
<body>
    <video controls></video>
</body>
</html>
