Chromium Code Reviews| Index: dart/pkg/unittest/test_controller.js |
| diff --git a/dart/pkg/unittest/test_controller.js b/dart/pkg/unittest/test_controller.js |
| index ce7a8f0d469ee10bf7536939d94ac0f251a8dd78..8cb6b227316d405b26cd12019ad4da5ee5c8f272 100644 |
| --- a/dart/pkg/unittest/test_controller.js |
| +++ b/dart/pkg/unittest/test_controller.js |
| @@ -13,13 +13,26 @@ if (navigator.webkitStartDart) { |
| var testRunner = window.testRunner || window.layoutTestController; |
| +var waitForDone = false; |
| + |
| function processMessage(msg) { |
| - if (testRunner) { |
| - if (msg == 'unittest-suite-done') { |
| - testRunner.notifyDone(); |
| - } else if (msg == 'unittest-suite-wait-for-done') { |
| - testRunner.startedDartTest = true; |
| + if (typeof msg != 'string') return; |
| + if (msg == 'unittest-suite-done') { |
| + if (testRunner) testRunner.notifyDone(); |
| + } else if (msg == 'unittest-suite-wait-for-done') { |
| + waitForDone = true; |
| + if (testRunner) testRunner.startedDartTest = true; |
| + } else if (msg == 'dart-calling-main') { |
| + if (testRunner) testRunner.startedDartTest = true; |
| + } else if (msg == 'dart-main-done') { |
| + if (!waitForDone) { |
| + window.postMessage('unittest-suite-success', '*'); |
| } |
| + } else if (msg == 'unittest-suite-success') { |
| + document.body.innerHTML += '<pre>PASS</pre>'; |
| + if (testRunner) testRunner.notifyDone(); |
| + } else if (msg == 'unittest-suite-fail') { |
| + showErrorAndExit('Some tests failed.'); |
| } |
| } |
| @@ -59,7 +72,7 @@ window.addEventListener("error", function(e) { |
| showErrorAndExit(e && e.message); |
| }, false); |
| -document.onreadystatechange = function() { |
| +document.addEventListener('readystatechange', function () { |
| if (document.readyState != "loaded") return; |
| // If 'startedDartTest' is not set, that means that the test did not have |
| // a chance to load. This will happen when a load error occurs in the VM. |
| @@ -74,4 +87,16 @@ document.onreadystatechange = function() { |
| } |
| }, 0); |
| }, 50); |
| -}; |
| +}); |
| + |
| +function dartPrint(msg) { |
| + var pre = document.createElement("pre"); |
| + pre.appendChild(document.createTextNode(String(msg))); |
| + document.body.appendChild(pre); |
| +} |
| + |
| +function dartMainRunner(main) { |
| + window.postMessage('dart-calling-main', '*'); |
| + main(); |
|
kasperl
2012/09/10 07:37:03
Should the done post message be handling in a fina
ahe
2012/09/10 08:31:14
That is effectively what line 70 does.
|
| + window.postMessage('dart-main-done', '*'); |
| +} |