| 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 | 9 |
| 10 class A extends HtmlElement { | 10 class A extends HtmlElement { |
| 11 static final tag = 'x-a'; | 11 static final tag = 'x-a'; |
| 12 factory A() => new Element.tag(tag); | 12 factory A() => new Element.tag(tag); |
| 13 | 13 |
| 14 static int createdInvocations = 0; | 14 static int createdInvocations = 0; |
| 15 | 15 |
| 16 void onCreated() { | 16 void created() { |
| 17 createdInvocations++; | 17 createdInvocations++; |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 class B extends HtmlElement { | 21 class B extends HtmlElement { |
| 22 static final tag = 'x-b'; | 22 static final tag = 'x-b'; |
| 23 factory B() => new Element.tag(tag); | 23 factory B() => new Element.tag(tag); |
| 24 } | 24 } |
| 25 | 25 |
| 26 class C extends HtmlElement { | 26 class C extends HtmlElement { |
| 27 static final tag = 'x-c'; | 27 static final tag = 'x-c'; |
| 28 factory C() => new Element.tag(tag); | 28 factory C() => new Element.tag(tag); |
| 29 | 29 |
| 30 static int createdInvocations = 0; | 30 static int createdInvocations = 0; |
| 31 static var div; | 31 static var div; |
| 32 | 32 |
| 33 void onCreated() { | 33 void created() { |
| 34 createdInvocations++; | 34 createdInvocations++; |
| 35 | 35 |
| 36 if (this.id != 'u') { | 36 if (this.id != 'u') { |
| 37 return; | 37 return; |
| 38 } | 38 } |
| 39 | 39 |
| 40 var t = div.query('#t'); | 40 var t = div.query('#t'); |
| 41 var v = div.query('#v'); | 41 var v = div.query('#v'); |
| 42 var w = div.query('#w'); | 42 var w = div.query('#w'); |
| 43 | 43 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 <x-b id="w"></x-b> | 78 <x-b id="w"></x-b> |
| 79 """; | 79 """; |
| 80 | 80 |
| 81 expect(C.createdInvocations, 2); | 81 expect(C.createdInvocations, 2); |
| 82 expect(div.query('#w') is B, isTrue); | 82 expect(div.query('#w') is B, isTrue); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 // TODO(vsm): Port additional test from upstream here: | 85 // 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 | 86 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 |
| 87 } | 87 } |
| OLD | NEW |