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 template_wrappers_test; | 5 library template_wrappers_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_config.dart'; | 10 import 'package:unittest/html_config.dart'; |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 main() { | 25 main() { |
26 useHtmlConfiguration(); | 26 useHtmlConfiguration(); |
27 | 27 |
28 setUp(() => customElementsReady); | 28 setUp(() => customElementsReady); |
29 | 29 |
30 test('element is upgraded once', () { | 30 test('element is upgraded once', () { |
31 | 31 |
32 expect(createdCount, 0); | 32 expect(createdCount, 0); |
33 document.register('x-custom', CustomElement); | 33 document.registerElement('x-custom', CustomElement); |
34 expect(createdCount, 0); | 34 expect(createdCount, 0); |
35 | 35 |
36 var element = document.createElement('x-custom'); | 36 var element = document.createElement('x-custom'); |
37 expect(createdCount, 1); | 37 expect(createdCount, 1); |
38 | 38 |
39 forceGC(); | 39 forceGC(); |
40 | 40 |
41 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { | 41 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { |
42 var t = document.querySelector('.t1'); | 42 var t = document.querySelector('.t1'); |
43 | 43 |
44 var fragment = t.content; | 44 var fragment = t.content; |
45 | 45 |
46 fragment.querySelector('x-custom').attributes['foo'] = 'true'; | 46 fragment.querySelector('x-custom').attributes['foo'] = 'true'; |
47 expect(createdCount, 1); | 47 expect(createdCount, 1); |
48 }); | 48 }); |
49 }); | 49 }); |
50 /* | 50 /* |
51 test('old wrappers do not cause multiple upgrades', () { | 51 test('old wrappers do not cause multiple upgrades', () { |
52 createdCount = 0; | 52 createdCount = 0; |
53 var d1 = document.querySelector('x-custom-two'); | 53 var d1 = document.querySelector('x-custom-two'); |
54 d1.attributes['foo'] = 'bar'; | 54 d1.attributes['foo'] = 'bar'; |
55 d1 = null; | 55 d1 = null; |
56 | 56 |
57 document.register('x-custom-two', CustomElement); | 57 document.registerElement('x-custom-two', CustomElement); |
58 | 58 |
59 expect(createdCount, 1); | 59 expect(createdCount, 1); |
60 | 60 |
61 forceGC(); | 61 forceGC(); |
62 | 62 |
63 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { | 63 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { |
64 var d = document.querySelector('x-custom-two'); | 64 var d = document.querySelector('x-custom-two'); |
65 expect(createdCount, 1); | 65 expect(createdCount, 1); |
66 }); | 66 }); |
67 }); | 67 }); |
68 */ | 68 */ |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 void forceGC() { | 72 void forceGC() { |
73 var N = 1000000; | 73 var N = 1000000; |
74 var M = 100; | 74 var M = 100; |
75 for (var i = 0; i < M; ++i) { | 75 for (var i = 0; i < M; ++i) { |
76 var l = new List(N); | 76 var l = new List(N); |
77 } | 77 } |
78 } | 78 } |
OLD | NEW |