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

Unified Diff: client/tests/client/html/ElementTests.dart

Issue 9930008: Fix issue http://code.google.com/p/dart/issues/detail?id=1877 without degrading performance. Impro… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review fixes Created 8 years, 9 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 | lib/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/client/html/ElementTests.dart
diff --git a/client/tests/client/html/ElementTests.dart b/client/tests/client/html/ElementTests.dart
index a049b698a9a480583af7539447354be1d34e7f3e..b953d6a3d96aa7ce076f16269803ce1c8b285905 100644
--- a/client/tests/client/html/ElementTests.dart
+++ b/client/tests/client/html/ElementTests.dart
@@ -412,38 +412,48 @@ void testElement() {
(listener) => Testing.addEventListener(element,
'webkitfullscreenchange', listener, true));
});
+
+ group('attributes', () {
+ test('manipulation', () {
+ final element = new Element.html(
+ '''<div class="foo" style="overflow: hidden" data-foo="bar"
+ data-foo2="bar2" dir="rtl">
+ </div>''');
+ final attributes = element.attributes;
+ Expect.equals(attributes['class'], 'foo');
+ Expect.equals(attributes['style'], 'overflow: hidden');
+ Expect.equals(attributes['data-foo'], 'bar');
+ Expect.equals(attributes['data-foo2'], 'bar2');
+ Expect.equals(attributes.length, 5);
+ Expect.equals(element.dataAttributes.length, 2);
+ element.dataAttributes['foo'] = 'baz';
+ Expect.equals(element.dataAttributes['foo'], 'baz');
+ Expect.equals(attributes['data-foo'], 'baz');
+ attributes['data-foo2'] = 'baz2';
+ Expect.equals(attributes['data-foo2'], 'baz2');
+ Expect.equals(element.dataAttributes['foo2'], 'baz2');
+ Expect.equals(attributes['dir'], 'rtl');
+
+ final dataAttributes = element.dataAttributes;
+ dataAttributes.remove('foo2');
+ Expect.equals(attributes.length, 4);
+ Expect.equals(dataAttributes.length, 1);
+ attributes.remove('style');
+ Expect.equals(attributes.length, 3);
+ dataAttributes['foo3'] = 'baz3';
+ Expect.equals(dataAttributes.length, 2);
+ Expect.equals(attributes.length, 4);
+ attributes['style'] = 'width: 300px;';
+ Expect.equals(attributes.length, 5);
+ });
- test('attributes', () {
- final element = new Element.html(
- '''<div class="foo" style="overflow: hidden" data-foo="bar"
- data-foo2="bar2" dir="rtl">
- </div>''');
- final attributes = element.attributes;
- Expect.equals(attributes['class'], 'foo');
- Expect.equals(attributes['style'], 'overflow: hidden');
- Expect.equals(attributes['data-foo'], 'bar');
- Expect.equals(attributes['data-foo2'], 'bar2');
- Expect.equals(attributes.length, 5);
- Expect.equals(element.dataAttributes.length, 2);
- element.dataAttributes['foo'] = 'baz';
- Expect.equals(element.dataAttributes['foo'], 'baz');
- Expect.equals(attributes['data-foo'], 'baz');
- attributes['data-foo2'] = 'baz2';
- Expect.equals(attributes['data-foo2'], 'baz2');
- Expect.equals(element.dataAttributes['foo2'], 'baz2');
- Expect.equals(attributes['dir'], 'rtl');
-
- // TODO(jacobr): determine why these tests are causing segfaults in dartium
- // element.dataAttributes.remove('foo2');
- // Expect.equals(attributes.length, 4);
- // Expect.equals(dataAttributes.length, 1);
- // attributes.remove('style');
- // Expect.equals(attributes.length, 3);
- // element.dataAttributes['foo3'] = 'baz3';
- // Expect.equals(dataAttributes.length, 2);
- // Expect.equals(attributes.length, 4);
- // attributes['style'] = 'width: 300px;';
- // Expect.equals(attributes.length, 5);*/
+ test('coercion', () {
+ final element = new Element.tag('div');
+ element.attributes['foo'] = 42;
+ element.attributes['bar'] = 3.1;
+ Expect.equals(element.attributes['foo'], '42');
+ Expect.equals(element.attributes['bar'], '3.1');
+ });
});
group('elements', () {
« no previous file with comments | « no previous file | lib/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698