<html>
<head>
</head>
<body onload="start()">
<p>Start playing a video with preloading enabled, do a seek near the
  end and check multiple buffered timeranges have been created.</p>
<video id="video" preload="auto" autobuffer></video>
<script src=../../media-resources/video-test.js></script>
<script src=../../media-resources/media-file.js></script>
<script>
    waitForEvent("ended", ended);
    waitForEventOnce('playing', function() {
        testExpected("video.buffered.length", 1, "==");
        run("video.currentTime = video.duration - 0.5");
    });

    function ended() {
        testExpected("video.buffered.length", 2, "==");
        endTest();
    }

    function start () {
        video = document.getElementById('video');
        var mediaFile = findMediaFile("audio", "../../../media/content/test");
        var type = mimeTypeForExtension(mediaFile.split('.').pop());
        video.src = "http://127.0.0.1:8000/media/video-throttled-load.cgi?nph=1&name=" + mediaFile + "&throttle=100&type=" + type;

        video.play();
    }
</script>
</body>
</html>
