| 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 // Set window onerror to make sure that we catch test harness errors across all | 14 // Set window onerror to make sure that we catch test harness errors across all |
| 15 // browsers. | 15 // browsers. |
| 16 window.onerror = function (message, url, lineNumber) { | 16 window.onerror = function (message, url, lineNumber) { |
| 17 if (url) { | 17 if (url) { |
| 18 showErrorAndExit( | 18 showErrorAndExit( |
| 19 "\n\n" + url + ":" + lineNumber + ":\n" + message + "\n\n"); | 19 "\n\n" + url + ":" + lineNumber + ":\n" + message + "\n\n"); |
| 20 } else { | 20 } else { |
| 21 showErrorAndExit(message); | 21 showErrorAndExit(message); |
| 22 } | 22 } |
| 23 window.postMessage('unittest-suite-external-error', '*'); | 23 window.postMessage('unittest-suite-external-error', '*'); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 if (navigator.webkitStartDart) { | 26 // Start Dartium/content_shell, unless we are waiting for HTML Imports to load. |
| 27 // HTML Imports allows a document to link to other HTMLs documents via |
| 28 // <link rel=import>. It also allows for those other documents to contain |
| 29 // <script> tags, which must be run before scripts on the main page. |
| 30 // We have package:html_import to polyfill this feature, and it will handle |
| 31 // starting Dartium/content_shell in that case. HTML Imports is used by Polymer, |
| 32 // but it could be used by itself too. See the specification: |
| 33 // https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html |
| 34 if (navigator.webkitStartDart && !window.HTMLImports) { |
| 27 navigator.webkitStartDart(); | 35 navigator.webkitStartDart(); |
| 28 } | 36 } |
| 29 | 37 |
| 30 // testRunner is provided by content shell. | 38 // testRunner is provided by content shell. |
| 31 // It is not available in selenium tests. | 39 // It is not available in selenium tests. |
| 32 var testRunner = window.testRunner || window.layoutTestController; | 40 var testRunner = window.testRunner || window.layoutTestController; |
| 33 | 41 |
| 34 var waitForDone = false; | 42 var waitForDone = false; |
| 35 | 43 |
| 36 // Returns the driving window object if available | 44 // Returns the driving window object if available |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 try { | 172 try { |
| 165 main(); | 173 main(); |
| 166 } catch (e) { | 174 } catch (e) { |
| 167 dartPrint(e); | 175 dartPrint(e); |
| 168 if (e.stack) dartPrint(e.stack); | 176 if (e.stack) dartPrint(e.stack); |
| 169 window.postMessage('unittest-suite-fail', '*'); | 177 window.postMessage('unittest-suite-fail', '*'); |
| 170 return; | 178 return; |
| 171 } | 179 } |
| 172 window.postMessage('dart-main-done', '*'); | 180 window.postMessage('dart-main-done', '*'); |
| 173 } | 181 } |
| OLD | NEW |