OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 register_element_proxy_test; | 5 library register_element_proxy_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:js' as js; | 9 import 'dart:js' as js; |
10 import 'package:unittest/html_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
(...skipping 22 matching lines...) Expand all Loading... |
33 var registered = false; | 33 var registered = false; |
34 var upgrader; | 34 var upgrader; |
35 setUp(() => customElementsReady.then((_) { | 35 setUp(() => customElementsReady.then((_) { |
36 if (!registered) { | 36 if (!registered) { |
37 registered = true; | 37 registered = true; |
38 upgrader = document.createElementUpgrader(FooElement); | 38 upgrader = document.createElementUpgrader(FooElement); |
39 js.context['upgradeListener'] = (e) { | 39 js.context['upgradeListener'] = (e) { |
40 upgrader.upgrade(e); | 40 upgrader.upgrade(e); |
41 }; | 41 }; |
42 | 42 |
43 document.register('custom-element', CustomElement); | 43 document.registerElement('custom-element', CustomElement); |
44 } | 44 } |
45 })); | 45 })); |
46 | 46 |
47 test('created gets proxied', () { | 47 test('created gets proxied', () { |
48 var element = document.createElement(FooElement.tag); | 48 var element = document.createElement(FooElement.tag); |
49 expect(element is FooElement, isTrue); | 49 expect(element is FooElement, isTrue); |
50 expect(element.initializedField, 666); | 50 expect(element.initializedField, 666); |
51 expect(element.text, 'constructed'); | 51 expect(element.text, 'constructed'); |
52 | 52 |
53 js.context.callMethod('validateIsFoo', [element]); | 53 js.context.callMethod('validateIsFoo', [element]); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 class CustomDiv extends DivElement { | 125 class CustomDiv extends DivElement { |
126 CustomDiv.created() : super.created(); | 126 CustomDiv.created() : super.created(); |
127 } | 127 } |
128 | 128 |
129 class CustomElement extends HtmlElement { | 129 class CustomElement extends HtmlElement { |
130 factory CustomElement() => document.createElement('custom-element'); | 130 factory CustomElement() => document.createElement('custom-element'); |
131 CustomElement.created() : super.created(); | 131 CustomElement.created() : super.created(); |
132 } | 132 } |
OLD | NEW |