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

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

Issue 26592009: Removing Element.createdCallback (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 unified diff | Download patch | Annotate | Revision Log
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 created_callback_test; 5 library created_callback_test;
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart'; 7 import 'package:unittest/html_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:js' as js; 9 import 'dart:js' as js;
10 import '../utils.dart'; 10 import '../utils.dart';
11 11
12 class A extends HtmlElement { 12 class A extends HtmlElement {
13 static final tag = 'x-a'; 13 static final tag = 'x-a';
14 factory A() => new Element.tag(tag); 14 factory A() => new Element.tag(tag);
15 A.created() : super.created(); 15 A.created() : super.created() {
16 createdInvocations++;
17 }
16 18
17 static int createdInvocations = 0; 19 static int createdInvocations = 0;
18
19 void createdCallback() {
20 createdInvocations++;
21 }
22 } 20 }
23 21
24 class B extends HtmlElement { 22 class B extends HtmlElement {
25 static final tag = 'x-b'; 23 static final tag = 'x-b';
26 factory B() => new Element.tag(tag); 24 factory B() => new Element.tag(tag);
27 B.created() : super.created(); 25 B.created() : super.created();
28 } 26 }
29 27
30 class C extends HtmlElement { 28 class C extends HtmlElement {
31 static final tag = 'x-c'; 29 static final tag = 'x-c';
32 factory C() => new Element.tag(tag); 30 factory C() => new Element.tag(tag);
33 C.created() : super.created(); 31 C.created() : super.created() {
34
35 static int createdInvocations = 0;
36 static var div;
37
38 void createdCallback() {
39 createdInvocations++; 32 createdInvocations++;
40 33
41 if (this.id != 'u') { 34 if (this.id != 'u') {
42 return; 35 return;
43 } 36 }
44 37
45 var t = div.query('#t'); 38 var t = div.query('#t');
46 var v = div.query('#v'); 39 var v = div.query('#v');
47 var w = div.query('#w'); 40 var w = div.query('#w');
48 41
49 expect(query('x-b:not(:unresolved)'), this); 42 expect(query('x-b:not(:unresolved)'), this);
50 expect(queryAll(':unresolved'), [v, w]); 43 expect(queryAll(':unresolved'), [v, w]);
51 44
52 // As per: 45 // As per:
53 // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-pa rsing 46 // http://www.w3.org/TR/2013/WD-custom-elements-20130514/#serializing-and-pa rsing
54 // creation order is t, u, v, w (postorder). 47 // creation order is t, u, v, w (postorder).
55 expect(t is C, isTrue); 48 expect(t is C, isTrue);
56 // Note, this is different from JavaScript where this would be false. 49 // Note, this is different from JavaScript where this would be false.
57 expect(v is C, isTrue); 50 expect(v is C, isTrue);
58 } 51 }
52
53 static int createdInvocations = 0;
54 static var div;
59 } 55 }
60 56
61 main() { 57 main() {
62 useHtmlConfiguration(); 58 useHtmlConfiguration();
63 59
64 // Adapted from Blink's 60 // Adapted from Blink's
65 // fast/dom/custom/created-callback test. 61 // fast/dom/custom/created-callback test.
66 62
67 var registered = false; 63 var registered = false;
68 setUp(() { 64 setUp(() {
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } catch(e) { 278 } catch(e) {
283 rethrow; 279 rethrow;
284 } finally { 280 } finally {
285 js.context['testExpectsGlobalError'] = false; 281 js.context['testExpectsGlobalError'] = false;
286 } 282 }
287 var errors = js.context['testSuppressedGlobalErrors']; 283 var errors = js.context['testSuppressedGlobalErrors'];
288 expect(errors['length'], 1); 284 expect(errors['length'], 1);
289 // Clear out the errors; 285 // Clear out the errors;
290 js.context['testSuppressedGlobalErrors']['length'] = 0; 286 js.context['testSuppressedGlobalErrors']['length'] = 0;
291 } 287 }
OLDNEW
« no previous file with comments | « tests/html/custom/constructor_calls_created_synchronously_test.dart ('k') | tests/html/custom/entered_left_view_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698