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 constructor_calls_created_synchronously_test; | 5 library constructor_calls_created_synchronously_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 import '../utils.dart'; |
10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
11 | 11 |
12 class A extends HtmlElement { | 12 class A extends HtmlElement { |
13 static final tag = 'x-a'; | 13 static final tag = 'x-a'; |
14 factory A() => new Element.tag(tag); | 14 factory A() => new Element.tag(tag); |
15 A.created() : super.created() { | 15 A.created() : super.created() { |
16 ncallbacks++; | 16 ncallbacks++; |
17 } | 17 } |
18 | 18 |
19 static int ncallbacks = 0; | 19 static int ncallbacks = 0; |
20 } | 20 } |
21 | 21 |
22 main() { | 22 main() { |
23 useHtmlConfiguration(); | 23 useHtmlConfiguration(); |
24 | 24 |
25 // Adapted from Blink's | 25 // Adapted from Blink's |
26 // fast/dom/custom/constructor-calls-created-synchronously test. | 26 // fast/dom/custom/constructor-calls-created-synchronously test. |
27 | 27 |
28 var registered = false; | 28 var registered = false; |
29 setUp(() { | 29 setUp(() { |
30 return loadPolyfills().then((_) { | 30 return customElementsReady.then((_) { |
31 if (!registered) { | 31 if (!registered) { |
32 registered = true; | 32 registered = true; |
33 document.register(A.tag, A); | 33 document.register(A.tag, A); |
34 } | 34 } |
35 }); | 35 }); |
36 }); | 36 }); |
37 | 37 |
38 test('createdCallback', () { | 38 test('createdCallback', () { |
39 var x = new A(); | 39 var x = new A(); |
40 expect(A.ncallbacks, 1); | 40 expect(A.ncallbacks, 1); |
(...skipping 16 matching lines...) Expand all Loading... |
57 expect(fancy.wasCreated, true, reason: 'FancySection ctor was called'); | 57 expect(fancy.wasCreated, true, reason: 'FancySection ctor was called'); |
58 }); | 58 }); |
59 } | 59 } |
60 | 60 |
61 class FancySection extends HtmlElement { | 61 class FancySection extends HtmlElement { |
62 bool wasCreated = false; | 62 bool wasCreated = false; |
63 FancySection.created() : super.created() { | 63 FancySection.created() : super.created() { |
64 wasCreated = true; | 64 wasCreated = true; |
65 } | 65 } |
66 } | 66 } |
OLD | NEW |