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

Side by Side Diff: third_party/WebKit/LayoutTests/media/video-source-moved.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 <title>moving &lt;source&gt; element test</title> 4 <title>moving &lt;source&gt; element test</title>
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 <script src=media-file.js></script> 8 <script src=media-file.js></script>
7 <script> 9 <script>
8 10
9 var testInfo = 11 var testInfo =
10 { 12 {
11 current : -1, 13 current : -1,
12 tests : 14 tests :
13 [ 15 [
14 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 1}, 16 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 1},
15 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 2}, 17 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 2},
16 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 3}, 18 { fcn : moveToEnd, errorCount : 0, moved : null, done : fals e, iteration : 3},
17 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 1 }, 19 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 1 },
18 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 2 }, 20 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 2 },
19 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 3 }, 21 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 3 },
20 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 4 } 22 { fcn : moveEarlier, errorCount : 0, moved : null, iteration : 4 }
21 ] 23 ]
22 }; 24 };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 video.insertBefore(test.moved, video.firstChild); 85 video.insertBefore(test.moved, video.firstChild);
84 break; 86 break;
85 87
86 default: 88 default:
87 // We should never get an error for the element we moved . 89 // We should never get an error for the element we moved .
88 if (event.target == test.moved) { 90 if (event.target == test.moved) {
89 failTest("Error fired for &lt;source&gt; moved to be ginning of list."); 91 failTest("Error fired for &lt;source&gt; moved to be ginning of list.");
90 test.done = true; 92 test.done = true;
91 return; 93 return;
92 } else if (!event.target.nextSibling) { 94 } else if (!event.target.nextSibling) {
93 logResult(true, "&lt;source&gt; moved was not proces sed"); 95 logResult(true, "&lt;source&gt; moved was not proces sed");
94 setTimeout(configureNextTest, 100); 96 setTimeout(configureNextTest, 100);
95 } 97 }
96 break; 98 break;
97 } 99 }
98 } 100 }
99 101
100 function moveToEnd(test, event) 102 function moveToEnd(test, event)
101 { 103 {
102 switch (++test.errorCount) 104 switch (++test.errorCount)
103 { 105 {
(...skipping 21 matching lines...) Expand all
125 failTest("Malformed test data!"); 127 failTest("Malformed test data!");
126 break; 128 break;
127 } 129 }
128 130
129 testExpected(test.moved, null, '!='); 131 testExpected(test.moved, null, '!=');
130 video.appendChild(test.moved); 132 video.appendChild(test.moved);
131 break; 133 break;
132 134
133 default: 135 default:
134 if (event.target == test.moved) { 136 if (event.target == test.moved) {
135 logResult(true, "&lt;source&gt; moved was processed a second time."); 137 logResult(true, "&lt;source&gt; moved was processed a second time.");
136 setTimeout(configureNextTest, 100); 138 setTimeout(configureNextTest, 100);
137 } else if (!event.target.nextSibling) { 139 } else if (!event.target.nextSibling) {
138 // We should never reach the end of the source list since the tests stops 140 // We should never reach the end of the source list since the tests stops
139 // when the error fires for the moved element. 141 // when the error fires for the moved element.
140 failTest("Error never fired for &lt;source&gt; moved !"); 142 failTest("Error never fired for &lt;source&gt; moved !");
141 } 143 }
142 break; 144 break;
143 } 145 }
144 } 146 }
145 147
146 function runOneTest(evt) 148 function runOneTest(evt)
147 { 149 {
148 var test = testInfo.tests[testInfo.current]; 150 var test = testInfo.tests[testInfo.current];
149 test.fcn(test, evt); 151 test.fcn(test, evt);
150 } 152 }
151 153
152 function addSource(index) 154 function addSource(index)
153 { 155 {
154 var source = document.createElement('source'); 156 var source = document.createElement('source');
155 source.src = findMediaFile("video", index + "-" + Date.now()); 157 source.src = findMediaFile("video", index + "-" + Date.now());
156 source.type = mimeTypeForExtension(source.src.split('.').pop()); 158 source.type = mimeTypeForExtension(source.src.split('.').pop());
157 video.appendChild(source); 159 video.appendChild(source);
158 } 160 }
159 161
160 function runNextTest() 162 function runNextTest()
161 { 163 {
162 consoleWrite(""); 164 consoleWrite("");
163 if (++testInfo.current >= testInfo.tests.length) { 165 if (++testInfo.current >= testInfo.tests.length) {
164 consoleWrite("PASS<br>"); 166 consoleWrite("PASS<br>");
165 endTest(); 167 endTest();
166 return; 168 return;
167 } 169 }
168 170
169 testInfo.errorCount = 0; 171 testInfo.errorCount = 0;
170 video = mediaElement = document.createElement('video'); 172 video = mediaElement = document.createElement('video');
171 document.body.appendChild(video); 173 document.body.appendChild(video);
172 174
173 // Add a bunch of source elements with bogus urls because we wan t to rearrange elements 175 // Add a bunch of source elements with bogus urls because we wan t to rearrange elements
174 // after the media engine begins processing sources, and we can' t predict the delay 176 // after the media engine begins processing sources, and we can' t predict the delay
175 // between when the media element fires an 'error' event and our handler is called, 177 // between when the media element fires an 'error' event and our handler is called,
176 // but we need to guarantee that there are <source> elements tha t haven't been processed 178 // but we need to guarantee that there are <source> elements tha t haven't been processed
177 // when we run the test. 179 // when we run the test.
178 for (var ndx = 1; ndx <= 10; ndx++) 180 for (var ndx = 1; ndx <= 10; ndx++)
179 addSource(ndx); 181 addSource(ndx);
180 } 182 }
181 183
182 function configureNextTest() 184 function configureNextTest()
183 { 185 {
184 var videos = document.querySelectorAll('video'); 186 var videos = document.querySelectorAll('video');
185 for (var ndx = 0; ndx < videos.length; ++ndx) 187 for (var ndx = 0; ndx < videos.length; ++ndx)
186 videos[ndx].parentNode.removeChild(videos[ndx]); 188 videos[ndx].parentNode.removeChild(videos[ndx]);
187 video = mediaElement = null; 189 video = mediaElement = null;
188 setTimeout(runNextTest, 100); 190 setTimeout(runNextTest, 100);
189 } 191 }
190 192
191 function setup() 193 function setup()
192 { 194 {
193 document.addEventListener("error", runOneTest, true); 195 document.addEventListener("error", runOneTest, true);
194 configureNextTest(); 196 configureNextTest();
195 } 197 }
196 198
197 </script> 199 </script>
198 </head> 200 </head>
199 201
200 <body> 202 <body>
201 <div>Test to make sure a &lt;source&gt; moved after the media element be gins processing 203 <div>Test to make sure a &lt;source&gt; moved after the media element be gins processing
202 is handled correctly.</div> 204 is handled correctly.</div>
203 <script>setup()</script> 205 <script>setup()</script>
204 </body> 206 </body>
205 </html> 207 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698