| 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 created_callback_test; | 5 library created_callback_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 A extends HtmlElement { | 11 class A extends HtmlElement { |
| 11 static final tag = 'x-a'; | 12 static final tag = 'x-a'; |
| 12 factory A() => new Element.tag(tag); | 13 factory A() => new Element.tag(tag); |
| 13 | 14 |
| 14 static int createdInvocations = 0; | 15 static int createdInvocations = 0; |
| 15 | 16 |
| 16 void created() { | 17 void created() { |
| 17 createdInvocations++; | 18 createdInvocations++; |
| 18 } | 19 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 var x = new A(); | 65 var x = new A(); |
| 65 expect(A.createdInvocations, 1); | 66 expect(A.createdInvocations, 1); |
| 66 }); | 67 }); |
| 67 | 68 |
| 68 test(':unresolved and created callback timing', () { | 69 test(':unresolved and created callback timing', () { |
| 69 document.register(B.tag, B); | 70 document.register(B.tag, B); |
| 70 document.register(C.tag, C); | 71 document.register(C.tag, C); |
| 71 | 72 |
| 72 var div = new DivElement(); | 73 var div = new DivElement(); |
| 73 C.div = div; | 74 C.div = div; |
| 74 div.innerHtml = """ | 75 div.setInnerHtml(""" |
| 75 <x-c id="t"></x-c> | 76 <x-c id="t"></x-c> |
| 76 <x-b id="u"></x-b> | 77 <x-b id="u"></x-b> |
| 77 <x-c id="v"></x-c> | 78 <x-c id="v"></x-c> |
| 78 <x-b id="w"></x-b> | 79 <x-b id="w"></x-b> |
| 79 """; | 80 """, treeSanitizer: new NullTreeSanitizer()); |
| 80 | 81 |
| 81 expect(C.createdInvocations, 2); | 82 expect(C.createdInvocations, 2); |
| 82 expect(div.query('#w') is B, isTrue); | 83 expect(div.query('#w') is B, isTrue); |
| 83 }); | 84 }); |
| 84 | 85 |
| 85 // TODO(vsm): Port additional test from upstream here: | 86 // TODO(vsm): Port additional test from upstream here: |
| 86 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 | 87 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 |
| 87 } | 88 } |
| OLD | NEW |