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

Unified Diff: tests/html/custom/created_callback_test.dart

Issue 23232005: Port custom element layout tests to Dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix dart2js and status Created 7 years, 4 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
Index: tests/html/custom/created_callback_test.dart
diff --git a/tests/html/custom/created_callback_test.dart b/tests/html/custom/created_callback_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2f3cd51872cff72e7be6ffd609deecd1c699b95c
--- /dev/null
+++ b/tests/html/custom/created_callback_test.dart
@@ -0,0 +1,87 @@
+// 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 created_callback_test;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:html';
+
+class A extends HtmlElement {
+ static final tag = 'x-a';
+ factory A() => new Element.tag(tag);
+
+ static int createdInvocations = 0;
+
+ void onCreated() {
+ createdInvocations++;
+ }
+}
+
+class B extends HtmlElement {
+ static final tag = 'x-b';
+ factory B() => new Element.tag(tag);
+}
+
+class C extends HtmlElement {
+ static final tag = 'x-c';
+ factory C() => new Element.tag(tag);
+
+ static int createdInvocations = 0;
+ static var div;
+
+ void onCreated() {
+ createdInvocations++;
+
+ if (this.id != 'u') {
+ return;
+ }
+
+ var t = div.query('#t');
+ var v = div.query('#v');
+ var w = div.query('#w');
+
+ expect(query('x-b:not(:unresolved)'), this);
+ expect(queryAll(':unresolved'), [v, w]);
+
+ // As per:
+ // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-parsing
+ // creation order is t, u, v, w (postorder).
+ expect(t is C, isTrue);
+ // Note, this is different from JavaScript where this would be false.
+ expect(v is C, isTrue);
+ }
+}
+
+main() {
+ useHtmlConfiguration();
+
+ // Adapted from Blink's
+ // fast/dom/custom/created-callback test.
+
+ test('transfer created callback', () {
+ document.register(A.tag, A);
+ var x = new A();
+ expect(A.createdInvocations, 1);
+ });
+
+ test(':unresolved and created callback timing', () {
+ document.register(B.tag, B);
+ document.register(C.tag, C);
+
+ var div = new DivElement();
+ C.div = div;
+ div.innerHtml = """
+<x-c id="t"></x-c>
+<x-b id="u"></x-b>
+<x-c id="v"></x-c>
+<x-b id="w"></x-b>
+""";
+
+ expect(C.createdInvocations, 2);
+ expect(div.query('#w') is B, isTrue);
+ });
+
+ // TODO(vsm): Port additional test from upstream here:
+ // http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/dom/custom/created-callback.html?r1=156141&r2=156185
+}

Powered by Google App Engine
This is Rietveld 408576698