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

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

Issue 49673003: Tests for premature GC of custom elements within template contents (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
(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 }
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