OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <body onload="load()"> | |
4 <p>Test that a video element scales decoded frames to match the initial
size | |
5 as opposed to changing the size of the element.</p> | |
6 <video width="320"></video> | |
7 <video></video> | |
8 | |
9 <script> | |
10 if (window.testRunner) { | |
11 testRunner.waitUntilDone(); | |
12 } | |
13 | |
14 function load() | |
15 { | |
16 var video = document.getElementsByTagName("video")[1]; | |
17 var video_fixed_size = document.getElementsByTagName("video")[0]
; | |
18 video.src = "resources/frame_size_change.webm"; | |
19 video_fixed_size.src = "resources/frame_size_change.webm"; | |
20 | |
21 // Expect no resize event after the initial one because the tag'
s size (the frames' | |
22 // "natural size") doesn't change, only the internal resolution | |
23 // does. Fail if this expectation is violated. | |
24 var expectedResizeCount = 2; // One event per <video>. | |
25 video.addEventListener('resize', onresize); | |
26 video_fixed_size.addEventListener('resize', onresize); | |
27 function onresize() | |
28 { | |
29 if (--expectedResizeCount >= 0) { | |
30 return; | |
31 } | |
32 document.body.appendChild(document.createTextNode('FAIL: une
xpected resize')); | |
33 if (window.testRunner) { | |
34 testRunner.notifyDone(); | |
35 } | |
36 } | |
37 | |
38 var canplayCount = 0; | |
39 function oncanplay() | |
40 { | |
41 if (++canplayCount < 2) { | |
42 return; | |
43 } | |
44 | |
45 if (expectedResizeCount != 0) { | |
46 document.body.appendChild(document.createTextNode('FAIL:
missing resize event')); | |
47 if (window.testRunner) { | |
48 testRunner.notifyDone(); | |
49 } | |
50 } | |
51 | |
52 // Make sure we render the first frame. | |
53 if (window.testRunner) { | |
54 testRunner.display(); | |
55 } | |
56 | |
57 video.play(); | |
58 video_fixed_size.play(); | |
59 video.removeEventListener('canplay', oncanplay); | |
60 video_fixed_size.removeEventListener('canplay', oncanplay); | |
61 }; | |
62 video.addEventListener('canplay', oncanplay); | |
63 video_fixed_size.addEventListener('canplay', oncanplay); | |
64 | |
65 var playingCount = 0; | |
66 function onplaying() | |
67 { | |
68 if (++playingCount < 2) { | |
69 return; | |
70 } | |
71 | |
72 video.removeEventListener('playing', onplaying); | |
73 video_fixed_size.removeEventListener('playing', onplaying); | |
74 | |
75 // Make sure both videos play for a bit. | |
76 function ontimeupdate(e) | |
77 { | |
78 if (e.target.currentTime > 1.0) { | |
79 e.target.pause(); | |
80 } | |
81 }; | |
82 video.addEventListener('timeupdate', ontimeupdate); | |
83 video_fixed_size.addEventListener('timeupdate', ontimeupdate
); | |
84 }; | |
85 video.addEventListener('playing', onplaying); | |
86 video_fixed_size.addEventListener('playing', onplaying); | |
87 | |
88 var pauseCount = 0; | |
89 function onpause() | |
90 { | |
91 if (++pauseCount < 2) { | |
92 return; | |
93 } | |
94 | |
95 var seekedCount = 0; | |
96 function onseeked() | |
97 { | |
98 if (++seekedCount < 2) { | |
99 return; | |
100 } | |
101 | |
102 if (window.testRunner) { | |
103 testRunner.notifyDone(); | |
104 } | |
105 } | |
106 | |
107 video.addEventListener('seeked', onseeked); | |
108 video_fixed_size.addEventListener('seeked', onseeked); | |
109 | |
110 video.currentTime = 1.0; | |
111 video_fixed_size.currentTime = 0.5; | |
112 }; | |
113 video.addEventListener('pause', onpause); | |
114 video_fixed_size.addEventListener('pause', onpause); | |
115 } | |
116 </script> | |
117 </body> | |
118 </html> | |
OLD | NEW |