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

Side by Side Diff: tests/html/element_test.dart

Issue 11348111: Adding support for accessing attributes in alternate namespaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Minor cleanup Created 8 years, 1 month 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 ElementTest; 5 library ElementTest;
6 import '../../pkg/unittest/lib/unittest.dart'; 6 import '../../pkg/unittest/lib/unittest.dart';
7 import '../../pkg/unittest/lib/html_individual_config.dart'; 7 import '../../pkg/unittest/lib/html_individual_config.dart';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'dart:svg'; 9 import 'dart:svg';
10 10
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 test('tbody', () => testConstructorHelper('tbody', 142 test('tbody', () => testConstructorHelper('tbody',
143 '<tbody><tr><td>foo</td></tr></tbody>', 'foo', 143 '<tbody><tr><td>foo</td></tr></tbody>', 'foo',
144 (element) => element is TableSectionElement)); 144 (element) => element is TableSectionElement));
145 test('tfoot', () => testConstructorHelper('tfoot', 145 test('tfoot', () => testConstructorHelper('tfoot',
146 '<tfoot><tr><td>foo</td></tr></tfoot>', 'foo', 146 '<tfoot><tr><td>foo</td></tr></tfoot>', 'foo',
147 (element) => element is TableSectionElement)); 147 (element) => element is TableSectionElement));
148 test('thead', () => testConstructorHelper('thead', 148 test('thead', () => testConstructorHelper('thead',
149 '<thead><tr><td>foo</td></tr></thead>', 'foo', 149 '<thead><tr><td>foo</td></tr></thead>', 'foo',
150 (element) => element is TableSectionElement)); 150 (element) => element is TableSectionElement));
151 }); 151 });
152 152
153 group('constructors', () { 153 group('constructors', () {
154 test('error', () { 154 test('error', () {
155 expect(() => new Element.html('<br/><br/>'), throwsArgumentError); 155 expect(() => new Element.html('<br/><br/>'), throwsArgumentError);
156 }); 156 });
157 157
158 test('.html has no parent', () => 158 test('.html has no parent', () =>
159 expect(new Element.html('<br/>').parent, isNull)); 159 expect(new Element.html('<br/>').parent, isNull));
160 160
161 test('a', () => testConstructorHelper('a', '<a>foo</a>', 'foo', 161 test('a', () => testConstructorHelper('a', '<a>foo</a>', 'foo',
162 (element) => element is AnchorElement)); 162 (element) => element is AnchorElement));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 // TODO(jacobr): video tags cause tests to segfault when using dartium. 276 // TODO(jacobr): video tags cause tests to segfault when using dartium.
277 // b/5522106. 277 // b/5522106.
278 // test('video', () => testConstructorHelper('video', 278 // test('video', () => testConstructorHelper('video',
279 // '<video>foo</video>', 'foo', 279 // '<video>foo</video>', 'foo',
280 // (element) => element is VideoElement)); 280 // (element) => element is VideoElement));
281 // TODO(jacobr): this test is broken until Dartium fixes b/5521083 281 // TODO(jacobr): this test is broken until Dartium fixes b/5521083
282 // test('someunknown', () => testConstructorHelper('someunknown', 282 // test('someunknown', () => testConstructorHelper('someunknown',
283 // '<someunknown>foo</someunknown>', 'foo', 283 // '<someunknown>foo</someunknown>', 'foo',
284 // (element) => element is UnknownElement)); 284 // (element) => element is UnknownElement));
285 }); 285 });
286 286
287 group('eventListening', () { 287 group('eventListening', () {
288 test('eventListeners', () { 288 test('eventListeners', () {
289 final element = new Element.tag('div'); 289 final element = new Element.tag('div');
290 final on = element.on; 290 final on = element.on;
291 291
292 testEventHelper(on.abort, 'abort', 292 testEventHelper(on.abort, 'abort',
293 (listener) => Testing.addEventListener( 293 (listener) => Testing.addEventListener(
294 element, 'abort', listener, true)); 294 element, 'abort', listener, true));
295 testEventHelper(on.beforeCopy, 'beforecopy', 295 testEventHelper(on.beforeCopy, 'beforecopy',
296 (listener) => Testing.addEventListener( 296 (listener) => Testing.addEventListener(
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 expect(attributes.length, 4); 457 expect(attributes.length, 4);
458 expect(dataAttributes.length, 1); 458 expect(dataAttributes.length, 1);
459 attributes.remove('style'); 459 attributes.remove('style');
460 expect(attributes.length, 3); 460 expect(attributes.length, 3);
461 dataAttributes['foo3'] = 'baz3'; 461 dataAttributes['foo3'] = 'baz3';
462 expect(dataAttributes.length, 2); 462 expect(dataAttributes.length, 2);
463 expect(attributes.length, 4); 463 expect(attributes.length, 4);
464 attributes['style'] = 'width: 300px;'; 464 attributes['style'] = 'width: 300px;';
465 expect(attributes.length, 5); 465 expect(attributes.length, 5);
466 }); 466 });
467
468 test('namespaces', () {
469 var element = new SVGElement.svg(
470 '''<svg xmlns="http://www.w3.org/2000/svg"
471 xmlns:xlink="http://www.w3.org/1999/xlink">
472 <image xlink:href="foo" data-foo="bar"/>
473 </svg>''').elements[0];
474
475 var attributes = element.attributes;
476 expect(attributes.length, 1);
477 expect(attributes['data-foo'], 'bar');
478
479 var xlinkAttrs =
480 element.getNamespacedAttributes('http://www.w3.org/1999/xlink');
481 expect(xlinkAttrs.length, 1);
482 expect(xlinkAttrs['href'], 'foo');
483
484 xlinkAttrs.remove('href');
485 expect(xlinkAttrs.length, 0);
486
487 xlinkAttrs['href'] = 'bar';
488 expect(xlinkAttrs['href'], 'bar');
489
490 var randomAttrs = element.getNamespacedAttributes('http://example.com');
491 expect(randomAttrs.length, 0);
492 randomAttrs['href'] = 'bar';
493 expect(randomAttrs.length, 1);
494 });
467 }); 495 });
468 496
469 group('elements', () { 497 group('elements', () {
470 test('is a subset of nodes', () { 498 test('is a subset of nodes', () {
471 var el = new Element.html("<div>Foo<br/><img/></div>"); 499 var el = new Element.html("<div>Foo<br/><img/></div>");
472 expect(el.nodes.length, 3); 500 expect(el.nodes.length, 3);
473 expect(el.elements.length, 2); 501 expect(el.elements.length, 2);
474 expect(el.nodes[1], el.elements[0]); 502 expect(el.nodes[1], el.elements[0]);
475 expect(el.nodes[2], el.elements[1]); 503 expect(el.nodes[2], el.elements[1]);
476 }); 504 });
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 }); 763 });
736 764
737 test('getRange', () { 765 test('getRange', () {
738 var range = makeElList().getRange(1, 2); 766 var range = makeElList().getRange(1, 2);
739 expect(range, isElementList); 767 expect(range, isElementList);
740 expect(range[0], isImageElement); 768 expect(range[0], isImageElement);
741 expect(range[1], isInputElement); 769 expect(range[1], isInputElement);
742 }); 770 });
743 }); 771 });
744 } 772 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698