Files
sdk/pkg/polymer/test/event_path_test.dart
T
sigmund@google.com 4d357c5148 Improves how to initialize polymer apps and fixes polymer build and linter to
match Dartium semantics (Issue 14238). In particular:
  - only one script tag is allowed per document
  - initPolymer can be call from init.dart or the users main method, the build
    process knows how to call the user's main given the new Dartium semantics.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org//27903006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28971 260f80e4-7a28-3924-810f-c04153c831b5
2013-10-21 23:30:23 +00:00

81 lines
2.6 KiB
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 polymer.test.web.event_path_test;
import 'dart:html';
import 'package:polymer/polymer.dart';
import 'package:unittest/html_config.dart';
import 'package:unittest/unittest.dart';
@CustomTag("x-selector")
class XSelector extends PolymerElement {
XSelector.created() : super.created();
}
@CustomTag("x-overlay")
class XOverlay extends PolymerElement {
XOverlay.created() : super.created();
}
@CustomTag("x-menu")
class XMenu extends PolymerElement {
XMenu.created() : super.created();
}
@CustomTag("x-menu-button")
class XMenuButton extends PolymerElement {
XMenuButton.created() : super.created();
}
main() {
initPolymer();
useHtmlConfiguration();
setUp(() => Polymer.onReady);
test('bubbling in the right order', () {
var item1 = query('#item1');
var menuButton = query('#menuButton');
// Note: polymer uses automatic node finding (menuButton.$.menu)
// also note that their node finding code also reachs into the ids
// from the parent shadow (menu.$.selectorContent instead of
// menu.$.menuShadow.$.selectorContent)
var menu = menuButton.shadowRoot.query('#menu');
var overlay = menuButton.shadowRoot.query('#overlay');
var expectedPath = <Node>[
item1,
menuButton.shadowRoot.query('#menuButtonContent'),
menu.shadowRoot.olderShadowRoot.query('#selectorContent'),
menu.shadowRoot.olderShadowRoot.query('#selectorDiv'),
menu.shadowRoot.olderShadowRoot,
menu.shadowRoot.query('#menuShadow'),
menu.shadowRoot.query('#menuDiv'),
menu.shadowRoot,
menu,
menuButton.shadowRoot.query('#menuButtonDiv'),
// TODO(sigmund): this test is currently broken because currently
// registerElement is sensitive to the order in which each custom
// element is registered. When fixed, we should be able to add the
// following three targets:
// overlay.shadowRoot.query('#overlayContent'),
// overlay.shadowRoot,
// overlay,
menuButton.shadowRoot,
menuButton
];
var x = 0;
for (int i = 0; i < expectedPath.length; i++) {
var node = expectedPath[i];
expect(node, isNotNull, reason: "Should not be null at $i");
node.on['x'].listen(expectAsync1((e) {
expect(e.currentTarget, node);
expect(x++, i);
}));
}
item1.dispatchEvent(new Event('x', canBubble: true));
});
}