| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Test controller logic - used by unit test harness to embed tests in | 6 * Test controller logic - used by unit test harness to embed tests in |
| 7 * conent shell. | 7 * conent shell. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 // Clear the console before every test run - this is Firebug specific code. | 10 // Clear the console before every test run - this is Firebug specific code. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // Note: before renaming this function, note that it is also included in an | 115 // Note: before renaming this function, note that it is also included in an |
| 116 // inlined error handler in the HTML files that wrap DRT tests. | 116 // inlined error handler in the HTML files that wrap DRT tests. |
| 117 // See: tools/testing/dart/browser_test.dart | 117 // See: tools/testing/dart/browser_test.dart |
| 118 function externalError(e) { | 118 function externalError(e) { |
| 119 // needed for dartium compilation errors. | 119 // needed for dartium compilation errors. |
| 120 showErrorAndExit(e && e.message); | 120 showErrorAndExit(e && e.message); |
| 121 window.postMessage('unittest-suite-external-error', '*'); | 121 window.postMessage('unittest-suite-external-error', '*'); |
| 122 } | 122 } |
| 123 | 123 |
| 124 // If nobody intercepts the error, finish the test. | |
| 125 window.addEventListener("error", externalError, false); | |
| 126 | |
| 127 document.addEventListener('readystatechange', function () { | 124 document.addEventListener('readystatechange', function () { |
| 128 if (document.readyState != "loaded") return; | 125 if (document.readyState != "loaded") return; |
| 129 // If 'startedDartTest' is not set, that means that the test did not have | 126 // If 'startedDartTest' is not set, that means that the test did not have |
| 130 // a chance to load. This will happen when a load error occurs in the VM. | 127 // a chance to load. This will happen when a load error occurs in the VM. |
| 131 // Give the machine time to start up. | 128 // Give the machine time to start up. |
| 132 setTimeout(function() { | 129 setTimeout(function() { |
| 133 // A window.postMessage might have been enqueued after this timeout. | 130 // A window.postMessage might have been enqueued after this timeout. |
| 134 // Just sleep another time to give the browser the time to process the | 131 // Just sleep another time to give the browser the time to process the |
| 135 // posted message. | 132 // posted message. |
| 136 setTimeout(function() { | 133 setTimeout(function() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 166 try { | 163 try { |
| 167 main(); | 164 main(); |
| 168 } catch (e) { | 165 } catch (e) { |
| 169 dartPrint(e); | 166 dartPrint(e); |
| 170 if (e.stack) dartPrint(e.stack); | 167 if (e.stack) dartPrint(e.stack); |
| 171 window.postMessage('unittest-suite-fail', '*'); | 168 window.postMessage('unittest-suite-fail', '*'); |
| 172 return; | 169 return; |
| 173 } | 170 } |
| 174 window.postMessage('dart-main-done', '*'); | 171 window.postMessage('dart-main-done', '*'); |
| 175 } | 172 } |
| OLD | NEW |