Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Unified Diff: pkg/unittest/html_enhanced_config.dart

Issue 10959025: Move the addition of an onError handler to earlier (onInit instead of onStart), while still support… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);

Powered by Google App Engine
This is Rietveld 408576698