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 entered_left_view_test; | 5 library entered_left_view_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'dart:js' as js; | 9 import 'dart:js' as js; |
10 import 'package:unittest/html_individual_config.dart'; | 10 import 'package:unittest/html_individual_config.dart'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 void leftView() { | 25 void leftView() { |
26 invocations.add('left'); | 26 invocations.add('left'); |
27 } | 27 } |
28 | 28 |
29 void attributeChanged(String name, String oldValue, String newValue) { | 29 void attributeChanged(String name, String oldValue, String newValue) { |
30 invocations.add('attribute changed'); | 30 invocations.add('attribute changed'); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
34 // Pump custom events polyfill events. | |
35 void customElementsTakeRecords() { | |
36 if (js.context.hasProperty('CustomElements')) { | |
37 js.context['CustomElements'].callMethod('takeRecords'); | |
38 } | |
39 } | |
40 | |
41 main() { | 34 main() { |
42 useHtmlIndividualConfiguration(); | 35 useHtmlIndividualConfiguration(); |
43 | 36 |
44 // Adapted from Blink's | 37 // Adapted from Blink's |
45 // fast/dom/custom/entered-left-document.html test. | 38 // fast/dom/custom/entered-left-document.html test. |
46 | 39 |
47 var docA = document; | 40 var docA = document; |
48 var docB = document.implementation.createHtmlDocument(''); | 41 var docB = document.implementation.createHtmlDocument(''); |
49 | 42 |
50 var nullSanitizer = new NullTreeSanitizer(); | 43 var nullSanitizer = new NullTreeSanitizer(); |
51 | 44 |
52 var registeredTypes = false; | 45 var registeredTypes = false; |
53 setUp(() { | 46 setUp(() => customElementsReady.then((_) { |
54 return loadPolyfills().then((_) { | 47 if (registeredTypes) return; |
55 if (registeredTypes) { | 48 registeredTypes = true; |
56 return; | 49 document.register('x-a', Foo); |
57 } | 50 })); |
58 registeredTypes = true; | |
59 document.register('x-a', Foo); | |
60 }); | |
61 }); | |
62 | 51 |
63 group('standard_events', () { | 52 group('standard_events', () { |
64 var a; | 53 var a; |
65 setUp(() { | 54 setUp(() { |
66 invocations = []; | 55 invocations = []; |
67 }); | 56 }); |
68 | 57 |
69 test('Created', () { | 58 test('Created', () { |
70 a = new Element.tag('x-a'); | 59 a = new Element.tag('x-a'); |
71 expect(invocations, ['created']); | 60 expect(invocations, ['created']); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 upgradeCustomElements(div); | 224 upgradeCustomElements(div); |
236 invocations = []; | 225 invocations = []; |
237 document.body.append(div); | 226 document.body.append(div); |
238 customElementsTakeRecords(); | 227 customElementsTakeRecords(); |
239 expect(invocations, ['entered'], | 228 expect(invocations, ['entered'], |
240 reason: 'the entered callback should be invoked when inserted into a ' | 229 reason: 'the entered callback should be invoked when inserted into a ' |
241 'document with a view as part of a subtree'); | 230 'document with a view as part of a subtree'); |
242 }); | 231 }); |
243 }); | 232 }); |
244 } | 233 } |
OLD | NEW |