| 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 import '../utils.dart'; |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // As per: | 48 // As per: |
| 49 // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-pa
rsing | 49 // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-pa
rsing |
| 50 // creation order is t, u, v, w (postorder). | 50 // creation order is t, u, v, w (postorder). |
| 51 expect(t is C, isTrue); | 51 expect(t is C, isTrue); |
| 52 // Note, this is different from JavaScript where this would be false. | 52 // Note, this is different from JavaScript where this would be false. |
| 53 expect(v is C, isTrue); | 53 expect(v is C, isTrue); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 | 56 |
| 57 loadPolyfills() { |
| 58 if (!document.supportsRegister) { |
| 59 // Cache blocker is a workaround for: |
| 60 // https://code.google.com/p/dart/issues/detail?id=11834 |
| 61 var cacheBlocker = new DateTime.now().millisecondsSinceEpoch; |
| 62 return HttpRequest.getString('/root_dart/pkg/custom_element/lib/' |
| 63 'custom-elements.debug.js?cacheBlock=$cacheBlocker').then((code) { |
| 64 document.head.children.add(new ScriptElement()..text = code); |
| 65 }); |
| 66 } |
| 67 } |
| 68 |
| 57 main() { | 69 main() { |
| 58 useHtmlConfiguration(); | 70 useHtmlConfiguration(); |
| 59 | 71 |
| 60 // Adapted from Blink's | 72 // Adapted from Blink's |
| 61 // fast/dom/custom/created-callback test. | 73 // fast/dom/custom/created-callback test. |
| 62 | 74 |
| 75 setUp(loadPolyfills); |
| 76 |
| 63 test('transfer created callback', () { | 77 test('transfer created callback', () { |
| 64 document.register(A.tag, A); | 78 document.register(A.tag, A); |
| 65 var x = new A(); | 79 var x = new A(); |
| 66 expect(A.createdInvocations, 1); | 80 expect(A.createdInvocations, 1); |
| 67 }); | 81 }); |
| 68 | 82 |
| 69 test(':unresolved and created callback timing', () { | 83 test(':unresolved and created callback timing', () { |
| 70 document.register(B.tag, B); | 84 document.register(B.tag, B); |
| 71 document.register(C.tag, C); | 85 document.register(C.tag, C); |
| 72 | 86 |
| 73 var div = new DivElement(); | 87 var div = new DivElement(); |
| 74 C.div = div; | 88 C.div = div; |
| 75 div.setInnerHtml(""" | 89 div.setInnerHtml(""" |
| 76 <x-c id="t"></x-c> | 90 <x-c id="t"></x-c> |
| 77 <x-b id="u"></x-b> | 91 <x-b id="u"></x-b> |
| 78 <x-c id="v"></x-c> | 92 <x-c id="v"></x-c> |
| 79 <x-b id="w"></x-b> | 93 <x-b id="w"></x-b> |
| 80 """, treeSanitizer: new NullTreeSanitizer()); | 94 """, treeSanitizer: new NullTreeSanitizer()); |
| 81 | 95 |
| 96 Platform.upgradeCustomElements(div); |
| 97 |
| 82 expect(C.createdInvocations, 2); | 98 expect(C.createdInvocations, 2); |
| 83 expect(div.query('#w') is B, isTrue); | 99 expect(div.query('#w') is B, isTrue); |
| 84 }); | 100 }); |
| 85 | 101 |
| 86 // TODO(vsm): Port additional test from upstream here: | 102 // TODO(vsm): Port additional test from upstream here: |
| 87 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 | 103 // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/crea
ted-callback.html?r1=156141&r2=156185 |
| 88 } | 104 } |
| OLD | NEW |