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

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

Issue 22912004: Initial Dartium custom element support (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Mark tests fail until parser fix Created 7 years, 4 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
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 custom_elements_test; 5 library custom_elements_test;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 9
10 class CustomType extends Element { 10 class CustomType extends Element {
11 factory CustomType() => null;
12
11 bool onCreatedCalled = false; 13 bool onCreatedCalled = false;
12 void onCreated() { 14 void onCreated() {
13 onCreatedCalled = true; 15 onCreatedCalled = true;
16 customCreatedCount++;
14 } 17 }
15 } 18 }
16 19
20 int customCreatedCount = 0;
21
17 class NotAnElement {} 22 class NotAnElement {}
18 23
19 main() { 24 main() {
20 useHtmlIndividualConfiguration(); 25 useHtmlIndividualConfiguration();
21 26
22 group('register', () { 27 group('register', () {
23 test('register', () { 28 test('register', () {
24 document.register('x-type1', CustomType); 29 document.register('x-type1', CustomType);
25 30
26 var element = new Element.tag('x-type1'); 31 var element = new Element.tag('x-type1');
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 var firedOnPost = false; 93 var firedOnPost = false;
89 postElement.onFocus.listen((_) { 94 postElement.onFocus.listen((_) {
90 firedOnPost = true; 95 firedOnPost = true;
91 }); 96 });
92 // Event handlers should not persist to new element. 97 // Event handlers should not persist to new element.
93 postElement.dispatchEvent(new Event('focus')); 98 postElement.dispatchEvent(new Event('focus'));
94 expect(firedOnPre, isFalse); 99 expect(firedOnPre, isFalse);
95 expect(firedOnPost, isTrue); 100 expect(firedOnPost, isTrue);
96 }); 101 });
97 }); 102 });
103
104 group('innerHtml', () {
105 test('query', () {
106 document.register('x-type8', CustomType);
107 var element = new DivElement();
108 element.innerHtml = '<x-type8></x-type8>';
109 document.body.nodes.add(element);
110 var queried = query('x-type8');
111
112 expect(queried, isNotNull);
113 expect(queried is CustomType, isTrue);
114 expect(queried.onCreatedCalled, isTrue);
115 });
116 });
117
118 group('lifecycle', () {
119 test('onCreated', () {
120 int oldCount = customCreatedCount;
121
122 document.register('x-type9', CustomType);
123 var element = new DivElement();
124 element.innerHtml = '<x-type9></x-type9>';
125 document.body.nodes.add(element);
126 expect(customCreatedCount, oldCount + 1);
127 });
128 });
98 } 129 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698