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

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

Issue 1715303002: Add TODOs to convert from video-test.js to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add bug ref Created 4 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 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956
6 (Please avoid writing new tests using video-test.js) -->
5 <script src=video-test.js></script> 7 <script src=video-test.js></script>
6 8
7 <script> 9 <script>
8 var seekCount = 0; 10 var seekCount = 0;
9 var playCount = 0; 11 var playCount = 0;
10 12
11 function play() 13 function play()
12 { 14 {
13 if (video.readyState < HTMLMediaElement.HAVE_METADATA) { 15 if (video.readyState < HTMLMediaElement.HAVE_METADATA) {
14 setTimeout(play, 100); 16 setTimeout(play, 100);
15 return; 17 return;
16 } 18 }
17 19
18 if (++playCount > 1) 20 if (++playCount > 1)
19 return; 21 return;
20 22
21 consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>"); 23 consoleWrite("<br><em>++ seek to near the end, wait for 'seeked' event to announce loop.</em>");
22 testExpected("video.paused", false); 24 testExpected("video.paused", false);
23 25
24 // Pause playback so the movie can't possibly loop before the se eked event fires 26 // Pause playback so the movie can't possibly loop before the se eked event fires
25 run("video.pause()"); 27 run("video.pause()");
26 waitForEvent("seeked", seeked); 28 waitForEvent("seeked", seeked);
27 run("video.currentTime = video.duration - 0.4"); 29 run("video.currentTime = video.duration - 0.4");
28 consoleWrite(""); 30 consoleWrite("");
29 } 31 }
30 32
31 function seeked() 33 function seeked()
32 { 34 {
33 switch (++seekCount) 35 switch (++seekCount)
34 { 36 {
35 case 1: 37 case 1:
36 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>"); 38 consoleWrite("<br><em>++ first seek completed, beginning playback.</em>");
37 testExpected("video.paused", true); 39 testExpected("video.paused", true);
38 testExpected("video.ended", false); 40 testExpected("video.ended", false);
39 run("video.play()"); 41 run("video.play()");
40 consoleWrite(""); 42 consoleWrite("");
41 break; 43 break;
42 case 2: 44 case 2:
43 consoleWrite("<br><em>++ second seek completed because v ideo looped, toggle 'loop' and seek to near end again.</em>"); 45 consoleWrite("<br><em>++ second seek completed because v ideo looped, toggle 'loop' and seek to near end again.</em>");
44 testExpected("video.paused", false); 46 testExpected("video.paused", false);
45 testExpected("video.ended", false); 47 testExpected("video.ended", false);
46 run("video.pause()"); 48 run("video.pause()");
47 49
48 testExpected("mediaElement.currentTime", 0, '>='); 50 testExpected("mediaElement.currentTime", 0, '>=');
49 51
50 // don't use "testExpected()" so we won't log the actual duration as the floating point result may differ with different engines 52 // 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); 53 reportExpected(mediaElement.currentTime < mediaElement.d uration, "mediaElement.currentTime", "<", "mediaElement.duration", mediaElement. currentTime);
52 run("video.loop = false"); 54 run("video.loop = false");
53 run("video.currentTime = video.duration - 0.4"); 55 run("video.currentTime = video.duration - 0.4");
54 consoleWrite(""); 56 consoleWrite("");
55 break; 57 break;
56 case 3: 58 case 3:
57 consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>"); 59 consoleWrite("<br><em>++ third seek completed, beginning playback for the last time.</em>");
58 testExpected("video.paused", true); 60 testExpected("video.paused", true);
59 testExpected("video.ended", false); 61 testExpected("video.ended", false);
60 run("video.play()"); 62 run("video.play()");
61 consoleWrite(""); 63 consoleWrite("");
62 break; 64 break;
63 default: 65 default:
64 failTest("Video should have only seeked three times."); 66 failTest("Video should have only seeked three times.");
65 break; 67 break;
66 68
67 } 69 }
68 } 70 }
69 71
70 function ended() 72 function ended()
71 { 73 {
72 consoleWrite("<br><em>++ played to end and stopped.</em>"); 74 consoleWrite("<br><em>++ played to end and stopped.</em>");
73 testExpected("video.ended", true); 75 testExpected("video.ended", true);
74 76
75 // don't use "testExpected()" so we won't log the actual duratio n as the floating point result may differ with different engines 77 // 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); 78 reportExpected(mediaElement.currentTime == mediaElement.duration , "mediaElement.currentTime", "==", "mediaElement.duration", mediaElement.curren tTime);
77 79
78 consoleWrite(""); 80 consoleWrite("");
79 endTest(); 81 endTest();
80 } 82 }
81 83
82 function start() 84 function start()
83 { 85 {
84 findMediaElement(); 86 findMediaElement();
85 87
86 consoleWrite("<em>++ Test setting/removing the attribute.</em>") ; 88 consoleWrite("<em>++ Test setting/removing the attribute.</em>") ;
87 testExpected("video.getAttribute('loop')", null); 89 testExpected("video.getAttribute('loop')", null);
88 testExpected("video.loop", false); 90 testExpected("video.loop", false);
89 91
90 run("video.loop = true"); 92 run("video.loop = true");
91 testExpected("video.loop", true); 93 testExpected("video.loop", true);
92 testExpected("video.getAttribute('loop')", null, "!="); 94 testExpected("video.getAttribute('loop')", null, "!=");
93 95
94 run("video.removeAttribute('loop')"); 96 run("video.removeAttribute('loop')");
95 testExpected("video.loop", false); 97 testExpected("video.loop", false);
96 98
97 waitForEvent('pause'); 99 waitForEvent('pause');
98 waitForEvent('play', play); 100 waitForEvent('play', play);
99 waitForEvent("ended", ended); 101 waitForEvent("ended", ended);
100 102
101 consoleWrite("<br><em>++ Set 'loop' to true and begin playing.</ em>"); 103 consoleWrite("<br><em>++ Set 'loop' to true and begin playing.</ em>");
102 var mediaFile = findMediaFile("video", "content/test"); 104 var mediaFile = findMediaFile("video", "content/test");
103 run("video.loop = true"); 105 run("video.loop = true");
104 video.src = mediaFile; 106 video.src = mediaFile;
105 consoleWrite(""); 107 consoleWrite("");
106 } 108 }
107 </script> 109 </script>
108 110
109 </head> 111 </head>
110 <body> 112 <body>
111 <video controls autoplay ></video> 113 <video controls autoplay ></video>
112 <p><b>Test looping by:</b> 114 <p><b>Test looping by:</b>
113 <ol> 115 <ol>
114 <li>Play to end with 'loop' set to true.</li> 116 <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> 117 <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> 118 <li>Set 'loop' to false and play again.</li>
117 <li>Verify that 'ended' event fires.</li> 119 <li>Verify that 'ended' event fires.</li>
118 </ol> 120 </ol>
119 </p> 121 </p>
120 <script>start()</script> 122 <script>start()</script>
121 </body> 123 </body>
122 </html> 124 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698