| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library tests.html.events_test; | 5 library tests.html.events_test; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 expect(invocationCounter, isZero); | 64 expect(invocationCounter, isZero); |
| 65 | 65 |
| 66 provider.forTarget(element).listen(handler); | 66 provider.forTarget(element).listen(handler); |
| 67 invocationCounter = 0; | 67 invocationCounter = 0; |
| 68 element.dispatchEvent(event); | 68 element.dispatchEvent(event); |
| 69 expect(invocationCounter, 1); | 69 expect(invocationCounter, 1); |
| 70 | 70 |
| 71 provider.forTarget(element).listen(handler); | 71 provider.forTarget(element).listen(handler); |
| 72 invocationCounter = 0; | 72 invocationCounter = 0; |
| 73 element.dispatchEvent(event); | 73 element.dispatchEvent(event); |
| 74 expect(invocationCounter, 1); | 74 |
| 75 // NOTE: when run in a custom zone, the handler is wrapped |
| 76 // The logic for html events which ensures identical handlers are added only |
| 77 // once is therefor muted by the wrapped handlers. |
| 78 // Hence, we get different behavior depending on the current zone. |
| 79 if(Zone.current == Zone.ROOT) { |
| 80 expect(invocationCounter, 1); |
| 81 } else { |
| 82 expect(invocationCounter, 2); |
| 83 } |
| 75 }); | 84 }); |
| 76 | 85 |
| 77 test('InitMouseEvent', () { | 86 test('InitMouseEvent', () { |
| 78 DivElement div = new Element.tag('div'); | 87 DivElement div = new Element.tag('div'); |
| 79 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); | 88 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); |
| 80 }); | 89 }); |
| 81 | 90 |
| 82 test('DOM event callbacks are associated with the correct zone', () { | 91 test('DOM event callbacks are associated with the correct zone', () { |
| 83 var callbacks = []; | 92 var callbacks = []; |
| 84 | 93 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 101 expect(Zone.current, equals(zone)); | 110 expect(Zone.current, equals(zone)); |
| 102 sub.cancel(); | 111 sub.cancel(); |
| 103 })); | 112 })); |
| 104 } | 113 } |
| 105 | 114 |
| 106 sub = element.on['test'].listen(expectAsync1(handler)); | 115 sub = element.on['test'].listen(expectAsync1(handler)); |
| 107 })); | 116 })); |
| 108 element.dispatchEvent(new Event('test')); | 117 element.dispatchEvent(new Event('test')); |
| 109 }); | 118 }); |
| 110 } | 119 } |
| OLD | NEW |