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

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
« no previous file with comments | « pkg/unittest/html_config.dart ('k') | pkg/unittest/interactive_html_config.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 _uninstallErrorHandler() {
+ if (_onErrorClosure != null) {
+ window.on.error.remove(_onErrorClosure);
+ _onErrorClosure = null;
+ }
+ }
+
void onInit() {
+ _installErrorHandler();
//initialize and load CSS
final String _CSSID = '_unittestcss_';
@@ -34,9 +51,6 @@
}
cssElement.innerHTML = _htmlTestCSS;
-
- _onErrorClosure =
- (e) => handleExternalError(e, '(DOM callback has errors)');
}
void onStart() {
@@ -49,7 +63,7 @@
void onDone(int passed, int failed, int errors, List<TestCase> results,
String uncaughtError) {
- window.on.error.remove(_onErrorClosure);
+ _uninstallErrorHandler();
_showInteractiveResultsInPage(passed, failed, errors, results,
_isLayoutTest, uncaughtError);
« no previous file with comments | « pkg/unittest/html_config.dart ('k') | pkg/unittest/interactive_html_config.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698