| 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 /** Configuration for running tests in a browser using dart:dom_deprecated. */ | 5 /** Configuration for running tests in a browser using dart:dom_deprecated. */ |
| 6 #library('dom_config'); | 6 #library('dom_config'); |
| 7 | 7 |
| 8 #import('dart:dom_deprecated'); | 8 #import('dart:dom_deprecated'); |
| 9 #import('unittest.dart'); | 9 #import('unittest.dart'); |
| 10 | 10 |
| 11 #source('html_print.dart'); | 11 #source('html_print.dart'); |
| 12 | 12 |
| 13 class DomConfiguration extends Configuration { | 13 class DomConfiguration extends Configuration { |
| 14 /** Whether this is run within dartium layout tests. */ | 14 /** Whether this is run within dartium layout tests. */ |
| 15 final bool _isLayoutTest; | 15 final bool _isLayoutTest; |
| 16 | 16 |
| 17 DomConfiguration(this._isLayoutTest); | 17 DomConfiguration(this._isLayoutTest); |
| 18 | 18 |
| 19 // TODO(rnystrom): Get rid of this if we get canonical closures for methods. | 19 // TODO(rnystrom): Get rid of this if we get canonical closures for methods. |
| 20 EventListener _onErrorClosure; | 20 EventListener _onErrorClosure; |
| 21 | 21 |
| 22 void onInit() { | 22 void onInit() { |
| 23 _onErrorClosure = (e) { | 23 _onErrorClosure = |
| 24 // TODO(vsm): figure out how to expose the stack trace here | 24 (e) => handleExternalError(e, '(DOM callback has errors)'); |
| 25 // Currently e.message works in dartium, but not in dartc. | |
| 26 reportTestError('(DOM callback has errors) Caught $e', ''); | |
| 27 }; | |
| 28 } | 25 } |
| 29 | 26 |
| 30 void onStart() { | 27 void onStart() { |
| 31 window.postMessage('unittest-suite-wait-for-done', '*'); | 28 window.postMessage('unittest-suite-wait-for-done', '*'); |
| 32 // Listen for uncaught errors. | 29 // Listen for uncaught errors. |
| 33 window.addEventListener('error', _onErrorClosure, true); | 30 window.addEventListener('error', _onErrorClosure, true); |
| 34 } | 31 } |
| 35 | 32 |
| 36 void onTestResult(TestCase testCase) {} | 33 void onTestResult(TestCase testCase) {} |
| 37 | 34 |
| 38 void onDone(int passed, int failed, int errors, List<TestCase> results, | 35 void onDone(int passed, int failed, int errors, List<TestCase> results, |
| 39 String uncaughtError) { | 36 String uncaughtError) { |
| 40 window.removeEventListener('error', _onErrorClosure); | 37 window.removeEventListener('error', _onErrorClosure); |
| 41 _showResultsInPage(passed, failed, errors, results, _isLayoutTest, | 38 _showResultsInPage(passed, failed, errors, results, _isLayoutTest, |
| 42 uncaughtError); | 39 uncaughtError); |
| 43 window.postMessage('unittest-suite-done', '*'); | 40 window.postMessage('unittest-suite-done', '*'); |
| 44 } | 41 } |
| 45 } | 42 } |
| 46 | 43 |
| 47 void useDomConfiguration([bool isLayoutTest = false]) { | 44 void useDomConfiguration([bool isLayoutTest = false]) { |
| 48 configure(new DomConfiguration(isLayoutTest)); | 45 configure(new DomConfiguration(isLayoutTest)); |
| 49 } | 46 } |
| OLD | NEW |