| <!DOCTYPE html> |
| <html> |
| <body onload="load()"> |
| <p>Test that a video element scales decoded frames to match the initial size |
| as opposed to changing the size of the element.</p> |
| <video width="320"></video> |
| <video></video> |
| |
| <script> |
| if (window.testRunner) { |
| testRunner.waitUntilDone(); |
| } |
| |
| function load() |
| { |
| var video = document.getElementsByTagName("video")[1]; |
| var video_fixed_size = document.getElementsByTagName("video")[0]; |
| video.src = "resources/frame_size_change.webm"; |
| video_fixed_size.src = "resources/frame_size_change.webm"; |
| |
| // Expect no resize event after the initial one because the tag's size (the frames' |
| // "natural size") doesn't change, only the internal resolution |
| // does. Fail if this expectation is violated. |
| var expectedResizeCount = 2; // One event per <video>. |
| video.addEventListener('resize', onresize); |
| video_fixed_size.addEventListener('resize', onresize); |
| function onresize() |
| { |
| if (--expectedResizeCount >= 0) { |
| return; |
| } |
| document.body.appendChild(document.createTextNode('FAIL: unexpected resize')); |
| if (window.testRunner) { |
| testRunner.notifyDone(); |
| } |
| } |
| |
| var canplayCount = 0; |
| function oncanplay() |
| { |
| if (++canplayCount < 2) { |
| return; |
| } |
| |
| if (expectedResizeCount != 0) { |
| document.body.appendChild(document.createTextNode('FAIL: missing resize event')); |
| if (window.testRunner) { |
| testRunner.notifyDone(); |
| } |
| } |
| |
| // Make sure we render the first frame. |
| if (window.testRunner) { |
| testRunner.display(); |
| } |
| |
| video.play(); |
| video_fixed_size.play(); |
| video.removeEventListener('canplay', oncanplay); |
| video_fixed_size.removeEventListener('canplay', oncanplay); |
| }; |
| video.addEventListener('canplay', oncanplay); |
| video_fixed_size.addEventListener('canplay', oncanplay); |
| |
| var playingCount = 0; |
| function onplaying() |
| { |
| if (++playingCount < 2) { |
| return; |
| } |
| |
| video.removeEventListener('playing', onplaying); |
| video_fixed_size.removeEventListener('playing', onplaying); |
| |
| // Make sure both videos play for a bit. |
| function ontimeupdate(e) |
| { |
| if (e.target.currentTime > 1.0) { |
| e.target.pause(); |
| } |
| }; |
| video.addEventListener('timeupdate', ontimeupdate); |
| video_fixed_size.addEventListener('timeupdate', ontimeupdate); |
| }; |
| video.addEventListener('playing', onplaying); |
| video_fixed_size.addEventListener('playing', onplaying); |
| |
| var pauseCount = 0; |
| function onpause() |
| { |
| if (++pauseCount < 2) { |
| return; |
| } |
| |
| var seekedCount = 0; |
| function onseeked() |
| { |
| if (++seekedCount < 2) { |
| return; |
| } |
| |
| if (window.testRunner) { |
| testRunner.notifyDone(); |
| } |
| } |
| |
| video.addEventListener('seeked', onseeked); |
| video_fixed_size.addEventListener('seeked', onseeked); |
| |
| video.currentTime = 1.0; |
| video_fixed_size.currentTime = 0.5; |
| }; |
| video.addEventListener('pause', onpause); |
| video_fixed_size.addEventListener('pause', onpause); |
| } |
| </script> |
| </body> |
| </html> |