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

Side by Side Diff: tests/html/custom/document_register_basic_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 document_register_basic_test; 5 library document_register_basic_test;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart'; 7 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'utils.dart';
9 10
10 class Foo extends HtmlElement { 11 class Foo extends HtmlElement {
11 static final tag = 'x-foo'; 12 static final tag = 'x-foo';
12 factory Foo() => new Element.tag(tag); 13 factory Foo() => new Element.tag(tag);
13 14
14 get thisIsACustomClass => true; 15 get thisIsACustomClass => true;
15 } 16 }
16 17
17 class Bar extends HtmlElement { 18 class Bar extends HtmlElement {
18 static final tag = 'x-bar'; 19 static final tag = 'x-bar';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 expect(createdFoo.text, "Hello"); 77 expect(createdFoo.text, "Hello");
77 78
78 // Native method 79 // Native method
79 var childDiv = new DivElement(); 80 var childDiv = new DivElement();
80 createdFoo.append(childDiv); 81 createdFoo.append(childDiv);
81 expect(createdFoo.lastChild, childDiv); 82 expect(createdFoo.lastChild, childDiv);
82 83
83 // Parser initiated instantiation 84 // Parser initiated instantiation
84 var container = new DivElement()..id = "container"; 85 var container = new DivElement()..id = "container";
85 document.body.append(container); 86 document.body.append(container);
86 container.innerHtml = "<x-foo></x-foo>"; 87 container.setInnerHtml("<x-foo></x-foo>",
88 treeSanitizer: new NullTreeSanitizer());
87 var parsedFoo = container.firstChild; 89 var parsedFoo = container.firstChild;
88 90
89 expect(parsedFoo is Foo, isTrue); 91 expect(parsedFoo is Foo, isTrue);
90 expect(parsedFoo.tagName, "X-FOO"); 92 expect(parsedFoo.tagName, "X-FOO");
91 93
92 // Ensuring the wrapper is retained 94 // Ensuring the wrapper is retained
93 var someProperty = new Expando(); 95 var someProperty = new Expando();
94 someProperty[parsedFoo] = "hello"; 96 someProperty[parsedFoo] = "hello";
95 expect(container.firstChild, parsedFoo); 97 expect(container.firstChild, parsedFoo);
96 expect(someProperty[container.firstChild], someProperty[parsedFoo]); 98 expect(someProperty[container.firstChild], someProperty[parsedFoo]);
(...skipping 13 matching lines...) Expand all
110 expect(createdBaz.thisIsAlsoACustomClass, isTrue); 112 expect(createdBaz.thisIsAlsoACustomClass, isTrue);
111 113
112 // With irregular cases 114 // With irregular cases
113 var createdUpperBar = new Element.tag("X-BAR"); 115 var createdUpperBar = new Element.tag("X-BAR");
114 var createdMixedBar = new Element.tag("X-Bar"); 116 var createdMixedBar = new Element.tag("X-Bar");
115 expect(createdUpperBar is Bar, isTrue); 117 expect(createdUpperBar is Bar, isTrue);
116 expect(createdUpperBar.tagName, "X-BAR"); 118 expect(createdUpperBar.tagName, "X-BAR");
117 expect(createdMixedBar is Bar, isTrue); 119 expect(createdMixedBar is Bar, isTrue);
118 expect(createdMixedBar.tagName, "X-BAR"); 120 expect(createdMixedBar.tagName, "X-BAR");
119 121
120 container.innerHtml = "<X-BAR></X-BAR><X-Bar></X-Bar>"; 122 container.setInnerHtml("<X-BAR></X-BAR><X-Bar></X-Bar>",
123 treeSanitizer: new NullTreeSanitizer());
121 expect(container.firstChild is Bar, isTrue); 124 expect(container.firstChild is Bar, isTrue);
122 expect(container.firstChild.tagName, "X-BAR"); 125 expect(container.firstChild.tagName, "X-BAR");
123 expect(container.lastChild is Bar, isTrue); 126 expect(container.lastChild is Bar, isTrue);
124 expect(container.lastChild.tagName, "X-BAR"); 127 expect(container.lastChild.tagName, "X-BAR");
125 128
126 // Constructors shouldn't interfere with each other 129 // Constructors shouldn't interfere with each other
127 expect((new Foo()).tagName, "X-FOO"); 130 expect((new Foo()).tagName, "X-FOO");
128 expect((new Bar()).tagName, "X-BAR"); 131 expect((new Bar()).tagName, "X-BAR");
129 expect((new Baz()).tagName, "X-BAZ"); 132 expect((new Baz()).tagName, "X-BAZ");
130 }); 133 });
131 } 134 }
OLDNEW
« no previous file with comments | « tests/html/cssstyledeclaration_test.dart ('k') | tests/html/custom/document_register_type_extensions_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698