Chromium Code Reviews| Index: pkg/unittest/html_config.dart |
| =================================================================== |
| --- pkg/unittest/html_config.dart (revision 12649) |
| +++ pkg/unittest/html_config.dart (working copy) |
| @@ -20,22 +20,36 @@ |
| // 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
maybe rename [_removeErrorHandler] to [_uninstallE
gram
2012/09/20 20:48:29
Done.
|
| + if (_onErrorClosure != null) { |
| + window.on.error.remove(_onErrorClosure); |
| + _onErrorClosure = null; |
| + } |
| + } |
| + |
| void onInit() { |
| - _onErrorClosure = |
| - (e) => handleExternalError(e, '(DOM callback has errors)'); |
| + _installErrorHandler(); |
| } |
| void onStart() { |
| + _installErrorHandler(); |
| window.postMessage('unittest-suite-wait-for-done', '*'); |
| - // Listen for uncaught errors. |
| - window.on.error.add(_onErrorClosure); |
| } |
| void onTestResult(TestCase testCase) {} |
| void onDone(int passed, int failed, int errors, List<TestCase> results, |
| String uncaughtError) { |
| - window.on.error.remove(_onErrorClosure); |
| + _removeErrorHandler(); |
|
Siggi Cherem (dart-lang)
2012/09/20 20:41:31
since the idea of detaching/reataching it is mostl
gram
2012/09/20 20:48:29
Done.
|
| _showResultsInPage(passed, failed, errors, results, _isLayoutTest, |
| uncaughtError); |
| window.postMessage('unittest-suite-done', '*'); |