| Index: tests/html/events_test.dart
|
| diff --git a/tests/html/events_test.dart b/tests/html/events_test.dart
|
| index 8451c893d6363a04d452f576541e060cb3574ef7..73de9453c55899621c1ebf38a107a041cf6ae716 100644
|
| --- a/tests/html/events_test.dart
|
| +++ b/tests/html/events_test.dart
|
| @@ -1,7 +1,13 @@
|
| -library EventsTest;
|
| -import '../../pkg/unittest/lib/unittest.dart';
|
| -import '../../pkg/unittest/lib/html_config.dart';
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +library tests.html.events_test;
|
| +
|
| +import 'dart:async';
|
| import 'dart:html';
|
| +import 'package:unittest/unittest.dart';
|
| +import 'package:unittest/html_config.dart';
|
|
|
| main() {
|
| useHtmlConfiguration();
|
| @@ -72,4 +78,39 @@ main() {
|
| DivElement div = new Element.tag('div');
|
| MouseEvent event = new MouseEvent('zebra', relatedTarget: div);
|
| });
|
| +
|
| + test('DOM event callbaccks are associated with the correct zone', () {
|
| + var callbacks = [];
|
| + runZonedExperimental(expectAsync0(() {
|
| + final element = new Element.tag('test');
|
| + element.id = 'eventtarget';
|
| + document.body.append(element);
|
| +
|
| + int asyncCounter = 0;
|
| + var asyncCallback = expectAsync0(() {
|
| + asyncCounter++;
|
| + });
|
| +
|
| + void handler(Event e) {
|
| + expect(e.type, equals('test'));
|
| + Element target = e.target;
|
| + expect(element, equals(target));
|
| +
|
| + runAsync(asyncCallback);
|
| + }
|
| +
|
| + var provider = new EventStreamProvider<CustomEvent>('test');
|
| + var sub = provider.forTarget(element).listen(expectAsync1(handler));
|
| + element.dispatchEvent(new Event('test'));
|
| +
|
| + expect(callbacks.length, 1, reason: 'event was run in a zone.');
|
| + expect(asyncCounter, 0, reason: 'callback was not invoked yet.');
|
| + callbacks.first();
|
| + expect(asyncCounter, 1, reason: 'callback was invoked.');
|
| + sub.cancel();
|
| + }), onRunAsync: (x) {
|
| + callbacks.add(x);
|
| + return x;
|
| + });
|
| + });
|
| }
|
|
|