Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ca733ddfbe
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 91 lines (77 sloc) 3.511 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90

<html>
    <head>
        <!-- LayoutTests location is hard-coded to avoid duplication of code. -->
        <script src="http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/media-file.js"></script>
        <script src="http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/video-test.js"></script>

        <script>
            var expectedRates = { "defaultPlaybackRate" : 1, "playbackRate" : 1};
            var playingFromScript = false;
            var changedRate = false;

            function absoluteUrl(url)
            {
                var a = document.createElement('a');
                a.href = url;
                return a.href;
            }

            function testRates()
            {
                consoleWrite("");
                var playWithControllerButton = !changedRate && !playingFromScript;
                testExpected("video.playbackRate", playWithControllerButton ? expectedRates['defaultPlaybackRate'] : expectedRates['playbackRate']);
                testExpected("video.defaultPlaybackRate", expectedRates['defaultPlaybackRate']);
                changedRate = false;
            }

            function playing()
            {
                consoleWrite("<br>'playing' event");
                expectedRates['playbackRate'] = playingFromScript ? video.playbackRate : video.defaultPlaybackRate;
                testRates();
                playingFromScript = false;
            }

            function ratechange()
            {
                consoleWrite("<br>'ratechange' event");
                testRates();
            }

            function start()
            {
                findMediaElement();
                video.addEventListener('ratechange', ratechange);
                video.addEventListener('playing', playing);

                // Use the video file from the svn repository to avoid duplicating the file.
                video.src = absoluteUrl(findMediaFile('video', 'http://svn.webkit.org/repository/webkit/trunk/LayoutTests/media/content/test'));
                testRates();
            }

            function play()
            {
                playingFromScript = true;
                video.play();
            }

            function setRate(which, rate)
            {
                changedRate = true;
                video[which] = rate;
                expectedRates[which] = rate;
            }

        </script>
    </head>

    <body onload="start()">
        
        <video controls > </video>
        <ul>
            <li>The current 'playbackRate' and 'defaultPlaybackRate' should be logged every time either changes.</li>
            <li>'playbackRate' should be set to 'defaultPlaybackRate' when the Play button in the built-in controls is pressed</li>
            <li>'playbackRate' should NOT when play() is called from script.</li>
        </ul>
        <div>
            <button id="controls" onclick="setRate('defaultPlaybackRate', 2)">defaultPlaybackRate = 2</button>
            <button id="controls" onclick="setRate('defaultPlaybackRate', 1)">defaultPlaybackRate = 1</button>
            <button id="controls" onclick="setRate('playbackRate', 2)">playbackRate = 2</button>
            <button id="controls" onclick="setRate('playbackRate', 1)">playbackRate = 1</button>
        </div>
        <div>
            <button id="controls" onclick="play()">play()</button>
            <button id="controls" onclick="video.pause()">pause()</button>
        </div>
        <br>
    </body>
</html>
Something went wrong with that request. Please try again.