Chromium Code Reviews| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 " " + sanitize(prefix) + " " + (j - i) + " tests \n" | 178 " " + sanitize(prefix) + " " + (j - i) + " tests \n" |
| 179 i = j - 1; | 179 i = j - 1; |
| 180 continue; | 180 continue; |
| 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 if (output_document.URL.indexOf("http://web-platform.test") >= 0) { | |
|
tkent
2017/01/26 22:09:43
I don't think this condition makes much sense. Th
yoichio
2017/01/27 07:21:56
I would be helpful but it needs much rebasing -exp
| |
| 189 let testResults = ""; | |
| 190 let resultCounter = [0,0,0,0]; | |
|
tkent
2017/01/26 22:09:43
[0,0,0,0] -> [0, 0, 0, 0]
yoichio
2017/01/27 07:21:56
Done.
| |
| 191 for (var i = 0; i < tests.length; ++i) { | |
| 192 resultCounter[tests[i].status]++; | |
| 193 testResults += convertResult(tests[i].status) + " " + | |
| 194 sanitize(tests[i].name) + " " + | |
| 195 sanitize(tests[i].message) + "\n"; | |
| 196 } | |
| 197 resultStr += `Found ${tests.length} tests.` + | |
|
tkent
2017/01/26 22:09:43
I recommend to show the stats only if
- non-0 FAI
yoichio
2017/01/27 07:21:56
Done.
| |
| 198 ` ${resultCounter[0]} PASS` + | |
| 199 ` ${resultCounter[1]} FAIL` + | |
| 200 ` ${resultCounter[2]} TIMEOUT` + | |
| 201 ` ${resultCounter[3]} NOTRUN\n`; | |
| 202 resultStr += testResults; | |
| 188 } else { | 203 } else { |
| 189 // Iterate through tests array and build string that contains | 204 // Iterate through tests array and build string that contains |
| 190 // results for all tests. | 205 // results for all tests. |
| 191 for (var i = 0; i < tests.length; ++i) { | 206 for (var i = 0; i < tests.length; ++i) { |
| 192 resultStr += convertResult(tests[i].status) + " " + | 207 resultStr += convertResult(tests[i].status) + " " + |
| 193 sanitize(tests[i].name) + " " + | 208 sanitize(tests[i].name) + " " + |
| 194 sanitize(tests[i].message) + "\n"; | 209 sanitize(tests[i].message) + "\n"; |
| 195 } | 210 } |
| 196 } | 211 } |
| 197 | 212 |
| 213 | |
|
tkent
2017/01/26 22:09:43
Do not add unnecessary blank lines.
yoichio
2017/01/27 07:21:56
Done.
| |
| 214 | |
| 198 resultStr += "Harness: the test ran to completion.\n"; | 215 resultStr += "Harness: the test ran to completion.\n"; |
| 199 | 216 |
| 200 // Set results element's textContent to the results string. | 217 // Set results element's textContent to the results string. |
| 201 results.textContent = resultStr; | 218 results.textContent = resultStr; |
| 202 | 219 |
| 203 function done() { | 220 function done() { |
| 204 // A temporary workaround since |window.self| property lookup starts | 221 // A temporary workaround since |window.self| property lookup starts |
| 205 // failing if the frame is detached. |output_document| may be an | 222 // failing if the frame is detached. |output_document| may be an |
| 206 // ancestor of |self| so clearing |textContent| may detach |self|. | 223 // ancestor of |self| so clearing |textContent| may detach |self|. |
| 207 // To get around this, cache window.self now and use the cached | 224 // To get around this, cache window.self now and use the cached |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 // another completion callback might generate more results. So, we | 257 // another completion callback might generate more results. So, we |
| 241 // don't dump the results immediately. | 258 // don't dump the results immediately. |
| 242 setTimeout(done, 0); | 259 setTimeout(done, 0); |
| 243 } else { | 260 } else { |
| 244 // Parsing the test HTML isn't finished yet. | 261 // Parsing the test HTML isn't finished yet. |
| 245 window.addEventListener('load', done); | 262 window.addEventListener('load', done); |
| 246 } | 263 } |
| 247 }); | 264 }); |
| 248 | 265 |
| 249 })(); | 266 })(); |
| OLD | NEW |