| 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'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 import '../utils.dart'; | 12 import '../utils.dart'; |
| 13 | 13 |
| 14 int createdCount = 0; | 14 int createdCount = 0; |
| 15 | 15 |
| 16 class CustomElement extends HtmlElement { | 16 class CustomElement extends HtmlElement { |
| 17 CustomElement.created() : super.created() { | 17 CustomElement.created() : super.created() { |
| 18 ++createdCount; | 18 ++createdCount; |
| 19 } | 19 } |
| 20 | 20 |
| 21 void checkCreated() { | 21 void checkCreated() { |
| 22 } | 22 } |
| 23 } | 23 } |
| 24 | 24 |
| 25 // Pump custom events polyfill events. | |
| 26 void customElementsTakeRecords() { | |
| 27 if (js.context != null && js.context.hasProperty('CustomElements')) { | |
| 28 js.context['CustomElements'].callMethod('takeRecords'); | |
| 29 } | |
| 30 } | |
| 31 | |
| 32 main() { | 25 main() { |
| 33 useHtmlConfiguration(); | 26 useHtmlConfiguration(); |
| 34 | 27 |
| 35 setUp(loadPolyfills); | 28 setUp(customElementsReady); |
| 36 | 29 |
| 37 test('element is upgraded once', () { | 30 test('element is upgraded once', () { |
| 38 | 31 |
| 39 expect(createdCount, 0); | 32 expect(createdCount, 0); |
| 40 document.register('x-custom', CustomElement); | 33 document.register('x-custom', CustomElement); |
| 41 expect(createdCount, 1); | 34 expect(createdCount, 1); |
| 42 | 35 |
| 43 forceGC(); | 36 forceGC(); |
| 44 | 37 |
| 45 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { | 38 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 73 } | 66 } |
| 74 | 67 |
| 75 | 68 |
| 76 void forceGC() { | 69 void forceGC() { |
| 77 var N = 1000000; | 70 var N = 1000000; |
| 78 var M = 100; | 71 var M = 100; |
| 79 for (var i = 0; i < M; ++i) { | 72 for (var i = 0; i < M; ++i) { |
| 80 var l = new List(N); | 73 var l = new List(N); |
| 81 } | 74 } |
| 82 } | 75 } |
| OLD | NEW |