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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/html/custom/template_wrappers_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/custom/template_wrappers_test.dart
diff --git a/tests/html/custom/template_wrappers_test.dart b/tests/html/custom/template_wrappers_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8754f857e190f273759182f261d1fac50236fe0d
--- /dev/null
+++ b/tests/html/custom/template_wrappers_test.dart
@@ -0,0 +1,64 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library template_wrappers_test;
+
+import 'dart:async';
+import 'dart:html';
+import 'dart:js' as js;
+import 'package:unittest/html_config.dart';
+import 'package:unittest/unittest.dart';
+import '../utils.dart';
+
+int createdCount = 0;
+
+class CustomElement extends HtmlElement {
+ CustomElement.created() : super.created() {
+ ++createdCount;
+ }
+
+ void checkCreated() {
+ }
+}
+
+// Pump custom events polyfill events.
+void customElementsTakeRecords() {
+ if (js.context != null && js.context.hasProperty('CustomElements')) {
+ js.context['CustomElements'].callMethod('takeRecords');
+ }
+}
+
+main() {
+ useHtmlConfiguration();
+
+ var registeredTypes = false;
+ setUp(loadPolyfills);
+
+ test('element is upgraded once', () {
+
+ expect(createdCount, 0);
+ document.register('x-custom', CustomElement);
+ expect(createdCount, 1);
+
+ forceGC();
+
+ return new Future.delayed(new Duration(milliseconds: 50)).then((_) {
+ var t = document.querySelector('.t1');
+
+ var fragment = t.content;
+
+ fragment.querySelector('x-custom').checkCreated();
+ expect(createdCount, 1);
+ });
+ });
+}
+
+
+void forceGC() {
+ var N = 1000000;
+ var M = 1000;
+ for (var i = 0; i < M; ++i) {
+ var l = new List(N);
+ }
+}
« 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