OLD | NEW |
1 // js-test now supports lazily printing test results which dumps all test | 1 // js-test now supports lazily printing test results which dumps all test |
2 // results once at the end of the test instead of building them up. To enable | 2 // results once at the end of the test instead of building them up. To enable |
3 // this option, call setPrintTestResultsLazily() before running any tests. | 3 // this option, call setPrintTestResultsLazily() before running any tests. |
4 var _lazyTestResults; // Set by setPrintTestResultsLazily(). | 4 var _lazyTestResults; // Set by setPrintTestResultsLazily(). |
5 | 5 |
6 // svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump tex
t + pixel results | 6 // svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump tex
t + pixel results |
7 if (self.testRunner) { | 7 if (self.testRunner) { |
8 if (self.enablePixelTesting) | 8 if (self.enablePixelTesting) |
9 testRunner.dumpAsTextWithPixelResults(); | 9 testRunner.dumpAsTextWithPixelResults(); |
10 else | 10 else |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 else if (isResultCorrect(_av, _bv) || (typeof opt_tolerance == 'number' && typ
eof _av == 'number' && Math.abs(_av - _bv) <= opt_tolerance)) { | 262 else if (isResultCorrect(_av, _bv) || (typeof opt_tolerance == 'number' && typ
eof _av == 'number' && Math.abs(_av - _bv) <= opt_tolerance)) { |
263 if (!quiet) { | 263 if (!quiet) { |
264 testPassed(_a + " is " + _b); | 264 testPassed(_a + " is " + _b); |
265 } | 265 } |
266 } else if (typeof(_av) == typeof(_bv)) | 266 } else if (typeof(_av) == typeof(_bv)) |
267 testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + "."); | 267 testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + "."); |
268 else | 268 else |
269 testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was "
+ _av + " (of type " + typeof _av + ")."); | 269 testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was "
+ _av + " (of type " + typeof _av + ")."); |
270 } | 270 } |
271 | 271 |
272 // Execute condition every 5 milliseconds until it succeed or failureTime is rea
ched. | 272 // Execute condition every animation frame until it succeeds or failureTime is r
eached. |
273 // completionHandler is executed on success, failureHandler is executed on timeo
ut. | 273 // completionHandler is executed on success, failureHandler is executed on timeo
ut. |
274 function _waitForCondition(condition, failureTime, completionHandler, failureHan
dler) | 274 function _waitForCondition(condition, failureTime, completionHandler, failureHan
dler) |
275 { | 275 { |
276 if (condition()) { | 276 if (condition()) { |
277 completionHandler(); | 277 completionHandler(); |
278 } else if (Date.now() > failureTime) { | 278 } else if (Date.now() > failureTime) { |
279 failureHandler(); | 279 failureHandler(); |
280 } else { | 280 } else { |
281 setTimeout(_waitForCondition, 5, condition, failureTime, completionHandler,
failureHandler); | 281 requestAnimationFrame(function() { |
| 282 _waitForCondition(condition, failureTime, completionHandler, failureHandle
r); |
| 283 }); |
282 } | 284 } |
283 } | 285 } |
284 | 286 |
285 function shouldBecomeEqual(_a, _b, _completionHandler, _timeout) | 287 function shouldBecomeEqual(_a, _b, _completionHandler, _timeout) |
286 { | 288 { |
287 if (typeof _a != "string" || typeof _b != "string") | 289 if (typeof _a != "string" || typeof _b != "string") |
288 debug("WARN: shouldBecomeEqual() expects string arguments"); | 290 debug("WARN: shouldBecomeEqual() expects string arguments"); |
289 | 291 |
290 if (_timeout === undefined) | 292 if (_timeout === undefined) |
291 _timeout = 500; | 293 _timeout = 500; |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 testPassed = function(msg) { | 892 testPassed = function(msg) { |
891 workerPort.postMessage('PASS:' + msg); | 893 workerPort.postMessage('PASS:' + msg); |
892 }; | 894 }; |
893 finishJSTest = function() { | 895 finishJSTest = function() { |
894 workerPort.postMessage('DONE:'); | 896 workerPort.postMessage('DONE:'); |
895 }; | 897 }; |
896 debug = function(msg) { | 898 debug = function(msg) { |
897 workerPort.postMessage(msg); | 899 workerPort.postMessage(msg); |
898 }; | 900 }; |
899 } | 901 } |
OLD | NEW |