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

Side by Side Diff: tests/html/shadow_dom_test.dart

Issue 11748003: Fixing up WebComponents types & tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/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('supported', () {
14 test('supported', () {
15 expect(ShadowRoot.supported, true);
16 });
17 });
18
13 group('ShadowDOM tests', () { 19 group('ShadowDOM tests', () {
14 20
15 var div1, div2, shadowRoot, paragraph1, paragraph2; 21 var div1, div2, shadowRoot, paragraph1, paragraph2;
16 22
17 setUp(() { 23 init() {
18 paragraph1 = new ParagraphElement(); 24 paragraph1 = new ParagraphElement();
19 paragraph2 = new ParagraphElement(); 25 paragraph2 = new ParagraphElement();
20 [paragraph1, paragraph2].forEach((p) { p.classes.add('foo');}); 26 [paragraph1, paragraph2].forEach((p) { p.classes.add('foo');});
21 div1 = new DivElement(); 27 div1 = new DivElement();
22 div2 = new DivElement(); 28 div2 = new DivElement();
23 div1.classes.add('foo'); 29 div1.classes.add('foo');
24 shadowRoot = div2.webkitCreateShadowRoot(); 30 shadowRoot = div2.createShadowRoot();
25 shadowRoot.nodes.add(paragraph1); 31 shadowRoot.nodes.add(paragraph1);
26 // No constructor for ContentElement exists yet. 32 shadowRoot.nodes.add(new ContentElement());
27 // See http://code.google.com/p/dart/issues/detail?id=3870.
28 shadowRoot.nodes.add(new Element.tag('content'));
29 div2.nodes.add(paragraph2); 33 div2.nodes.add(paragraph2);
30 document.body.nodes.add(div1); 34 document.body.nodes.add(div1);
31 document.body.nodes.add(div2); 35 document.body.nodes.add(div2);
32 }); 36 }
37
38 var expectation = ShadowRoot.supported ? returnsNormally : throws;
33 39
34 test("Shadowed nodes aren't visible to queries from outside ShadowDOM", () { 40 test("Shadowed nodes aren't visible to queries from outside ShadowDOM", () {
35 expect(queryAll('.foo'), equals([div1, paragraph2])); 41 expect(() {
42 init();
43
Emily Fortuna 2013/01/02 18:54:04 probably don't need the extra newlines here
44 expect(queryAll('.foo'), equals([div1, paragraph2]));
45 }, expectation);
36 }); 46 });
37 47
38 test('Parent node of a shadow root must be null.', () { 48 test('Parent node of a shadow root must be null.', () {
39 expect(shadowRoot.parent, isNull); 49 expect(() {
50 init();
51
52 expect(shadowRoot.parent, isNull);
53 }, expectation);
40 }); 54 });
41 55
42 56
43 // TODO(samhop): test that <content> and <content select="foo"> and 57 // TODO(samhop): test that <content> and <content select="foo"> and
44 // <shadow> 58 // <shadow>
45 // work properly. This is blocked on having a good way to do browser 59 // work properly. This is blocked on having a good way to do browser
46 // rendering tests. 60 // rendering tests.
47 61
48 test('Querying in shadowed fragment respects the shadow boundary.', () { 62 test('Querying in shadowed fragment respects the shadow boundary.', () {
49 expect(shadowRoot.queryAll('.foo'), equals([paragraph1])); 63 expect(() {
64 init();
65
66 expect(shadowRoot.queryAll('.foo'), equals([paragraph1]));
67 }, expectation);
50 }); 68 });
51 }); 69 });
52 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698