OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src=media-file.js></script> |
| 5 <script src=video-test.js></script> |
| 6 |
| 7 <script> |
| 8 function start() |
| 9 { |
| 10 findMediaElement(); |
| 11 var mediaFile = findMediaFile("video", "content/test"); |
| 12 video.src = mediaFile; |
| 13 |
| 14 consoleWrite("<br><em>++ Video is initially paused and 'loop' un
set.</em>"); |
| 15 testExpected("video.paused", true) |
| 16 testExpected("video.loop", false); |
| 17 |
| 18 seekThenPlayWhenReady(); |
| 19 } |
| 20 |
| 21 function seekThenPlayWhenReady() { |
| 22 if (video.readyState < HTMLMediaElement.HAVE_METADATA) { |
| 23 setTimeout(seekThenPlayWhenReady, 100); |
| 24 return; |
| 25 } |
| 26 |
| 27 consoleWrite("<br><em>++ Seek to just before the end of the vide
o and play.</em>"); |
| 28 run("video.currentTime = video.duration - .5"); |
| 29 waitForEvent("play"); |
| 30 waitForEvent("ended", ended); |
| 31 run("video.play()"); |
| 32 consoleWrite(""); |
| 33 } |
| 34 |
| 35 function ended() |
| 36 { |
| 37 consoleWrite("<br><em>++ Verify played to end and stopped.</em>"
); |
| 38 testExpected("video.ended", true); |
| 39 testExpected("video.paused", true); |
| 40 // Using reportExpected to avoid logging floating point value wh
ich may differ across engines. |
| 41 reportExpected(video.currentTime == video.duration, "video.curre
ntTime", "==", "video.duration", video.currentTime); |
| 42 |
| 43 consoleWrite("<br><em>++ With playback ended, set 'loop' attribu
te. This will cause ended == false; looping video cannot be 'ended', only paused
.</em>"); |
| 44 testExpected("video.loop", false); |
| 45 run("video.loop = true"); |
| 46 testExpected("video.loop", true); |
| 47 testExpected("video.ended", false); |
| 48 testExpected("video.paused", true); |
| 49 |
| 50 consoleWrite("<br><em>++ Play video with 'loop' set. Expect seek
back to start.<em>"); |
| 51 waitForEvent("seeked", seeked); |
| 52 run("video.play()"); |
| 53 consoleWrite(""); |
| 54 } |
| 55 |
| 56 function seeked() |
| 57 { |
| 58 consoleWrite("<br><em>++ Observed seek. Verify current time decr
eased and still playing.</em>"); |
| 59 testExpected("video.loop", true); |
| 60 testExpected("video.paused", false); |
| 61 testExpected("video.ended", false); |
| 62 // Using reportExpected to avoid logging floating point value wh
ich may differ across engines. |
| 63 reportExpected(video.currentTime < video.duration, "video.curren
tTime", "<", "video.duration", video.currentTime); |
| 64 |
| 65 consoleWrite("<br><em>++ Pausing now that test is over to preven
t additional unwanted looping.</em>"); |
| 66 run("video.pause()"); |
| 67 consoleWrite(""); |
| 68 endTest(); |
| 69 } |
| 70 </script> |
| 71 |
| 72 </head> |
| 73 <body> |
| 74 <video controls></video> |
| 75 <p><b>Test looping edge case to verify http://crbug.com/364442. Steps:</
b> |
| 76 <ol> |
| 77 <li>Seek toward end of video (for faster testing).</li> |
| 78 <li>Play video to end with 'loop' set to false.</li> |
| 79 <li>Once ended, set 'loop' to true.</li> |
| 80 <li>Call play.</li> |
| 81 <li>Verify that 'seeked' event fires, seeking back to the beginning.
</li> |
| 82 <li>Pause video and end test.</li> |
| 83 </ol> |
| 84 </p> |
| 85 <script>start()</script> |
| 86 </body> |
| 87 </html> |
OLD | NEW |