|
Lines 1-66
LayoutTests/media/video-loop.html_sec1
|
|
|
1 |
<!DOCTYPE html> |
| 1 |
<html> |
2 |
<html> |
| 2 |
|
3 |
<head> |
| 3 |
<video controls autoplay ></video> |
4 |
<script src=media-file.js></script> |
| 4 |
|
5 |
<script src=video-test.js></script> |
| 5 |
<script src=media-file.js></script> |
6 |
|
| 6 |
<script src=video-test.js></script> |
7 |
<script> |
| 7 |
|
8 |
var seekCount = 0; |
| 8 |
<script> |
9 |
var playCount = 0; |
| 9 |
|
10 |
|
| 10 |
testExpected("video.getAttribute('loop')", null); |
11 |
function play() |
| 11 |
testExpected("video.loop", false); |
12 |
{ |
| 12 |
|
13 |
if (++playCount > 1) |
| 13 |
run("video.loop = true"); |
14 |
return; |
| 14 |
testExpected("video.loop", true); |
15 |
|
| 15 |
testExpected("video.getAttribute('loop')", null, "!="); |
16 |
consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>"); |
|
|
17 |
testExpected("video.paused", false); |
| 18 |
|
| 19 |
// Pause playback so the movie can't possibly loop before the seeked event fires |
| 20 |
run("video.pause()"); |
| 21 |
waitForEvent("seeked", seeked); |
| 22 |
run("video.currentTime = video.duration - 0.4"); |
| 23 |
consoleWrite(""); |
| 24 |
} |
| 16 |
|
25 |
|
| 17 |
run("video.removeAttribute('loop')"); |
26 |
function seeked() |
| 18 |
testExpected("video.loop", false); |
27 |
{ |
|
|
28 |
switch (++seekCount) |
| 29 |
{ |
| 30 |
case 1: |
| 31 |
consoleWrite("<br><em>++ first seek completed, beginning playback.</em>"); |
| 32 |
testExpected("video.paused", true); |
| 33 |
testExpected("video.ended", false); |
| 34 |
run("video.play()"); |
| 35 |
consoleWrite(""); |
| 36 |
break; |
| 37 |
case 2: |
| 38 |
consoleWrite("<br><em>++ second seek completed because video looped, toggle 'loop' and seek to near end again.</em>"); |
| 39 |
testExpected("video.paused", false); |
| 40 |
testExpected("video.ended", false); |
| 41 |
run("video.pause()"); |
| 42 |
|
| 43 |
testExpected("mediaElement.currentTime", 0, '>='); |
| 44 |
|
| 45 |
// don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines |
| 46 |
reportExpected(mediaElement.currentTime < mediaElement.duration, "mediaElement.currentTime", "<", "mediaElement.duration", mediaElement.currentTime); |
| 47 |
run("video.loop = false"); |
| 48 |
run("video.currentTime = video.duration - 0.4"); |
| 49 |
consoleWrite(""); |
| 50 |
break; |
| 51 |
case 3: |
| 52 |
consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>"); |
| 53 |
testExpected("video.paused", true); |
| 54 |
testExpected("video.ended", false); |
| 55 |
run("video.play()"); |
| 56 |
consoleWrite(""); |
| 57 |
break; |
| 58 |
default: |
| 59 |
failTest("Video should have only seeked three times."); |
| 60 |
break; |
| 61 |
|
| 62 |
} |
| 63 |
} |
| 19 |
|
64 |
|
| 20 |
var respondToTimeUpdate = false; |
65 |
function ended() |
| 21 |
var firstTimeCheck = true; |
|
|
| 22 |
|
| 23 |
waitForEvent('pause'); |
| 24 |
waitForEvent('playing'); |
| 25 |
|
| 26 |
// make sure we are playing, seek to near the end so the test doesn't take too long |
| 27 |
waitForEvent('play', function () { |
| 28 |
testExpected("video.paused", false); |
| 29 |
run("video.currentTime = video.duration - 0.4"); |
| 30 |
|
| 31 |
consoleWrite(""); |
| 32 |
setTimeout(timeCheck, 800); |
| 33 |
} ); |
| 34 |
|
| 35 |
function timeCheck() { |
| 36 |
testExpected("video.ended", !firstTimeCheck); |
| 37 |
if (!firstTimeCheck) |
| 38 |
{ |
66 |
{ |
| 39 |
// don't use "testExpected()" so we won't log the actual duration to the |
67 |
consoleWrite("<br><em>++ played to end and stopped.</em>"); |
| 40 |
// results file, as the floating point result may differ with different engines |
68 |
testExpected("video.ended", true); |
|
|
69 |
|
| 70 |
// don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines |
| 41 |
reportExpected(mediaElement.currentTime == mediaElement.duration, "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.currentTime); |
71 |
reportExpected(mediaElement.currentTime == mediaElement.duration, "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.currentTime); |
|
|
72 |
|
| 73 |
consoleWrite(""); |
| 42 |
endTest(); |
74 |
endTest(); |
| 43 |
return; |
|
|
| 44 |
} |
75 |
} |
| 45 |
|
76 |
|
| 46 |
testExpected("mediaElement.currentTime", 0, '>'); |
77 |
function start() |
| 47 |
testExpected("mediaElement.currentTime", (video.duration - 0.4).toFixed(2), '<'); |
78 |
{ |
| 48 |
run("video.loop = false"); |
79 |
findMediaElement(); |
| 49 |
run("video.currentTime = video.duration - 0.3"); |
|
|
| 50 |
respondToTimeUpdate = true; |
| 51 |
firstTimeCheck = false; |
| 52 |
|
| 53 |
consoleWrite(""); |
| 54 |
setTimeout(timeCheck, 800); |
| 55 |
} |
| 56 |
|
| 57 |
consoleWrite(""); |
| 58 |
run("video.loop = true"); |
| 59 |
var mediaFile = findMediaFile("video", "content/test"); |
| 60 |
run("video.src = '" + mediaFile + "'"); |
| 61 |
consoleWrite(""); |
| 62 |
</script> |
| 63 |
|
80 |
|
| 64 |
</head> |
81 |
consoleWrite("<em>++ Test setting/removing the attribute.</em>"); |
|
|
82 |
testExpected("video.getAttribute('loop')", null); |
| 83 |
testExpected("video.loop", false); |
| 84 |
|
| 85 |
run("video.loop = true"); |
| 86 |
testExpected("video.loop", true); |
| 87 |
testExpected("video.getAttribute('loop')", null, "!="); |
| 88 |
|
| 89 |
run("video.removeAttribute('loop')"); |
| 90 |
testExpected("video.loop", false); |
| 91 |
|
| 92 |
waitForEvent('pause'); |
| 93 |
waitForEvent('play', play); |
| 94 |
waitForEvent("ended", ended); |
| 95 |
|
| 96 |
consoleWrite("<br><em>++ Set 'loop' to true and begin playing.</em>"); |
| 97 |
var mediaFile = findMediaFile("video", "content/test"); |
| 98 |
run("video.loop = true"); |
| 99 |
video.src = mediaFile; |
| 100 |
consoleWrite(""); |
| 101 |
} |
| 102 |
</script> |
| 65 |
|
103 |
|
|
|
104 |
</head> |
| 105 |
<body> |
| 106 |
<video controls autoplay ></video> |
| 107 |
<p><b>Test looping by:</b> |
| 108 |
<ol> |
| 109 |
<li>Play to end with 'loop' set to true.</li> |
| 110 |
<li>When 'seeked' event fires, verify that time has jumped back and movie is playing.</li> |
| 111 |
<li>Set 'loop' to false and play again.</li> |
| 112 |
<li>Verify that 'ended' event fires.</li> |
| 113 |
</ol> |
| 114 |
</p> |
| 115 |
<script>start()</script> |
| 116 |
</body> |
| 66 |
</html> |
117 |
</html> |