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