Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: tests/html/custom/template_wrappers_test.dart

Issue 55153002: Adding test for old wrappers causing multiple upgrades (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/html/custom/template_wrappers_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 // Pump custom events polyfill events. 25 // Pump custom events polyfill events.
26 void customElementsTakeRecords() { 26 void customElementsTakeRecords() {
27 if (js.context != null && js.context.hasProperty('CustomElements')) { 27 if (js.context != null && js.context.hasProperty('CustomElements')) {
28 js.context['CustomElements'].callMethod('takeRecords'); 28 js.context['CustomElements'].callMethod('takeRecords');
29 } 29 }
30 } 30 }
31 31
32 main() { 32 main() {
33 useHtmlConfiguration(); 33 useHtmlConfiguration();
34 34
35 var registeredTypes = false;
36 setUp(loadPolyfills); 35 setUp(loadPolyfills);
37 36
38 test('element is upgraded once', () { 37 test('element is upgraded once', () {
39 38
40 expect(createdCount, 0); 39 expect(createdCount, 0);
41 document.register('x-custom', CustomElement); 40 document.register('x-custom', CustomElement);
42 expect(createdCount, 1); 41 expect(createdCount, 1);
43 42
44 forceGC(); 43 forceGC();
45 44
46 return new Future.delayed(new Duration(milliseconds: 50)).then((_) { 45 return new Future.delayed(new Duration(milliseconds: 50)).then((_) {
47 var t = document.querySelector('.t1'); 46 var t = document.querySelector('.t1');
48 47
49 var fragment = t.content; 48 var fragment = t.content;
50 49
51 fragment.querySelector('x-custom').checkCreated(); 50 fragment.querySelector('x-custom').checkCreated();
52 expect(createdCount, 1); 51 expect(createdCount, 1);
53 }); 52 });
54 }); 53 });
54
55 test('old wrappers do not cause multiple upgrades', () {
56 createdCount = 0;
57 var d1 = document.querySelector('x-custom-two');
58 d1.attributes['foo'] = 'bar';
59 d1 = null;
60
61 document.register('x-custom-two', CustomElement);
62
63 expect(createdCount, 1);
64
65 forceGC();
66
67 return new Future.delayed(new Duration(milliseconds: 50)).then((_) {
68 var d = document.querySelector('x-custom-two');
69 expect(createdCount, 1);
70 });
71 });
55 } 72 }
56 73
57 74
58 void forceGC() { 75 void forceGC() {
59 var N = 1000000; 76 var N = 1000000;
60 var M = 1000; 77 var M = 100;
blois 2013/10/31 18:43:13 Bumping down to 100 makes this quite a bit faster
siva 2013/10/31 19:49:05 This seems like a very contrived way to trigger a
61 for (var i = 0; i < M; ++i) { 78 for (var i = 0; i < M; ++i) {
62 var l = new List(N); 79 var l = new List(N);
63 } 80 }
64 } 81 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/custom/template_wrappers_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698