| 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 * DumpRenderTree. | 7 * DumpRenderTree. |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 | 76 |
| 77 function onLoad(e) { | 77 function onLoad(e) { |
| 78 // needed for dartium compilation errors. | 78 // needed for dartium compilation errors. |
| 79 if (window.compilationError) { | 79 if (window.compilationError) { |
| 80 showErrorAndExit(window.compilationError); | 80 showErrorAndExit(window.compilationError); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 window.addEventListener("DOMContentLoaded", onLoad, false); | 84 window.addEventListener("DOMContentLoaded", onLoad, false); |
| 85 | 85 |
| 86 // If nobody intercepts the error, finish the test. | 86 // Note: before renaming this function, note that it is also included in an |
| 87 window.addEventListener("error", function(e) { | 87 // inlined error handler in the HTML files that wrap DRT tests. |
| 88 // See: tools/testing/dart/browser_test.dart |
| 89 function externalError(e) { |
| 88 // needed for dartium compilation errors. | 90 // needed for dartium compilation errors. |
| 89 showErrorAndExit(e && e.message); | 91 showErrorAndExit(e && e.message); |
| 90 window.postMessage('unittest-suite-external-error', '*'); | 92 window.postMessage('unittest-suite-external-error', '*'); |
| 91 }, false); | 93 } |
| 94 |
| 95 // If nobody intercepts the error, finish the test. |
| 96 window.addEventListener("error", externalError, false); |
| 92 | 97 |
| 93 document.addEventListener('readystatechange', function () { | 98 document.addEventListener('readystatechange', function () { |
| 94 if (document.readyState != "loaded") return; | 99 if (document.readyState != "loaded") return; |
| 95 // If 'startedDartTest' is not set, that means that the test did not have | 100 // If 'startedDartTest' is not set, that means that the test did not have |
| 96 // a chance to load. This will happen when a load error occurs in the VM. | 101 // a chance to load. This will happen when a load error occurs in the VM. |
| 97 // Give the machine time to start up. | 102 // Give the machine time to start up. |
| 98 setTimeout(function() { | 103 setTimeout(function() { |
| 99 // A window.postMessage might have been enqueued after this timeout. | 104 // A window.postMessage might have been enqueued after this timeout. |
| 100 // Just sleep another time to give the browser the time to process the | 105 // Just sleep another time to give the browser the time to process the |
| 101 // posted message. | 106 // posted message. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 128 function dartMainRunner(main) { | 133 function dartMainRunner(main) { |
| 129 window.postMessage('dart-calling-main', '*'); | 134 window.postMessage('dart-calling-main', '*'); |
| 130 try { | 135 try { |
| 131 main(); | 136 main(); |
| 132 } catch (e) { | 137 } catch (e) { |
| 133 window.postMessage('unittest-suite-fail', '*'); | 138 window.postMessage('unittest-suite-fail', '*'); |
| 134 return; | 139 return; |
| 135 } | 140 } |
| 136 window.postMessage('dart-main-done', '*'); | 141 window.postMessage('dart-main-done', '*'); |
| 137 } | 142 } |
| OLD | NEW |