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