Index: LayoutTests/media/video-loop-from-ended.html |
diff --git a/LayoutTests/media/video-loop-from-ended.html b/LayoutTests/media/video-loop-from-ended.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a010768577ef7eb5fd24a40da1c73c5156ec4473 |
--- /dev/null |
+++ b/LayoutTests/media/video-loop-from-ended.html |
@@ -0,0 +1,89 @@ |
+ |
wolenetz
2015/02/13 23:47:46
nit: drop blank line
chcunningham
2015/02/14 02:47:17
Done.
|
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src=media-file.js></script> |
+ <script src=video-test.js></script> |
+ |
+ <script> |
+ function start() |
+ { |
+ findMediaElement(); |
+ var mediaFile = findMediaFile("video", "content/test"); |
+ video.src = mediaFile; |
+ |
wolenetz
2015/02/13 23:47:45
nit: drop the trailing spaces on this line
fyi htt
chcunningham
2015/02/14 02:47:17
Done. And added the trim on save to my config.
|
+ consoleWrite("<br><em>++ Video is initially paused and 'loop' unset.</em>"); |
wolenetz
2015/02/13 23:47:45
nit ditto (trailing spaces)
chcunningham
2015/02/14 02:47:17
Done.
|
+ testExpected("video.paused", true) |
+ testExpected("video.loop", false); |
+ |
+ playWhenReady(); |
wolenetz
2015/02/13 23:47:46
nit: s/play/seekThenPlay/ ? no strong feeling thou
chcunningham
2015/02/14 02:47:17
Done.
|
+ } |
+ |
+ function playWhenReady() { |
+ if (video.readyState < HTMLMediaElement.HAVE_METADATA) { |
+ setTimeout(playWhenReady, 100); |
+ return; |
+ } |
+ |
+ consoleWrite("<br><em>++ Seek to just before the end of the video and play.</em>"); |
+ run("video.currentTime = video.duration - .5"); |
wolenetz
2015/02/13 23:47:45
nit: why .5 versus .4? No strong feeling.. just cu
chcunningham
2015/02/14 02:47:17
This file doesn't reference .4 at all. .4 seemed a
|
+ waitForEvent("play"); |
+ waitForEvent("ended", ended); |
+ run("video.play()"); |
+ consoleWrite(""); |
+ } |
+ |
+ function ended() |
wolenetz
2015/02/13 23:47:45
nit ditto (trailing spaces)
chcunningham
2015/02/14 02:47:17
Done.
|
+ { |
+ consoleWrite("<br><em>++ Verify played to end and stopped.</em>"); |
+ testExpected("video.ended", true); |
+ testExpected("video.paused", true); |
+ // Using reportExpected to avoid logging floating point value which may differ across engines. |
+ reportExpected(video.currentTime == video.duration, "video.currentTime", "==", "video.duration", video.currentTime); |
+ |
+ |
wolenetz
2015/02/13 23:47:45
nit: remove extra blank line
chcunningham
2015/02/14 02:47:17
Done.
|
+ consoleWrite("<br><em>++ With playback ended, set 'loop' attribute. This will cause ended == false; looping video cannot be 'ended', only paused.</em>"); |
+ testExpected("video.loop", false); |
+ run("video.loop = true"); |
+ testExpected("video.loop", true); |
+ testExpected("video.ended", false); |
+ testExpected("video.paused", true); |
+ |
+ consoleWrite("<br><em>++ Play video with 'loop' set. Expect seek back to start.<em>"); |
+ waitForEvent("seeked", seeked); |
+ run("video.play()"); |
+ consoleWrite(""); |
+ } |
+ |
+ function seeked() |
+ { |
+ consoleWrite("<br><em>++ Observed seek. Verify current time decreased and still playing.</em>"); |
+ testExpected("video.loop", true); |
+ testExpected("video.paused", false); |
+ testExpected("video.ended", false); |
+ // Using reportExpected to avoid logging floating point value which may differ across engines. |
+ reportExpected(video.currentTime < video.duration, "video.currentTime", "<", "video.duration", video.currentTime); |
+ |
+ consoleWrite("<br><em>++ Pausing now that test is over to prevent additional unwanted looping.</em>"); |
+ run("video.pause()"); |
+ consoleWrite(""); |
+ endTest(); |
+ } |
+ </script> |
+ |
+ </head> |
+ <body> |
+ <video controls></video> |
+ <p><b>Test looping edge case to verifies crbug.com/364442. Steps:</b> |
+ <ol> |
+ <li>Seek toward end of video (for faster testing).</li> |
+ <li>Play video to end with 'loop' set to false.</li> |
+ <li>Once ended, set 'loop' to true.</li> |
+ <li>Call play.</li> |
+ <li>Verify that 'seeked' event fires, seeking back to the beginning.</li> |
+ <li>Pause video and end test.</li> |
+ </ol> |
+ </p> |
+ <script>start()</script> |
+ </body> |
+</html> |