e303778d9f8dda4ead08be7eff038a3a8a121eba
[WebKit-https.git] / LayoutTests / compositing / resources / media-testing.js
1
2 if (window.layoutTestController)
3     layoutTestController.waitUntilDone();
4
5 function ensureFrameVisible(video, videoRenderedCallback)
6 {
7     video.addEventListener('timeupdate', function() {
8         video.pause();
9         video.currentTime = 0;
10         if (videoRenderedCallback)
11             videoRenderedCallback();
12     }, false);
13     
14     video.play();
15 }
16
17 function setupVideo(videoElement, videoPath, canPlayThroughCallback, videoRenderedCallback)
18 {
19     var mediaFile = findMediaFile("video", videoPath);
20     videoElement.addEventListener("canplaythrough", function () {
21         if (canPlayThroughCallback)
22             canPlayThroughCallback();
23         ensureFrameVisible(this, videoRenderedCallback);
24     }, false);
25     videoElement.src = mediaFile;
26 }