Chromium Code Reviews| Index: pkg/unittest/html_enhanced_config.dart |
| =================================================================== |
| --- pkg/unittest/html_enhanced_config.dart (revision 12649) |
| +++ pkg/unittest/html_enhanced_config.dart (working copy) |
| @@ -22,7 +22,24 @@ |
| // TODO(rnystrom): Get rid of this if we get canonical closures for methods. |
| EventListener _onErrorClosure; |
| + void _installErrorHandler() { |
| + if (_onErrorClosure == null) { |
| + _onErrorClosure = |
| + (e) => handleExternalError(e, '(DOM callback has errors)'); |
| + // Listen for uncaught errors. |
| + window.on.error.add(_onErrorClosure); |
| + } |
| + } |
| + |
| + void _removeErrorHandler() { |
|
Siggi Cherem (dart-lang)
2012/09/20 20:41:31
ditto (rename)
gram
2012/09/20 20:48:29
Done.
|
| + if (_onErrorClosure != null) { |
| + window.on.error.remove(_onErrorClosure); |
| + _onErrorClosure = null; |
| + } |
| + } |
| + |
| void onInit() { |
| + _installErrorHandler(); |
| //initialize and load CSS |
| final String _CSSID = '_unittestcss_'; |
| @@ -34,12 +51,10 @@ |
| } |
| cssElement.innerHTML = _htmlTestCSS; |
| - |
| - _onErrorClosure = |
| - (e) => handleExternalError(e, '(DOM callback has errors)'); |
| } |
| void onStart() { |
| + _installErrorHandler(); |
| window.postMessage('unittest-suite-wait-for-done', '*'); |
| // Listen for uncaught errors. |
| window.on.error.add(_onErrorClosure); |
| @@ -49,7 +64,7 @@ |
| void onDone(int passed, int failed, int errors, List<TestCase> results, |
| String uncaughtError) { |
| - window.on.error.remove(_onErrorClosure); |
| + _removeErrorHandler(); |
| _showInteractiveResultsInPage(passed, failed, errors, results, |
| _isLayoutTest, uncaughtError); |