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