| 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 |
| 11 testRunner.dumpAsText(); | 11 testRunner.dumpAsText(); |
| 12 } | 12 } |
| 13 | 13 |
| 14 var isJsTest = true; | 14 var isJsTest = true; |
| 15 | 15 |
| 16 var description, debug, successfullyParsed; | 16 var description, debug, successfullyParsed; |
| 17 | 17 |
| 18 var expectingError; // set by shouldHaveError() | 18 var expectingError; // set by expectError() |
| 19 var expectedErrorMessage; // set by onerror when expectingError is true | 19 var expectedErrorMessage; // set by onerror when expectingError is true |
| 20 var unexpectedErrorMessage; // set by onerror when expectingError is not true | 20 var unexpectedErrorMessage; // set by onerror when expectingError is not true |
| 21 | 21 |
| 22 (function() { | 22 (function() { |
| 23 | 23 |
| 24 function getOrCreate(id, tagName) | 24 function getOrCreate(id, tagName) |
| 25 { | 25 { |
| 26 var element = document.getElementById(id); | 26 var element = document.getElementById(id); |
| 27 if (element) | 27 if (element) |
| 28 return element; | 28 return element; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 window.addEventListener('DOMContentLoaded', handleTestFinished, false); | 105 window.addEventListener('DOMContentLoaded', handleTestFinished, false); |
| 106 insertStyleSheet(); | 106 insertStyleSheet(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 if (!self.isOnErrorTest) { | 109 if (!self.isOnErrorTest) { |
| 110 self.onerror = function(message) | 110 self.onerror = function(message) |
| 111 { | 111 { |
| 112 if (self.expectingError) { | 112 if (self.expectingError) { |
| 113 self.expectedErrorMessage = message; | 113 self.expectedErrorMessage = message; |
| 114 self.expectingError = false; | 114 self.expectingError = false; |
| 115 return; | 115 // Consume expected error in worker, so window doesn't fail the
test. |
| 116 return isWorker(); |
| 116 } | 117 } |
| 117 self.unexpectedErrorMessage = message; | 118 self.unexpectedErrorMessage = message; |
| 118 if (self.jsTestIsAsync) { | 119 if (self.jsTestIsAsync) { |
| 119 self.testFailed("Unexpected error: " + message); | 120 self.testFailed("Unexpected error: " + message); |
| 120 finishJSTest(); | 121 finishJSTest(); |
| 121 } | 122 } |
| 122 }; | 123 }; |
| 123 } | 124 } |
| 124 })(); | 125 })(); |
| 125 | 126 |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 660 |
| 660 testPassed(a + " is equivalent to Date.now()."); | 661 testPassed(a + " is equivalent to Date.now()."); |
| 661 return; | 662 return; |
| 662 } | 663 } |
| 663 testFailed(a + " cannot be tested against the current time. The clock is goi
ng backwards too often."); | 664 testFailed(a + " cannot be tested against the current time. The clock is goi
ng backwards too often."); |
| 664 } | 665 } |
| 665 | 666 |
| 666 function expectError() | 667 function expectError() |
| 667 { | 668 { |
| 668 if (expectingError) { | 669 if (expectingError) { |
| 669 testFailed("shouldHaveError() called twice before an error occurred!"); | 670 testFailed("expectError() called twice before an error occurred!"); |
| 670 } | 671 } |
| 671 expectingError = true; | 672 expectingError = true; |
| 672 } | 673 } |
| 673 | 674 |
| 674 function shouldHaveHadError(message) | 675 function shouldHaveHadError(message) |
| 675 { | 676 { |
| 676 if (expectingError) { | 677 if (expectingError) { |
| 677 testFailed("No error thrown between expectError() and shouldHaveHadError
()"); | 678 testFailed("No error thrown between expectError() and shouldHaveHadError
()"); |
| 678 return; | 679 return; |
| 679 } | 680 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 testPassed = function(msg) { | 845 testPassed = function(msg) { |
| 845 workerPort.postMessage('PASS:' + msg); | 846 workerPort.postMessage('PASS:' + msg); |
| 846 }; | 847 }; |
| 847 finishJSTest = function() { | 848 finishJSTest = function() { |
| 848 workerPort.postMessage('DONE:'); | 849 workerPort.postMessage('DONE:'); |
| 849 }; | 850 }; |
| 850 debug = function(msg) { | 851 debug = function(msg) { |
| 851 workerPort.postMessage(msg); | 852 workerPort.postMessage(msg); |
| 852 }; | 853 }; |
| 853 } | 854 } |
| OLD | NEW |