Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: LayoutTests/media/video-loop.html

Issue 898883003: Fixes play seek when user sets loop after ended. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Responding to feedback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src=media-file.js></script> 4 <script src=media-file.js></script>
5 <script src=video-test.js></script> 5 <script src=video-test.js></script>
6 6
7 <script> 7 <script>
8 var seekCount = 0; 8 var seekCount = 0;
9 var playCount = 0; 9 var playCount = 0;
10 10
11 function play() 11 function play()
12 { 12 {
13 if (video.readyState < HTMLMediaElement.HAVE_METADATA) { 13 if (video.readyState < HTMLMediaElement.HAVE_METADATA) {
14 setTimeout(play, 100); 14 setTimeout(play, 100);
15 return; 15 return;
16 } 16 }
17 17
18 if (++playCount > 1) 18 if (++playCount > 1)
19 return; 19 return;
20 20
21 consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>"); 21 consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>");
22 testExpected("video.paused", false); 22 testExpected("video.paused", false);
23 23
24 // Pause playback so the movie can't possibly loop before the se eked event fires 24 // Pause playback so the movie can't possibly loop before the se eked event fires
25 run("video.pause()"); 25 run("video.pause()");
26 waitForEvent("seeked", seeked); 26 waitForEvent("seeked", seeked);
27 run("video.currentTime = video.duration - 0.4"); 27 run("video.currentTime = video.duration - 0.4");
28 consoleWrite(""); 28 consoleWrite("");
29 } 29 }
30 30
31 function seeked() 31 function seeked()
32 { 32 {
33 switch (++seekCount) 33 switch (++seekCount)
34 { 34 {
35 case 1: 35 case 1:
36 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>"); 36 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>");
37 testExpected("video.paused", true); 37 testExpected("video.paused", true);
38 testExpected("video.ended", false); 38 testExpected("video.ended", false);
39 run("video.play()"); 39 run("video.play()");
40 consoleWrite(""); 40 consoleWrite("");
41 break; 41 break;
42 case 2: 42 case 2:
43 consoleWrite("<br><em>++ second seek completed because v ideo looped, toggle 'loop' and seek to near end again.</em>"); 43 consoleWrite("<br><em>++ second seek completed because v ideo looped, toggle 'loop' and seek to near end again.</em>");
44 testExpected("video.paused", false); 44 testExpected("video.paused", false);
45 testExpected("video.ended", false); 45 testExpected("video.ended", false);
46 run("video.pause()"); 46 run("video.pause()");
47 47
48 testExpected("mediaElement.currentTime", 0, '>='); 48 testExpected("mediaElement.currentTime", 0, '>=');
49 49
50 // don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines 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.d uration, "mediaElement.currentTime", "<", "mediaElement.duration", mediaElement. currentTime); 51 reportExpected(mediaElement.currentTime < mediaElement.d uration - 0.4, "mediaElement.currentTime", "<", "mediaElement.duration", mediaEl ement.currentTime);
52 run("video.loop = false"); 52 run("video.loop = false");
53 run("video.currentTime = video.duration - 0.4"); 53 run("video.currentTime = video.duration - 0.4");
54 consoleWrite(""); 54 consoleWrite("");
55 break; 55 break;
56 case 3: 56 case 3:
57 consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>"); 57 consoleWrite("<br><em>++ third seek completed, unset 'lo op' and let play to the end.</em>");
58 testExpected("video.paused", true); 58 testExpected("video.paused", true);
59 testExpected("video.ended", false); 59 testExpected("video.ended", false);
60 run("video.play()"); 60 run("video.play()");
61 consoleWrite(""); 61 consoleWrite("");
62 break; 62 break;
63 case 4:
64 consoleWrite("<br><em>++ fourth seek completed.</em>");
65 // Don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines
66 reportExpected(mediaElement.currentTime < mediaElement.d uration, "mediaElement.currentTime", "<", "mediaElement.duration", mediaElement. currentTime);
67 testExpected("video.loop", true);
68 testExpected("video.paused", false);
69 testExpected("video.ended", false);
70 consoleWrite("<br><em>++ Pausing now that test is over t o prevent additional unwanted looping.</em>");
71 run("video.pause()");
72 consoleWrite("");
73 endTest();
63 default: 74 default:
64 failTest("Video should have only seeked three times."); 75 failTest("Video should have only seeked four times.");
65 break; 76 break;
66 77
67 } 78 }
68 } 79 }
69 80
70 function ended() 81 function ended()
71 { 82 {
72 consoleWrite("<br><em>++ played to end and stopped.</em>"); 83 consoleWrite("<br><em>++ played to end and stopped.</em>");
73 testExpected("video.ended", true); 84 testExpected("video.ended", true);
74 85
75 // don't use "testExpected()" so we won't log the actual duratio n as the floating point result may differ with different engines 86 // Don't use "testExpected()" so we won't log the actual duratio n as the floating point result may differ with different engines
76 reportExpected(mediaElement.currentTime == mediaElement.duration , "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.curren tTime); 87 reportExpected(mediaElement.currentTime == mediaElement.duration , "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.curren tTime);
77 88
89 // Testing edge case where we set 'loop' after playback ends. Ve rifies fix for crbug.com/364442
90 consoleWrite("<br><em>++ with ended == true, set 'loop' attribut e. This will cause ended == false; looping video cannot be 'ended', only paused. </em>");
91 testExpected("video.loop", false);
92 testExpected("video.paused", true);
93 run("video.loop = true");
94 testExpected("video.loop", true);
95 testExpected("video.ended", false);
96 testExpected("video.paused", true);
97 run("video.play()");
78 consoleWrite(""); 98 consoleWrite("");
79 endTest();
80 } 99 }
81 100
82 function start() 101 function start()
83 { 102 {
84 findMediaElement(); 103 findMediaElement();
85 104
86 consoleWrite("<em>++ Test setting/removing the attribute.</em>") ; 105 consoleWrite("<em>++ Test setting/removing the attribute.</em>") ;
87 testExpected("video.getAttribute('loop')", null); 106 testExpected("video.getAttribute('loop')", null);
88 testExpected("video.loop", false); 107 testExpected("video.loop", false);
89 108
90 run("video.loop = true"); 109 run("video.loop = true");
91 testExpected("video.loop", true); 110 testExpected("video.loop", true);
(...skipping 16 matching lines...) Expand all
108 127
109 </head> 128 </head>
110 <body> 129 <body>
111 <video controls autoplay ></video> 130 <video controls autoplay ></video>
112 <p><b>Test looping by:</b> 131 <p><b>Test looping by:</b>
113 <ol> 132 <ol>
114 <li>Play to end with 'loop' set to true.</li> 133 <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> 134 <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> 135 <li>Set 'loop' to false and play again.</li>
117 <li>Verify that 'ended' event fires.</li> 136 <li>Verify that 'ended' event fires.</li>
137 <li>Set 'loop' to true now that video is ended. Call play again.</li >
138 <li>Verify 'seeked' event fires, verify that time has jumped back an d movie is playing.</li>
118 </ol> 139 </ol>
119 </p> 140 </p>
120 <script>start()</script> 141 <script>start()</script>
121 </body> 142 </body>
122 </html> 143 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/media/video-loop-expected.txt » ('j') | Source/core/html/HTMLMediaElement.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698