Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011, 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('ShadowDOMTest'); | |
| 6 #import('../../lib/unittest/unittest.dart'); | |
| 7 #import('../../lib/unittest/html_config.dart'); | |
| 8 #import('dart:html'); | |
| 9 | |
| 10 main() { | |
| 11 useHtmlConfiguration(); | |
| 12 | |
| 13 group("ShadowDOM tests", () { | |
| 14 | |
| 15 var div1, div2, sr, para1, para2; | |
| 16 | |
| 17 setUp(() { | |
| 18 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
| |
| 19 para2 = new ParagraphElement(); | |
| 20 [para1, para2].forEach( (p) { | |
| 21 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
| |
| 22 }); | |
|
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.
| |
| 23 div1 = new DivElement(); | |
| 24 div2 = new DivElement(); | |
| 25 div1.classes.add('foo'); | |
| 26 sr = new ShadowRoot(div2); | |
| 27 sr.nodes.add(para1); | |
| 28 // No constructor for ContentElement exists yet. | |
| 29 // See http://code.google.com/p/dart/issues/detail?id=3870. | |
| 30 sr.nodes.add(new Element.tag('content')); | |
| 31 div2.nodes.add(para2); | |
| 32 document.body.nodes.add(div1); | |
| 33 document.body.nodes.add(div2); | |
| 34 }); | |
| 35 | |
| 36 test("Shadowed nodes aren't visible to queries from outside ShadowDOM", () { | |
| 37 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.
| |
| 38 }); | |
| 39 | |
| 40 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.
| |
| 41 expect(sr.parent, isNull); | |
| 42 }); | |
| 43 | |
| 44 | |
| 45 // TODO(samhop): test that <content> and <content select="foo"> and | |
| 46 // <shadow> | |
| 47 // work properly. This is blocked on having a good way to do browser | |
| 48 // rendering tests. | |
| 49 | |
| 50 test("Querying in shadowed fragment respects the shadow boundary.", () { | |
| 51 expect(sr.queryAll(".foo"), equals([para1])); | |
| 52 }); | |
| 53 }); | |
| 54 } | |
| OLD | NEW |