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

Unified Diff: tests/html/shadow_dom_test.dart

Issue 10661039: added preliminary ShadowDOM tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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
Index: tests/html/shadow_dom_test.dart
diff --git a/tests/html/shadow_dom_test.dart b/tests/html/shadow_dom_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..02bb6abc8a4df03e79ba67d111a5a5fa019e6bf8
--- /dev/null
+++ b/tests/html/shadow_dom_test.dart
@@ -0,0 +1,54 @@
+// Copyright (c) 2011, 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('ShadowDOMTest');
+#import('../../lib/unittest/unittest.dart');
+#import('../../lib/unittest/html_config.dart');
+#import('dart:html');
+
+main() {
+ useHtmlConfiguration();
+
+ group("ShadowDOM tests", () {
+
+ var div1, div2, sr, para1, para2;
+
+ setUp(() {
+ para1 = new ParagraphElement();
Jacob 2012/06/26 18:22:57 avoid variable names with abbreviations such as p
samhop 2012/06/26 22:38:34 fixed by switching to shadowRoot and paragraph1, p
+ para2 = new ParagraphElement();
+ [para1, para2].forEach( (p) {
+ p.classes.add("foo");
Jacob 2012/06/26 18:22:57 odd spacing. Also, might as well just use for (va
Emily Fortuna 2012/06/26 18:30:53 Or just [para1, para2].forEach( (p) { p.classes.a
samhop 2012/06/26 22:38:34 Thank you for your respect for *proper* programmin
+ });
Siggi Cherem (dart-lang) 2012/06/26 18:28:30 nit: I prefer here just the 2 lines: para1.classes
samhop 2012/06/26 22:38:34 Done.
+ div1 = new DivElement();
+ div2 = new DivElement();
+ div1.classes.add('foo');
+ sr = new ShadowRoot(div2);
+ sr.nodes.add(para1);
+ // No constructor for ContentElement exists yet.
+ // See http://code.google.com/p/dart/issues/detail?id=3870.
+ sr.nodes.add(new Element.tag('content'));
+ div2.nodes.add(para2);
+ document.body.nodes.add(div1);
+ document.body.nodes.add(div2);
+ });
+
+ test("Shadowed nodes aren't visible to queries from outside ShadowDOM", () {
+ expect(queryAll('.foo'), equals([div1, para2]));
Siggi Cherem (dart-lang) 2012/06/26 18:28:30 << (only +2 indent)
samhop 2012/06/26 22:38:34 Done.
+ });
+
+ test("Parent node of a shadow root must be null.", () {
Siggi Cherem (dart-lang) 2012/06/26 18:28:30 nit: we try to consistently prefer ' over " unless
samhop 2012/06/26 22:38:34 Done.
+ expect(sr.parent, isNull);
+ });
+
+
+ // TODO(samhop): test that <content> and <content select="foo"> and
+ // <shadow>
+ // work properly. This is blocked on having a good way to do browser
+ // rendering tests.
+
+ test("Querying in shadowed fragment respects the shadow boundary.", () {
+ expect(sr.queryAll(".foo"), equals([para1]));
+ });
+ });
+}

Powered by Google App Engine
This is Rietveld 408576698