Chromium Code Reviews| Index: pkg/unittest/lib/test_controller.js |
| =================================================================== |
| --- pkg/unittest/lib/test_controller.js (revision 22979) |
| +++ pkg/unittest/lib/test_controller.js (working copy) |
| @@ -33,8 +33,18 @@ |
| var waitForDone = false; |
| -function sendDomToTestDriver() { |
| +function start() { |
|
kustermann
2013/05/22 17:08:50
For symmetry reasons, I'd call it 'notifyStart()'.
ricow1
2013/05/22 17:36:12
Done.
|
| + if (testRunner) testRunner.startedDartTest = true; |
| if (window.opener) { |
| + window.opener.postMessage("STARTING", "*"); |
| + } |
| +} |
| + |
| +function notifyDone() { |
| + if (testRunner) testRunner.notifyDone(); |
| + // To support in browser launching of tests we post back start and result |
| + // messages to the window.opener. |
| + if (window.opener) { |
| window.opener.postMessage(window.document.body.innerHTML, "*"); |
| } |
| } |
| @@ -42,21 +52,19 @@ |
| function processMessage(msg) { |
| if (typeof msg != 'string') return; |
| if (msg == 'unittest-suite-done') { |
| - if (testRunner) testRunner.notifyDone(); |
| - sendDomToTestDriver(); |
| + notifyDone(); |
| } else if (msg == 'unittest-suite-wait-for-done') { |
| waitForDone = true; |
| - if (testRunner) testRunner.startedDartTest = true; |
| + start(); |
| } else if (msg == 'dart-calling-main') { |
| - if (testRunner) testRunner.startedDartTest = true; |
| + start(); |
|
kustermann
2013/05/22 17:08:50
When we reach this point, the test has already bee
ricow1
2013/05/22 17:36:12
That is fine, we do 2 postmessage there, they will
|
| } else if (msg == 'dart-main-done') { |
| if (!waitForDone) { |
| window.postMessage('unittest-suite-success', '*'); |
| } |
| } else if (msg == 'unittest-suite-success') { |
| dartPrint('PASS'); |
| - if (testRunner) testRunner.notifyDone(); |
| - sendDomToTestDriver(); |
| + notifyDone(); |
| } else if (msg == 'unittest-suite-fail') { |
| showErrorAndExit('Some tests failed.'); |
| } |
| @@ -79,8 +87,7 @@ |
| // dart/tools/testing/run_selenium.py is looking for either PASS or |
| // FAIL and will continue polling until one of these words show up. |
| dartPrint('FAIL'); |
| - if (testRunner) testRunner.notifyDone(); |
| - sendDomToTestDriver(); |
| + nofityDone(); |
| } |
| function onLoad(e) { |
| @@ -115,8 +122,7 @@ |
| // posted message. |
| setTimeout(function() { |
| if (testRunner && !testRunner.startedDartTest) { |
| - testRunner.notifyDone(); |
| - sendDomToTestDriver(); |
| + notifyDone(); |
| } |
| }, 0); |
| }, 50); |