4 <script src=media-file.js></script>
5 <script src=video-test.js></script>
13 if (video.readyState < HTMLMediaElement.HAVE_METADATA) {
14 setTimeout(play, 100);
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
26 waitForEvent("seeked", seeked);
27 run("video.currentTime = video.duration - 0.4");
36 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>");
37 testExpected("video.paused", true);
38 testExpected("video.ended", false);
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);
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");
57 consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>");
58 testExpected("video.paused", true);
59 testExpected("video.ended", false);
64 failTest("Video should have only seeked three times.");
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);
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;
111 <video controls autoplay ></video>
112 <p><b>Test looping by:</b>
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>
120 <script>start()</script>