OLD | NEW |
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; | |
6 import 'package:unittest/unittest.dart'; | |
7 import 'package:unittest/html_config.dart'; | |
8 import 'dart:html'; | 5 import 'dart:html'; |
| 6 |
| 7 import 'package:expect/minitest.dart'; |
| 8 |
9 import '../utils.dart'; | 9 import '../utils.dart'; |
10 | 10 |
11 class Foo extends HtmlElement { | 11 class Foo extends HtmlElement { |
12 static final tag = 'x-foo'; | 12 static final tag = 'x-foo'; |
13 factory Foo() => new Element.tag(tag); | 13 factory Foo() => new Element.tag(tag); |
14 Foo.created() : super.created(); | 14 Foo.created() : super.created(); |
15 | 15 |
16 get thisIsACustomClass => true; | 16 get thisIsACustomClass => true; |
17 } | 17 } |
18 | 18 |
(...skipping 19 matching lines...) Expand all Loading... |
38 abstract class BadC extends HtmlElement { | 38 abstract class BadC extends HtmlElement { |
39 BadC.created() : super.created(); | 39 BadC.created() : super.created(); |
40 } | 40 } |
41 | 41 |
42 class BadF implements HtmlElement { | 42 class BadF implements HtmlElement { |
43 static final tag = 'x-tag-f'; | 43 static final tag = 'x-tag-f'; |
44 factory BadF() => new Element.tag(tag); | 44 factory BadF() => new Element.tag(tag); |
45 } | 45 } |
46 | 46 |
47 main() { | 47 main() { |
48 useHtmlConfiguration(); | |
49 | |
50 // Adapted from Blink's fast/dom/custom/document-register-basic test. | 48 // Adapted from Blink's fast/dom/custom/document-register-basic test. |
51 | 49 |
52 setUp(() => customElementsReady); | 50 setUp(() => customElementsReady); |
53 | 51 |
54 test('Testing document.registerElement() basic behaviors', () { | 52 test('Testing document.registerElement() basic behaviors', () { |
55 document.registerElement(Foo.tag, Foo); | 53 document.registerElement(Foo.tag, Foo); |
56 | 54 |
57 // Cannot register an existing dart:html type. | 55 // Cannot register an existing dart:html type. |
58 expect(() => document.registerElement('x-bad-a', HtmlElement), throws); | 56 expect(() => document.registerElement('x-bad-a', HtmlElement), throws); |
59 | 57 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 expect(container.firstChild.tagName, "X-BAR"); | 137 expect(container.firstChild.tagName, "X-BAR"); |
140 expect(container.lastChild is Bar, isTrue); | 138 expect(container.lastChild is Bar, isTrue); |
141 expect(container.lastChild.tagName, "X-BAR"); | 139 expect(container.lastChild.tagName, "X-BAR"); |
142 | 140 |
143 // Constructors shouldn't interfere with each other | 141 // Constructors shouldn't interfere with each other |
144 expect((new Foo()).tagName, "X-FOO"); | 142 expect((new Foo()).tagName, "X-FOO"); |
145 expect((new Bar()).tagName, "X-BAR"); | 143 expect((new Bar()).tagName, "X-BAR"); |
146 expect((new Baz()).tagName, "X-BAZ"); | 144 expect((new Baz()).tagName, "X-BAZ"); |
147 }); | 145 }); |
148 } | 146 } |
OLD | NEW |