| 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 | 16 |
| 17 static int ncallbacks = 0; | 17 static int ncallbacks = 0; |
| 18 | 18 |
| 19 void createdCallback() { | 19 void createdCallback() { |
| 20 ncallbacks++; | 20 ncallbacks++; |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 main() { | 24 main() { |
| 25 useHtmlConfiguration(); | 25 useHtmlConfiguration(); |
| 26 | 26 |
| 27 // Adapted from Blink's | 27 // Adapted from Blink's |
| 28 // fast/dom/custom/constructor-calls-created-synchronously test. | 28 // fast/dom/custom/constructor-calls-created-synchronously test. |
| 29 | 29 |
| 30 setUp(loadPolyfills); | 30 var registered = false; |
| 31 setUp(() { |
| 32 return loadPolyfills().then((_) { |
| 33 if (!registered) { |
| 34 registered = true; |
| 35 document.register(A.tag, A); |
| 36 } |
| 37 }); |
| 38 }); |
| 31 | 39 |
| 32 test('createdCallback', () { | 40 test('createdCallback', () { |
| 33 document.register(A.tag, A); | |
| 34 var x = new A(); | 41 var x = new A(); |
| 35 expect(A.ncallbacks, 1); | 42 expect(A.ncallbacks, 1); |
| 36 }); | 43 }); |
| 44 |
| 45 test('clone node', () { |
| 46 A.ncallbacks = 0; |
| 47 |
| 48 var a = new A(); |
| 49 expect(A.ncallbacks, 1); |
| 50 var b = a.clone(false); |
| 51 expect(A.ncallbacks, 2); |
| 52 expect(b is A, isTrue); |
| 53 }); |
| 37 } | 54 } |
| OLD | NEW |