| Index: dart/pkg/unittest/test_controller.js
|
| diff --git a/dart/pkg/unittest/test_controller.js b/dart/pkg/unittest/test_controller.js
|
| index 5b2152103bf5aff2ecc26f92523f547632898e50..b5734b93e78d000f21799c3d611a95bd1f2e3bd8 100644
|
| --- a/dart/pkg/unittest/test_controller.js
|
| +++ b/dart/pkg/unittest/test_controller.js
|
| @@ -11,6 +11,8 @@ if (navigator.webkitStartDart) {
|
| navigator.webkitStartDart();
|
| }
|
|
|
| +// testRunner is provided by DRT or WebKit's layout tests.
|
| +// It is not available in selenium tests.
|
| var testRunner = window.testRunner || window.layoutTestController;
|
|
|
| var waitForDone = false;
|
| @@ -29,7 +31,7 @@ function processMessage(msg) {
|
| window.postMessage('unittest-suite-success', '*');
|
| }
|
| } else if (msg == 'unittest-suite-success') {
|
| - document.body.innerHTML += '<pre>PASS</pre>';
|
| + dartPrint('PASS');
|
| if (testRunner) testRunner.notifyDone();
|
| } else if (msg == 'unittest-suite-fail') {
|
| showErrorAndExit('Some tests failed.');
|
| @@ -48,13 +50,12 @@ window.addEventListener("message", onReceive, false);
|
|
|
| function showErrorAndExit(message) {
|
| if (message) {
|
| - var element = document.createElement('pre');
|
| - element.innerHTML = message;
|
| - document.body.appendChild(element);
|
| - }
|
| - if (testRunner) {
|
| - testRunner.notifyDone();
|
| + dartPrint('Error: ' + String(message));
|
| }
|
| + // 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();
|
| }
|
|
|
| function onLoad(e) {
|
| @@ -109,6 +110,11 @@ function dartPrint(msg) {
|
| // Dart [main] directly. The argument is a closure that invokes main.
|
| function dartMainRunner(main) {
|
| window.postMessage('dart-calling-main', '*');
|
| - main();
|
| + try {
|
| + main();
|
| + } catch (e) {
|
| + window.postMessage('unittest-suite-fail', '*');
|
| + return;
|
| + }
|
| window.postMessage('dart-main-done', '*');
|
| }
|
|
|