OLD | NEW |
1 /* | 1 /* |
2 * THIS FILE INTENTIONALLY LEFT BLANK | 2 * THIS FILE INTENTIONALLY LEFT BLANK |
3 * | 3 * |
4 * More specifically, this file is intended for vendors to implement | 4 * More specifically, this file is intended for vendors to implement |
5 * code needed to integrate testharness.js tests with their own test systems. | 5 * code needed to integrate testharness.js tests with their own test systems. |
6 * | 6 * |
7 * Typically such integration will attach callbacks when each test is | 7 * Typically such integration will attach callbacks when each test is |
8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has | 8 * has run, using add_result_callback(callback(test)), or when the whole test fi
le has |
9 * completed, using add_completion_callback(callback(tests, harness_status)). | 9 * completed, using add_completion_callback(callback(tests, harness_status)). |
10 * | 10 * |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 } | 182 } |
183 } | 183 } |
184 resultStr += convertResult(tests[i].status) + " " + | 184 resultStr += convertResult(tests[i].status) + " " + |
185 sanitize(tests[i].name) + " " + | 185 sanitize(tests[i].name) + " " + |
186 sanitize(tests[i].message) + "\n"; | 186 sanitize(tests[i].message) + "\n"; |
187 } | 187 } |
188 } else { | 188 } else { |
189 // Iterate through tests array and build string that contains | 189 // Iterate through tests array and build string that contains |
190 // results for all tests. | 190 // results for all tests. |
| 191 let testResults = ""; |
| 192 let resultCounter = [0, 0, 0, 0]; |
191 for (var i = 0; i < tests.length; ++i) { | 193 for (var i = 0; i < tests.length; ++i) { |
192 resultStr += convertResult(tests[i].status) + " " + | 194 resultCounter[tests[i].status]++; |
| 195 testResults += convertResult(tests[i].status) + " " + |
193 sanitize(tests[i].name) + " " + | 196 sanitize(tests[i].name) + " " + |
194 sanitize(tests[i].message) + "\n"; | 197 sanitize(tests[i].message) + "\n"; |
195 } | 198 } |
| 199 if (output_document.URL.indexOf("http://web-platform.test") >= 0 && |
| 200 tests.length >= 50 && (resultCounter[1] || resultCounter[2] || r
esultCounter[3])) { |
| 201 // Output failure metrics if there are many. |
| 202 resultStr += `Found ${tests.length} tests;` + |
| 203 ` ${resultCounter[0]} PASS,` + |
| 204 ` ${resultCounter[1]} FAIL,` + |
| 205 ` ${resultCounter[2]} TIMEOUT,` + |
| 206 ` ${resultCounter[3]} NOTRUN.\n`; |
| 207 } |
| 208 resultStr += testResults; |
196 } | 209 } |
197 | 210 |
198 resultStr += "Harness: the test ran to completion.\n"; | 211 resultStr += "Harness: the test ran to completion.\n"; |
199 | 212 |
200 // Set results element's textContent to the results string. | 213 // Set results element's textContent to the results string. |
201 results.textContent = resultStr; | 214 results.textContent = resultStr; |
202 | 215 |
203 function done() { | 216 function done() { |
204 // A temporary workaround since |window.self| property lookup starts | 217 // A temporary workaround since |window.self| property lookup starts |
205 // failing if the frame is detached. |output_document| may be an | 218 // failing if the frame is detached. |output_document| may be an |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // another completion callback might generate more results. So, we | 253 // another completion callback might generate more results. So, we |
241 // don't dump the results immediately. | 254 // don't dump the results immediately. |
242 setTimeout(done, 0); | 255 setTimeout(done, 0); |
243 } else { | 256 } else { |
244 // Parsing the test HTML isn't finished yet. | 257 // Parsing the test HTML isn't finished yet. |
245 window.addEventListener('load', done); | 258 window.addEventListener('load', done); |
246 } | 259 } |
247 }); | 260 }); |
248 | 261 |
249 })(); | 262 })(); |
OLD | NEW |