| 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. |
| 11 if (typeof console == "object" && typeof console.clear == "function") { | 11 if (typeof console == "object" && typeof console.clear == "function") { |
| 12 console.clear(); | 12 console.clear(); |
| 13 } | 13 } |
| 14 |
| 15 // Some tests may expect and have no way to suppress global errors. |
| 16 var testExpectsGlobalError = false; |
| 17 var testSuppressedGlobalErrors = []; |
| 18 |
| 14 // Set window onerror to make sure that we catch test harness errors across all | 19 // Set window onerror to make sure that we catch test harness errors across all |
| 15 // browsers. | 20 // browsers. |
| 16 window.onerror = function (message, url, lineNumber) { | 21 window.onerror = function (message, url, lineNumber) { |
| 22 if (testExpectsGlobalError) { |
| 23 testSuppressedGlobalErrors.push({ |
| 24 message: message |
| 25 }); |
| 26 return; |
| 27 } |
| 17 if (url) { | 28 if (url) { |
| 18 showErrorAndExit( | 29 showErrorAndExit( |
| 19 "\n\n" + url + ":" + lineNumber + ":\n" + message + "\n\n"); | 30 "\n\n" + url + ":" + lineNumber + ":\n" + message + "\n\n"); |
| 20 } else { | 31 } else { |
| 21 showErrorAndExit(message); | 32 showErrorAndExit(message); |
| 22 } | 33 } |
| 23 window.postMessage('unittest-suite-external-error', '*'); | 34 window.postMessage('unittest-suite-external-error', '*'); |
| 24 }; | 35 }; |
| 25 | 36 |
| 26 // Start Dartium/content_shell, unless we are waiting for HTML Imports to load. | 37 // Start Dartium/content_shell, unless we are waiting for HTML Imports to load. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 try { | 193 try { |
| 183 main(); | 194 main(); |
| 184 } catch (e) { | 195 } catch (e) { |
| 185 dartPrint(e); | 196 dartPrint(e); |
| 186 if (e.stack) dartPrint(e.stack); | 197 if (e.stack) dartPrint(e.stack); |
| 187 window.postMessage('unittest-suite-fail', '*'); | 198 window.postMessage('unittest-suite-fail', '*'); |
| 188 return; | 199 return; |
| 189 } | 200 } |
| 190 window.postMessage('dart-main-done', '*'); | 201 window.postMessage('dart-main-done', '*'); |
| 191 } | 202 } |
| OLD | NEW |