Chromium Code Reviews| 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 * DumpRenderTree. | 7 * DumpRenderTree. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 if (navigator.webkitStartDart) { | 10 if (navigator.webkitStartDart) { |
| 11 navigator.webkitStartDart(); | 11 navigator.webkitStartDart(); |
| 12 } | 12 } |
| 13 | 13 |
| 14 // testRunner is provided by DRT or WebKit's layout tests. | 14 // testRunner is provided by DRT or WebKit's layout tests. |
| 15 // It is not available in selenium tests. | 15 // It is not available in selenium tests. |
| 16 var testRunner = window.testRunner || window.layoutTestController; | 16 var testRunner = window.testRunner || window.layoutTestController; |
| 17 | 17 |
| 18 var waitForDone = false; | 18 var waitForDone = false; |
| 19 | 19 |
| 20 var _callback; | |
|
ahe
2012/10/09 06:01:04
Could you add a comment to explain what is going o
Emily Fortuna
2012/10/09 18:15:22
+1
gram
2012/10/09 18:57:14
Done.
| |
| 21 function getMessages(callback) { | |
| 22 _callback = callback; | |
| 23 window.postMessage("getMessages", "*"); | |
| 24 } | |
| 25 | |
| 20 function processMessage(msg) { | 26 function processMessage(msg) { |
| 21 if (typeof msg != 'string') return; | 27 if (typeof msg != 'string') { |
| 28 if (msg.type == "gotMessages") { | |
| 29 if (_callback) { | |
| 30 _callback(msg.messages); | |
| 31 _callback = null; | |
| 32 } | |
| 33 } | |
| 34 return; | |
| 35 } | |
| 22 if (msg == 'unittest-suite-done') { | 36 if (msg == 'unittest-suite-done') { |
| 23 if (testRunner) testRunner.notifyDone(); | 37 if (testRunner) testRunner.notifyDone(); |
| 24 } else if (msg == 'unittest-suite-wait-for-done') { | 38 } else if (msg == 'unittest-suite-wait-for-done') { |
| 25 waitForDone = true; | 39 waitForDone = true; |
| 26 if (testRunner) testRunner.startedDartTest = true; | 40 if (testRunner) testRunner.startedDartTest = true; |
| 27 } else if (msg == 'dart-calling-main') { | 41 } else if (msg == 'dart-calling-main') { |
| 28 if (testRunner) testRunner.startedDartTest = true; | 42 if (testRunner) testRunner.startedDartTest = true; |
| 29 } else if (msg == 'dart-main-done') { | 43 } else if (msg == 'dart-main-done') { |
| 30 if (!waitForDone) { | 44 if (!waitForDone) { |
| 31 window.postMessage('unittest-suite-success', '*'); | 45 window.postMessage('unittest-suite-success', '*'); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 function dartMainRunner(main) { | 126 function dartMainRunner(main) { |
| 113 window.postMessage('dart-calling-main', '*'); | 127 window.postMessage('dart-calling-main', '*'); |
| 114 try { | 128 try { |
| 115 main(); | 129 main(); |
| 116 } catch (e) { | 130 } catch (e) { |
| 117 window.postMessage('unittest-suite-fail', '*'); | 131 window.postMessage('unittest-suite-fail', '*'); |
| 118 return; | 132 return; |
| 119 } | 133 } |
| 120 window.postMessage('dart-main-done', '*'); | 134 window.postMessage('dart-main-done', '*'); |
| 121 } | 135 } |
| OLD | NEW |