Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / video-loop.html
blob4e44416754b58ee0508ab8abe7788dd0ffd2da00
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
7 <script>
8 var seekCount = 0;
9 var playCount = 0;
11 function play()
13 if (video.readyState < HTMLMediaElement.HAVE_METADATA) {
14 setTimeout(play, 100);
15 return;
18 if (++playCount > 1)
19 return;
21 consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>");
22 testExpected("video.paused", false);
24 // Pause playback so the movie can't possibly loop before the seeked event fires
25 run("video.pause()");
26 waitForEvent("seeked", seeked);
27 run("video.currentTime = video.duration - 0.4");
28 consoleWrite("");
31 function seeked()
33 switch (++seekCount)
35 case 1:
36 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>");
37 testExpected("video.paused", true);
38 testExpected("video.ended", false);
39 run("video.play()");
40 consoleWrite("");
41 break;
42 case 2:
43 consoleWrite("<br><em>++ second seek completed because video looped, toggle 'loop' and seek to near end again.</em>");
44 testExpected("video.paused", false);
45 testExpected("video.ended", false);
46 run("video.pause()");
48 testExpected("mediaElement.currentTime", 0, '>=');
50 // don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines
51 reportExpected(mediaElement.currentTime < mediaElement.duration, "mediaElement.currentTime", "<", "mediaElement.duration", mediaElement.currentTime);
52 run("video.loop = false");
53 run("video.currentTime = video.duration - 0.4");
54 consoleWrite("");
55 break;
56 case 3:
57 consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>");
58 testExpected("video.paused", true);
59 testExpected("video.ended", false);
60 run("video.play()");
61 consoleWrite("");
62 break;
63 default:
64 failTest("Video should have only seeked three times.");
65 break;
70 function ended()
72 consoleWrite("<br><em>++ played to end and stopped.</em>");
73 testExpected("video.ended", true);
75 // don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines
76 reportExpected(mediaElement.currentTime == mediaElement.duration, "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.currentTime);
78 consoleWrite("");
79 endTest();
82 function start()
84 findMediaElement();
86 consoleWrite("<em>++ Test setting/removing the attribute.</em>");
87 testExpected("video.getAttribute('loop')", null);
88 testExpected("video.loop", false);
90 run("video.loop = true");
91 testExpected("video.loop", true);
92 testExpected("video.getAttribute('loop')", null, "!=");
94 run("video.removeAttribute('loop')");
95 testExpected("video.loop", false);
97 waitForEvent('pause');
98 waitForEvent('play', play);
99 waitForEvent("ended", ended);
101 consoleWrite("<br><em>++ Set 'loop' to true and begin playing.</em>");
102 var mediaFile = findMediaFile("video", "content/test");
103 run("video.loop = true");
104 video.src = mediaFile;
105 consoleWrite("");
107 </script>
109 </head>
110 <body>
111 <video controls autoplay ></video>
112 <p><b>Test looping by:</b>
113 <ol>
114 <li>Play to end with 'loop' set to true.</li>
115 <li>When 'seeked' event fires, verify that time has jumped back and movie is playing.</li>
116 <li>Set 'loop' to false and play again.</li>
117 <li>Verify that 'ended' event fires.</li>
118 </ol>
119 </p>
120 <script>start()</script>
121 </body>
122 </html>