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

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

Issue 23276003: Updating custom element's preregister test to follow new contracts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Removing analyzer test skip. 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 CustomMixin { 10 class CustomMixin {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 }); 83 });
84 }); 84 });
85 85
86 group('preregister', () { 86 group('preregister', () {
87 // TODO(vsm): Modify this test once we agree on the proper semantics. 87 // TODO(vsm): Modify this test once we agree on the proper semantics.
88 test('pre-registration construction', () { 88 test('pre-registration construction', () {
89 var tag = nextTag; 89 var tag = nextTag;
90 var dom = new Element.html('<div><$tag></$tag></div>'); 90 var dom = new Element.html('<div><$tag></$tag></div>');
91 var preElement = dom.children[0]; 91 var preElement = dom.children[0];
92 expect(preElement, isNotNull); 92 expect(preElement, isNotNull);
93 expect(preElement is UnknownElement, isTrue); 93 expect(preElement is HtmlElement, isTrue);
94 expect(preElement is CustomType, isFalse);
94 var firedOnPre = false; 95 var firedOnPre = false;
95 preElement.onFocus.listen((_) { 96 preElement.onFocus.listen((_) {
96 firedOnPre = true; 97 firedOnPre = true;
97 }); 98 });
98 99
99 document.register(tag, CustomType); 100 document.register(tag, CustomType);
100 101
101 var postElement = dom.children[0]; 102 var postElement = dom.children[0];
102 expect(postElement, isNotNull); 103 expect(postElement, isNotNull);
103 expect(postElement is CustomType, isTrue); 104 expect(postElement is CustomType, isTrue);
104 expect(postElement.onCreatedCalled, isTrue); 105 expect(postElement.onCreatedCalled, isTrue);
105 106
106 // Element from first query remains an UnknownElement. 107 // Element from first query remains an UnknownElement.
107 expect(preElement is UnknownElement, isTrue); 108 expect(preElement is HtmlElement, isTrue);
108 expect(preElement.parent, isNull); 109 expect(preElement.parent, dom);
109 expect(dom.children.length, 1); 110 expect(dom.children.length, 1);
110 111
111 var firedOnPost = false; 112 var firedOnPost = false;
112 postElement.onFocus.listen((_) { 113 postElement.onFocus.listen((_) {
113 firedOnPost = true; 114 firedOnPost = true;
114 }); 115 });
115 // Event handlers should not persist to new element. 116 // Event handlers should not persist to new element.
116 postElement.dispatchEvent(new Event('focus')); 117 postElement.dispatchEvent(new Event('focus'));
117 expect(firedOnPre, isFalse); 118 expect(firedOnPre, isTrue);
vsm 2013/08/16 18:28:51 This doesn't match the comment on line #116.
blois 2013/08/16 19:45:48 Done.
118 expect(firedOnPost, isTrue); 119 expect(firedOnPost, isTrue);
119 }); 120 });
120 }); 121 });
121 122
122 group('innerHtml', () { 123 group('innerHtml', () {
123 test('query', () { 124 test('query', () {
124 var tag = nextTag; 125 var tag = nextTag;
125 document.register(tag, CustomType); 126 document.register(tag, CustomType);
126 var element = new DivElement(); 127 var element = new DivElement();
127 element.innerHtml = '<$tag></$tag>'; 128 element.innerHtml = '<$tag></$tag>';
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 test('can invoke mixin methods', () { 164 test('can invoke mixin methods', () {
164 var tag = nextTag; 165 var tag = nextTag;
165 document.register(tag, CustomType); 166 document.register(tag, CustomType);
166 167
167 var element = new Element.tag(tag); 168 var element = new Element.tag(tag);
168 element.invokeMixinMethod(); 169 element.invokeMixinMethod();
169 expect(element.mixinMethodCalled, isTrue); 170 expect(element.mixinMethodCalled, isTrue);
170 }); 171 });
171 }); 172 });
172 } 173 }
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