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

Unified Diff: pkg/unittest/lib/html_config.dart

Issue 12040059: Converting tests over to using event streams. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | tests/html/postmessage_structured_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/html_config.dart
diff --git a/pkg/unittest/lib/html_config.dart b/pkg/unittest/lib/html_config.dart
index a4a1f9feecbcb1cd6146369de0e09e10420d76a6..d4c9cdba48bf5652b859204ade1c5356bdbd26c2 100644
--- a/pkg/unittest/lib/html_config.dart
+++ b/pkg/unittest/lib/html_config.dart
@@ -7,6 +7,7 @@
*/
library unittest_html_config;
+import 'dart:async';
import 'dart:html';
import 'unittest.dart';
@@ -89,32 +90,28 @@ class HtmlConfiguration extends Configuration {
final bool _isLayoutTest;
HtmlConfiguration(this._isLayoutTest);
- // TODO(rnystrom): Get rid of this if we get canonical closures for methods.
- EventListener _onErrorClosure;
- EventListener _onMessageClosure;
+ StreamSubscription<Event> _onErrorSubscription;
+ StreamSubscription<Event> _onMessageSubscription;
void _installHandlers() {
- if (_onErrorClosure == null) {
- _onErrorClosure =
- (e) => handleExternalError(e, '(DOM callback has errors)');
- // Listen for uncaught errors.
- window.on.error.add(_onErrorClosure);
+ if (_onErrorSubscription == null) {
+ _onErrorSubscription = window.onError.listen(
+ (e) => handleExternalError(e, '(DOM callback has errors)'));
}
- if (_onMessageClosure == null) {
- _onMessageClosure = (e) => processMessage(e);
- // Listen for errors from JS.
- window.on.message.add(_onMessageClosure);
+ if (_onMessageSubscription == null) {
+ _onMessageSubscription = window.onMessage.listen(
+ (e) => processMessage(e));
}
}
void _uninstallHandlers() {
- if (_onErrorClosure != null) {
- window.on.error.remove(_onErrorClosure);
- _onErrorClosure = null;
+ if (_onErrorSubscription != null) {
+ _onErrorSubscription.cancel();
+ _onErrorSubscription = null;
}
- if (_onMessageClosure != null) {
- window.on.message.remove(_onMessageClosure);
- _onMessageClosure = null;
+ if (_onMessageSubscription != null) {
+ _onMessageSubscription.cancel();
+ _onMessageSubscription = null;
}
}
« no previous file with comments | « no previous file | sdk/lib/html/dart2js/html_dart2js.dart » ('j') | tests/html/postmessage_structured_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698