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

Side by Side Diff: tests/html/custom/attribute_changed_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/html/custom/constructor_calls_created_synchronously_test.dart » ('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 attribute_changed_callback_test;
6 import 'package:unittest/unittest.dart';
7 import 'package:unittest/html_config.dart';
8 import 'dart:html';
9
10 class A extends HtmlElement {
11 static final tag = 'x-a';
12 factory A() => new Element.tag(tag);
13
14 static var attributeChangedInvocations = 0;
15
16 void onAttributeChanged(name, oldValue, newValue) {
17 attributeChangedInvocations++;
18 }
19 }
20
21 class B extends HtmlElement {
22 static final tag = 'x-b';
23 factory B() => new Element.tag(tag);
24
25 static var invocations = [];
26
27 void onCreated() {
28 invocations.add('created');
29 }
30
31 void onAttributeChanged(name, oldValue, newValue) {
32 invocations.add('$name: $oldValue => $newValue');
33 }
34 }
35
36 main() {
37 useHtmlConfiguration();
38
39 // Adapted from Blink's fast/dom/custom/attribute-changed-callback test.
40
41 test('transfer attribute changed callback', () {
42 document.register(A.tag, A);
43 var element = new A();
44
45 element.attributes['a'] = 'b';
46 expect(A.attributeChangedInvocations, 1);
47 });
48
49 test('add, change and remove an attribute', () {
50 document.register(B.tag, B);
51 var b = new B();
52 b.id = 'x';
53 expect(B.invocations, ['created', 'id: null => x']);
54
55 B.invocations = [];
56 b.attributes.remove('id');
57 expect(B.invocations, ['id: x => null']);
58
59 B.invocations = [];
60 b.attributes['data-s'] = 't';
61 expect(B.invocations, ['data-s: null => t']);
62
63 B.invocations = [];
64 b.classList.toggle('u');
65 expect(B.invocations, ['class: null => u']);
66
67 b.attributes['data-v'] = 'w';
68 B.invocations = [];
69 b.attributes['data-v'] = 'x';
70 expect(B.invocations, ['data-v: w => x']);
71
72 B.invocations = [];
73 b.attributes['data-v'] = 'x';
74 expect(B.invocations, []);
75 });
76 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/custom/constructor_calls_created_synchronously_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698