| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library template_wrappers_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:html'; |
| 9 import 'dart:js' as js; |
| 10 import 'package:unittest/html_config.dart'; |
| 11 import 'package:unittest/unittest.dart'; |
| 12 import '../utils.dart'; |
| 13 |
| 14 int createdCount = 0; |
| 15 |
| 16 class CustomElement extends HtmlElement { |
| 17 CustomElement.created() : super.created() { |
| 18 ++createdCount; |
| 19 } |
| 20 |
| 21 void checkCreated() { |
| 22 } |
| 23 } |
| 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() { |
| 33 useHtmlConfiguration(); |
| 34 |
| 35 var registeredTypes = false; |
| 36 setUp(loadPolyfills); |
| 37 |
| 38 test('element is upgraded once', () { |
| 39 |
| 40 expect(createdCount, 0); |
| 41 document.register('x-custom', CustomElement); |
| 42 expect(createdCount, 1); |
| 43 |
| 44 forceGC(); |
| 45 |
| 46 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { |
| 47 var t = document.querySelector('.t1'); |
| 48 |
| 49 var fragment = t.content; |
| 50 |
| 51 fragment.querySelector('x-custom').checkCreated(); |
| 52 expect(createdCount, 1); |
| 53 }); |
| 54 }); |
| 55 } |
| 56 |
| 57 |
| 58 void forceGC() { |
| 59 var N = 1000000; |
| 60 var M = 1000; |
| 61 for (var i = 0; i < M; ++i) { |
| 62 var l = new List(N); |
| 63 } |
| 64 } |
| OLD | NEW |