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