OLD | NEW |
---|---|
1 // svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump tex t + pixel results | 1 // svg/dynamic-updates tests set enablePixelTesting=true, as we want to dump tex t + pixel results |
2 if (self.testRunner) { | 2 if (self.testRunner) { |
3 if (self.enablePixelTesting) | 3 if (self.enablePixelTesting) |
4 testRunner.dumpAsTextWithPixelResults(); | 4 testRunner.dumpAsTextWithPixelResults(); |
5 else | 5 else |
6 testRunner.dumpAsText(); | 6 testRunner.dumpAsText(); |
7 } | 7 } |
8 | 8 |
9 var description, debug, successfullyParsed; | 9 var description, debug, successfullyParsed; |
10 | 10 |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 if (typeof _e == "undefined" || _exception == _ev) | 562 if (typeof _e == "undefined" || _exception == _ev) |
563 testPassed(_a + " threw exception " + _exception + "."); | 563 testPassed(_a + " threw exception " + _exception + "."); |
564 else | 564 else |
565 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an excepti on" : _ev) + ". Threw exception " + _exception + "."); | 565 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an excepti on" : _ev) + ". Threw exception " + _exception + "."); |
566 } else if (typeof _av == "undefined") | 566 } else if (typeof _av == "undefined") |
567 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was undefined."); | 567 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was undefined."); |
568 else | 568 else |
569 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was " + _av + "."); | 569 testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception " : _ev) + ". Was " + _av + "."); |
570 } | 570 } |
571 | 571 |
572 function shouldBeNow(a) | |
573 { | |
574 for (var i = 0; i < 1000; ++i) { | |
ojan
2013/11/25 22:50:32
We'll have to see how long this takes in practice
| |
575 var startDate = Date.now(); | |
576 var av = eval(a); | |
577 var date = av.valueOf(); | |
578 var endDate = Date.now(); | |
579 | |
580 // On some occasions such as NTP updates, the current time can go | |
581 // backwards. This should only happen rarely, so we can get away with | |
582 // retrying the test a few times if we detect the time going backwards. | |
583 if (startDate > endDate) | |
584 continue; | |
585 | |
586 if (typeof date !== "number") { | |
587 testFailed(a + " is not a number or a Date. Got " + av); | |
588 return; | |
589 } | |
590 if (date < startDate) { | |
591 testFailed(a + " is not the curent time. Got " + av + " which is " + (startDate - date) / 1000 + " seconds in the past."); | |
592 return; | |
593 } | |
594 if (date > endDate) { | |
595 testFailed(a + " is not the current time. Got " + av + " which is " + (date - endDate) / 1000 + " seconds in the future."); | |
596 return; | |
597 } | |
598 | |
599 testPassed(a + " is equivalent to Date.now()."); | |
600 return; | |
601 } | |
602 testFailed(a + " cannot be tested against the current time. The clock is goi ng backwards too often."); | |
603 } | |
604 | |
572 function expectError() | 605 function expectError() |
573 { | 606 { |
574 if (expectingError) { | 607 if (expectingError) { |
575 testFailed("shouldHaveError() called twice before an error occurred!"); | 608 testFailed("shouldHaveError() called twice before an error occurred!"); |
576 } | 609 } |
577 expectingError = true; | 610 expectingError = true; |
578 } | 611 } |
579 | 612 |
580 function shouldHaveHadError(message) | 613 function shouldHaveHadError(message) |
581 { | 614 { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
714 testPassed = function(msg) { | 747 testPassed = function(msg) { |
715 workerPort.postMessage('PASS:' + msg); | 748 workerPort.postMessage('PASS:' + msg); |
716 }; | 749 }; |
717 finishJSTest = function() { | 750 finishJSTest = function() { |
718 workerPort.postMessage('DONE:'); | 751 workerPort.postMessage('DONE:'); |
719 }; | 752 }; |
720 debug = function(msg) { | 753 debug = function(msg) { |
721 workerPort.postMessage(msg); | 754 workerPort.postMessage(msg); |
722 }; | 755 }; |
723 } | 756 } |
OLD | NEW |