| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // [print] with the secret messages "unittest-suite-success" and | 145 // [print] with the secret messages "unittest-suite-success" and |
| 146 // "unittest-suite-wait-for-done". These messages are then posted so | 146 // "unittest-suite-wait-for-done". These messages are then posted so |
| 147 // processMessage above will see them. | 147 // processMessage above will see them. |
| 148 function dartPrint(msg) { | 148 function dartPrint(msg) { |
| 149 if ((msg === 'unittest-suite-success') | 149 if ((msg === 'unittest-suite-success') |
| 150 || (msg === 'unittest-suite-done') | 150 || (msg === 'unittest-suite-done') |
| 151 || (msg === 'unittest-suite-wait-for-done')) { | 151 || (msg === 'unittest-suite-wait-for-done')) { |
| 152 window.postMessage(msg, '*'); | 152 window.postMessage(msg, '*'); |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 if (typeof console === 'object') console.warn(msg); |
| 155 var pre = document.createElement("pre"); | 156 var pre = document.createElement("pre"); |
| 156 pre.appendChild(document.createTextNode(String(msg))); | 157 pre.appendChild(document.createTextNode(String(msg))); |
| 157 document.body.appendChild(pre); | 158 document.body.appendChild(pre); |
| 158 } | 159 } |
| 159 | 160 |
| 160 // dart2js will generate code to call this function instead of calling | 161 // dart2js will generate code to call this function instead of calling |
| 161 // Dart [main] directly. The argument is a closure that invokes main. | 162 // Dart [main] directly. The argument is a closure that invokes main. |
| 162 function dartMainRunner(main) { | 163 function dartMainRunner(main) { |
| 163 window.postMessage('dart-calling-main', '*'); | 164 window.postMessage('dart-calling-main', '*'); |
| 164 try { | 165 try { |
| 165 main(); | 166 main(); |
| 166 } catch (e) { | 167 } catch (e) { |
| 167 dartPrint(e); | 168 dartPrint(e); |
| 168 if (e.stack) dartPrint(e.stack); | 169 if (e.stack) dartPrint(e.stack); |
| 169 window.postMessage('unittest-suite-fail', '*'); | 170 window.postMessage('unittest-suite-fail', '*'); |
| 170 return; | 171 return; |
| 171 } | 172 } |
| 172 window.postMessage('dart-main-done', '*'); | 173 window.postMessage('dart-main-done', '*'); |
| 173 } | 174 } |
| OLD | NEW |