| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library polymer.test.web.event_path_test; |
| 6 |
| 7 import 'dart:html'; |
| 8 import 'dart:async'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; |
| 11 |
| 12 main() { |
| 13 useHtmlConfiguration(); |
| 14 test('bubbling in the right order', () { |
| 15 // TODO(sigmund): this should change once we port over the |
| 16 // 'WebComponentsReady' event. |
| 17 runAsync(expectAsync0(() { |
| 18 var item1 = query('#item1'); |
| 19 var menuButton = query('#menuButton'); |
| 20 // Note: polymer uses automatic node finding (menuButton.$.menu) |
| 21 // also note that their node finding code also reachs into the ids |
| 22 // from the parent shadow (menu.$.selectorContent instead of |
| 23 // menu.$.menuShadow.$.selectorContent) |
| 24 var menu = menuButton.shadowRoot.query('#menu'); |
| 25 var selector = menu.shadowRoot.query("#menuShadow"); |
| 26 var overlay = menuButton.shadowRoot.query('#overlay'); |
| 27 var expectedPath = <Node>[ |
| 28 item1, |
| 29 menuButton.shadowRoot.query('#menuButtonContent'), |
| 30 selector.olderShadowRoot.query('#selectorContent'), |
| 31 selector.olderShadowRoot.query('#selectorDiv'), |
| 32 menu.shadowRoot.query('#menuShadow').olderShadowRoot, |
| 33 menu.shadowRoot.query('#menuShadow'), |
| 34 menu.shadowRoot.query('#menuDiv'), |
| 35 menu.shadowRoot, |
| 36 menu, |
| 37 menuButton.shadowRoot.query('#menuButtonDiv'), |
| 38 // TODO(sigmund): this test is currently broken because currently |
| 39 // registerElement is sensitive to the order in which each custom |
| 40 // element is registered. When fixed, we should be able to add the |
| 41 // following three targets: |
| 42 // overlay.shadowRoot.query('#overlayContent'), |
| 43 // overlay.shadowRoot, |
| 44 // overlay, |
| 45 menuButton.shadowRoot, |
| 46 menuButton |
| 47 ]; |
| 48 var x = 0; |
| 49 for (int i = 0; i < expectedPath.length; i++) { |
| 50 var node = expectedPath[i]; |
| 51 expect(node, isNotNull, reason: "Should not be null at $i"); |
| 52 node.on['x'].listen(expectAsync1((e) { |
| 53 expect(e.currentTarget, node); |
| 54 expect(x++, i); |
| 55 })); |
| 56 } |
| 57 |
| 58 item1.dispatchEvent(new Event('x', canBubble: true)); |
| 59 })); |
| 60 }); |
| 61 } |
| OLD | NEW |