| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 } | 44 } |
| 45 return null; | 45 return null; |
| 46 } | 46 } |
| 47 | 47 |
| 48 function notifyStart() { | 48 function notifyStart() { |
| 49 var driver = getDriverWindow(); | 49 var driver = getDriverWindow(); |
| 50 if (driver) { | 50 if (driver) { |
| 51 driver.postMessage("STARTING", "*"); | 51 driver.postMessage("STARTING", "*"); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 // We call notifyStart here to notify the encapsulating browser. |
| 55 notifyStart(); |
| 54 | 56 |
| 55 function notifyDone() { | 57 function notifyDone() { |
| 56 if (testRunner) testRunner.notifyDone(); | 58 if (testRunner) testRunner.notifyDone(); |
| 57 // To support in browser launching of tests we post back start and result | 59 // To support in browser launching of tests we post back start and result |
| 58 // messages to the window.opener. | 60 // messages to the window.opener. |
| 59 var driver = getDriverWindow(); | 61 var driver = getDriverWindow(); |
| 60 if (driver) { | 62 if (driver) { |
| 61 driver.postMessage(window.document.body.innerHTML, "*"); | 63 driver.postMessage(window.document.body.innerHTML, "*"); |
| 62 } | 64 } |
| 63 } | 65 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return; | 153 return; |
| 152 } | 154 } |
| 153 var pre = document.createElement("pre"); | 155 var pre = document.createElement("pre"); |
| 154 pre.appendChild(document.createTextNode(String(msg))); | 156 pre.appendChild(document.createTextNode(String(msg))); |
| 155 document.body.appendChild(pre); | 157 document.body.appendChild(pre); |
| 156 } | 158 } |
| 157 | 159 |
| 158 // dart2js will generate code to call this function instead of calling | 160 // dart2js will generate code to call this function instead of calling |
| 159 // Dart [main] directly. The argument is a closure that invokes main. | 161 // Dart [main] directly. The argument is a closure that invokes main. |
| 160 function dartMainRunner(main) { | 162 function dartMainRunner(main) { |
| 161 // We call notifyStart here to notify the encapsulating browser. | |
| 162 notifyStart(); | |
| 163 window.postMessage('dart-calling-main', '*'); | 163 window.postMessage('dart-calling-main', '*'); |
| 164 try { | 164 try { |
| 165 main(); | 165 main(); |
| 166 } catch (e) { | 166 } catch (e) { |
| 167 dartPrint(e); | 167 dartPrint(e); |
| 168 if (e.stack) dartPrint(e.stack); | 168 if (e.stack) dartPrint(e.stack); |
| 169 window.postMessage('unittest-suite-fail', '*'); | 169 window.postMessage('unittest-suite-fail', '*'); |
| 170 return; | 170 return; |
| 171 } | 171 } |
| 172 window.postMessage('dart-main-done', '*'); | 172 window.postMessage('dart-main-done', '*'); |
| 173 } | 173 } |
| OLD | NEW |