[chromium] compositing tests with videos fail in chromium DumpRenderTree, seeking...
[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     var playingHandler = function() {
8         video.pause();
9         video.currentTime = 0;
10     };
11
12     var seekedHandler = function() {
13         if (videoRenderedCallback)
14             videoRenderedCallback();
15     };
16
17     video.addEventListener('playing', playingHandler, false);
18     video.addEventListener('seeked', seekedHandler, false);
19     video.play();
20 }
21
22 function setupVideo(videoElement, videoPath, canPlayThroughCallback, videoRenderedCallback)
23 {
24     var mediaFile = findMediaFile("video", videoPath);
25     videoElement.addEventListener("canplaythrough", function () {
26         if (canPlayThroughCallback)
27             canPlayThroughCallback();
28         ensureFrameVisible(this, videoRenderedCallback);
29     }, false);
30     videoElement.src = mediaFile;
31 }