summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/compositing/video-frame-size-change.html
blob: 801a33b99bf5b9c4f4aa97354ad909e39bd1ebf5 (plain)
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
<!DOCTYPE html>
<html>
    <body onload="load()">
        <p>Tests decoding and rendering a video element that has a changing resolution.</p>
        <video width=320></video>
        <video width=320></video>
        <script>
            if (window.testRunner) {
                testRunner.waitUntilDone();
            }

            function load() {
                var canplayCount = 0;
                function oncanplay() {
                    if (++canplayCount < 2) {
                        return;
                    }
                    // Make sure we render the first frame.
                    requestAnimationFrame(function() {
                        video.play();
                    });
                };

                // Get the first video to stay on frame zero for comparison purposes.
                var video = document.getElementsByTagName("video")[0];
                video.src = "../media/resources/frame_size_change.webm";
                video.addEventListener('canplay', oncanplay);

                // Get the second video to play through the clip with changing dimensions.
                video = document.getElementsByTagName("video")[1];
                video.src = "../media/resources/frame_size_change.webm";
                video.addEventListener('canplay', oncanplay);

                video.addEventListener('playing', function() {
                    // Make sure the video plays for a bit.
                    video.addEventListener('timeupdate', function() {
                        if (video.currentTime > 1.0) {
                            video.pause();
                        }
                    });
                });

                video.addEventListener('pause', function() {
                    // Now seek back to a point where resolution should be different.
                    video.addEventListener('seeked', function() {
                        if (window.testRunner) {
                            testRunner.notifyDone();
                        }
                    });

                    video.currentTime = 0.5;
                });
            }
        </script>
   </body>
</html>