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

Side by Side Diff: tests/html/custom_element_created_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: 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 unified diff | Download patch | Annotate | Revision Log
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 custom_element_created_test;
6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html';
9
10 class CustomA extends HtmlElement {
11 static final tag = 'x-a';
12 factory CustomA() => new Element.tag(tag);
13
14 static int createdInvocations = 0;
15
16 void onCreated() {
17 createdInvocations++;
18 }
19 }
20
21 class CustomB extends HtmlElement {
22 static final tag = 'x-b';
23 factory CustomB() => new Element.tag(tag);
24 }
25
26 class CustomC extends HtmlElement {
27 static final tag = 'x-c';
28 factory CustomC() => new Element.tag(tag);
29
30 static int createdInvocations = 0;
31 static var div;
32
33 void onCreated() {
34 createdInvocations++;
35
36 if (this.id != 'v') {
37 return;
38 }
39
40 var t = div.query('#t');
41 var u = div.query('#u');
42 var w = div.query('#w');
43
44 expect(query('x-c:not(:unresolved)'), this);
dominicc (has gone to gerrit) 2013/08/17 00:45:56 FYI this test changed in r156141. Upgrade happens
vsm 2013/08/19 17:00:10 Thanks for the catch! On 2013/08/17 00:45:56, dom
45 expect(queryAll(':unresolved'), [t, u]);
46
47 // Note, this is different from JavaScript where both would be false.
48 // As per:
49 // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-pa rsing
50 // creation order is w, v, u, t.
51 expect(t is CustomC, isTrue);
52 expect(u is CustomB, isTrue);
53 }
54 }
55
56 main() {
57 useHtmlIndividualConfiguration();
blois 2013/08/16 23:37:48 I wouldn't use the individual config unless we exp
vsm 2013/08/19 17:00:10 I've refactored all the tests to: (a) go under htm
58
59 // Adapted from Blink's
60 // fast/dom/custom/created-callback test.
61 group('callback', () {
62 test('transfer created callback', () {
63 document.register(CustomA.tag, CustomA);
64 var x = new CustomA();
65 expect(CustomA.createdInvocations, 1);
66 });
67
68 test(':unresolved and created callback timing', () {
69 document.register(CustomB.tag, CustomB);
70 document.register(CustomC.tag, CustomC);
71
72 var div = new DivElement();
73 CustomC.div = div;
74 div.innerHtml = """
75 <x-c id="t"></x-c>
76 <x-b id="u"></x-b>
77 <x-c id="v"></x-c>
78 <x-b id="w"></x-b>
79 """;
80
81 expect(CustomC.createdInvocations, 2);
82 expect(div.query('#t') is CustomC, isTrue);
83 });
84 });
85 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698