| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 function notifyStart() { | 56 function notifyStart() { |
| 57 var driver = getDriverWindow(); | 57 var driver = getDriverWindow(); |
| 58 if (driver) { | 58 if (driver) { |
| 59 driver.postMessage("STARTING", "*"); | 59 driver.postMessage("STARTING", "*"); |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 // We call notifyStart here to notify the encapsulating browser. | 62 // We call notifyStart here to notify the encapsulating browser. |
| 63 notifyStart(); | 63 notifyStart(); |
| 64 | 64 |
| 65 function notifyDone() { | 65 function notifyDone() { |
| 66 if (testRunner) testRunner.notifyDone(); |
| 67 |
| 66 // TODO(ricow): REMOVE, debug info, see issue 13292 | 68 // TODO(ricow): REMOVE, debug info, see issue 13292 |
| 67 dartPrint('Calling notifyDone()'); | 69 if (!testRunner) { |
| 68 if (testRunner) testRunner.notifyDone(); | 70 dartPrint('Calling notifyDone()'); |
| 71 } |
| 69 // To support in browser launching of tests we post back start and result | 72 // To support in browser launching of tests we post back start and result |
| 70 // messages to the window.opener. | 73 // messages to the window.opener. |
| 71 var driver = getDriverWindow(); | 74 var driver = getDriverWindow(); |
| 72 if (driver) { | 75 if (driver) { |
| 73 driver.postMessage(window.document.body.innerHTML, "*"); | 76 driver.postMessage(window.document.body.innerHTML, "*"); |
| 74 } | 77 } |
| 75 } | 78 } |
| 76 | 79 |
| 77 function processMessage(msg) { | 80 function processMessage(msg) { |
| 78 // TODO(ricow): REMOVE, debug info, see issue 13292 | 81 // TODO(ricow): REMOVE, debug info, see issue 13292 |
| 79 dartPrint('processMessage(): ' + msg); | 82 if (!testRunner) { |
| 80 | 83 dartPrint('processMessage(): ' + msg); |
| 84 } |
| 81 if (typeof msg != 'string') return; | 85 if (typeof msg != 'string') return; |
| 82 if (msg == 'unittest-suite-done') { | 86 if (msg == 'unittest-suite-done') { |
| 83 notifyDone(); | 87 notifyDone(); |
| 84 } else if (msg == 'unittest-suite-wait-for-done') { | 88 } else if (msg == 'unittest-suite-wait-for-done') { |
| 85 waitForDone = true; | 89 waitForDone = true; |
| 86 if (testRunner) testRunner.startedDartTest = true; | 90 if (testRunner) testRunner.startedDartTest = true; |
| 87 } else if (msg == 'dart-calling-main') { | 91 } else if (msg == 'dart-calling-main') { |
| 88 if (testRunner) testRunner.startedDartTest = true; | 92 if (testRunner) testRunner.startedDartTest = true; |
| 89 } else if (msg == 'dart-main-done') { | 93 } else if (msg == 'dart-main-done') { |
| 90 if (!waitForDone) { | 94 if (!waitForDone) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 try { | 182 try { |
| 179 main(); | 183 main(); |
| 180 } catch (e) { | 184 } catch (e) { |
| 181 dartPrint(e); | 185 dartPrint(e); |
| 182 if (e.stack) dartPrint(e.stack); | 186 if (e.stack) dartPrint(e.stack); |
| 183 window.postMessage('unittest-suite-fail', '*'); | 187 window.postMessage('unittest-suite-fail', '*'); |
| 184 return; | 188 return; |
| 185 } | 189 } |
| 186 window.postMessage('dart-main-done', '*'); | 190 window.postMessage('dart-main-done', '*'); |
| 187 } | 191 } |
| OLD | NEW |