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

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

Issue 16374007: First rev of Safe DOM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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) 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 'dart:async'; 6 import 'dart:async';
7 import 'dart:html'; 7 import 'dart:html';
8 import 'package:unittest/html_individual_config.dart'; 8 import 'package:unittest/html_individual_config.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'utils.dart';
10 11
11 class CustomMixin { 12 class CustomMixin {
12 var mixinMethodCalled; 13 var mixinMethodCalled;
13 14
14 void mixinMethod() { 15 void mixinMethod() {
15 mixinMethodCalled = true; 16 mixinMethodCalled = true;
16 } 17 }
17 } 18 }
18 19
19 class CustomType extends HtmlElement with CustomMixin{ 20 class CustomType extends HtmlElement with CustomMixin{
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 expect(firedOnPre, isTrue); 138 expect(firedOnPre, isTrue);
138 expect(firedOnPost, isTrue); 139 expect(firedOnPost, isTrue);
139 }); 140 });
140 });*/ 141 });*/
141 142
142 group('innerHtml', () { 143 group('innerHtml', () {
143 test('query', () { 144 test('query', () {
144 var tag = nextTag; 145 var tag = nextTag;
145 document.register(tag, CustomType); 146 document.register(tag, CustomType);
146 var element = new DivElement(); 147 var element = new DivElement();
147 element.innerHtml = '<$tag></$tag>'; 148 element.setInnerHtml('<$tag></$tag>',
149 treeSanitizer: new NullTreeSanitizer());
150 » Platform.upgradeCustomElements(element);
148 document.body.nodes.add(element); 151 document.body.nodes.add(element);
149 var queried = query(tag); 152 var queried = query(tag);
150 153
151 expect(queried, isNotNull); 154 expect(queried, isNotNull);
152 expect(queried is CustomType, isTrue); 155 expect(queried is CustomType, isTrue);
153 expect(queried.onCreatedCalled, isTrue); 156 expect(queried.onCreatedCalled, isTrue);
154 }); 157 });
155 158
156 test('query id', () { 159 test('query id', () {
157 var tag = nextTag; 160 var tag = nextTag;
158 document.register(tag, CustomType); 161 document.register(tag, CustomType);
159 var element = new DivElement(); 162 var element = new DivElement();
160 element.innerHtml = '<$tag id="someid"></$tag>'; 163 element.setInnerHtml('<$tag id="someid"></$tag>',
164 treeSanitizer: new NullTreeSanitizer());
165 » Platform.upgradeCustomElements(element);
161 document.body.nodes.add(element); 166 document.body.nodes.add(element);
162 var queried = query('#someid'); 167 var queried = query('#someid');
163 168
164 expect(queried, isNotNull); 169 expect(queried, isNotNull);
165 expect(queried is CustomType, isTrue); 170 expect(queried is CustomType, isTrue);
166 expect(queried.id, "someid"); 171 expect(queried.id, "someid");
167 }); 172 });
168 }); 173 });
169 174
170 group('lifecycle', () { 175 group('lifecycle', () {
171 test('onCreated', () { 176 test('onCreated', () {
172 int oldCount = customCreatedCount; 177 int oldCount = customCreatedCount;
173 var tag = nextTag; 178 var tag = nextTag;
174 document.register(tag, CustomType); 179 document.register(tag, CustomType);
175 var element = new DivElement(); 180 var element = new DivElement();
176 element.innerHtml = '<$tag></$tag>'; 181 element.setInnerHtml('<$tag></$tag>',
182 treeSanitizer: new NullTreeSanitizer());
177 Platform.upgradeCustomElements(element); 183 Platform.upgradeCustomElements(element);
178 document.body.nodes.add(element); 184 document.body.nodes.add(element);
179 expect(customCreatedCount, oldCount + 1); 185 expect(customCreatedCount, oldCount + 1);
180 }); 186 });
181 }); 187 });
182 188
183 group('mixins', () { 189 group('mixins', () {
184 test('can invoke mixin methods', () { 190 test('can invoke mixin methods', () {
185 var tag = nextTag; 191 var tag = nextTag;
186 document.register(tag, CustomType); 192 document.register(tag, CustomType);
187 193
188 var element = new Element.tag(tag); 194 var element = new Element.tag(tag);
189 element.invokeMixinMethod(); 195 element.invokeMixinMethod();
190 expect(element.mixinMethodCalled, isTrue); 196 expect(element.mixinMethodCalled, isTrue);
191 }); 197 });
192 }); 198 });
193 } 199 }
OLDNEW
« no previous file with comments | « tests/html/custom/document_register_type_extensions_test.dart ('k') | tests/html/custom_tags_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698