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

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

Issue 11888019: Fix new Element.html with tables in IE (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: updated Created 7 years, 11 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) 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' as svg; 9 import 'dart:svg' as svg;
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 container.remove(); 98 container.remove();
99 }); 99 });
100 100
101 group('constructors', () { 101 group('constructors', () {
102 test('error', () { 102 test('error', () {
103 expect(() => new Element.html('<br/><br/>'), throwsArgumentError); 103 expect(() => new Element.html('<br/><br/>'), throwsArgumentError);
104 }); 104 });
105 105
106 test('.html has no parent', () => 106 test('.html has no parent', () =>
107 expect(new Element.html('<br/>').parent, isNull)); 107 expect(new Element.html('<br/>').parent, isNull));
108
109 test('.html table', () {
110 // http://developers.whatwg.org/tabular-data.html#tabular-data
111 var node = new Element.html('''
112 <table>
113 <caption>Characteristics with positive and negative sides</caption>
114 <thead>
115 <tr>
116 <th id="n"> Negative
117 <th> Characteristic
118 <th> Positive
119 <tbody>
120 <tr>
121 <td headers="n r1"> Sad
122 <th id="r1"> Mood
123 <td> Happy
124 <tr>
125 <td headers="n r2"> Failing
126 <th id="r2"> Grade
127 <td> Passing
128 </table>''');
129 expect(node, predicate((x) => x is TableElement, 'is a TableElement'));
130 expect(node.tagName, 'TABLE');
131 expect(node.parent, isNull);
132 expect(node.caption.innerHtml,
133 'Characteristics with positive and negative sides');
134 expect(node.tHead.rows.length, 1);
135 expect(node.tHead.rows[0].cells.length, 3);
136 expect(node.tBodies.length, 1);
137 expect(node.tBodies[0].rows.length, 2);
138 expect(node.tBodies[0].rows[1].cells.mappedBy((c) => c.innerHtml),
139 [' Failing\n ', ' Grade\n ', ' Passing\n']);
140 });
141
142 test('.html caption', () {
143 var node = new Element.html('<caption><p>Table 1.');
144 expect(node, predicate((x) => x is TableCaptionElement,
145 'is a TableCaptionElement'));
146 expect(node.tagName, 'CAPTION');
147 expect(node.parent, isNull);
148 expect(node.innerHtml, '<p>Table 1.</p>');
149 });
150
151 test('.html colgroup', () {
152 var node = new Element.html('<colgroup> <col> <col> <col>');
153 expect(node, predicate((x) => x is TableColElement,
154 'is a TableColElement'));
155 expect(node.tagName, 'COLGROUP');
156 expect(node.parent, isNull);
157 expect(node.innerHtml, ' <col> <col> <col>');
158 });
159
160 test('.html col', () {
161 var node = new Element.html('<col span="2">');
162 expect(node, predicate((x) => x is TableColElement,
163 'is a TableColElement'));
164 expect(node.tagName, 'COL');
165 expect(node.parent, isNull);
166 expect(node.outerHtml, '<col span="2">');
167 });
168
169 test('.html tbody', () {
170 var innerHtml = '<tr><td headers="n r1">Sad</td><td>Happy</td></tr>';
171 var node = new Element.html('<tbody>$innerHtml');
172 expect(node, predicate((x) => x is TableSectionElement,
173 'is a TableSectionElement'));
174 expect(node.tagName, 'TBODY');
175 expect(node.parent, isNull);
176 expect(node.rows.length, 1);
177 expect(node.rows[0].cells.length, 2);
178 expect(node.innerHtml, innerHtml);
179 });
180
181 test('.html thead', () {
182 var innerHtml = '<tr><th id="n">Negative</th><th>Positive</th></tr>';
183 var node = new Element.html('<thead>$innerHtml');
184 expect(node, predicate((x) => x is TableSectionElement,
185 'is a TableSectionElement'));
186 expect(node.tagName, 'THEAD');
187 expect(node.parent, isNull);
188 expect(node.rows.length, 1);
189 expect(node.rows[0].cells.length, 2);
190 expect(node.innerHtml, innerHtml);
191 });
192
193 test('.html tfoot', () {
194 var innerHtml = '<tr><th>percentage</th><td>34.3%</td></tr>';
195 var node = new Element.html('<tfoot>$innerHtml');
196 expect(node, predicate((x) => x is TableSectionElement,
197 'is a TableSectionElement'));
198 expect(node.tagName, 'TFOOT');
199 expect(node.parent, isNull);
200 expect(node.rows.length, 1);
201 expect(node.rows[0].cells.length, 2);
202 expect(node.innerHtml, innerHtml);
203 });
204
205 test('.html tr', () {
206 var node = new Element.html('<tr><td>foo<td>bar');
207 expect(node, predicate((x) => x is TableRowElement,
208 'is a TableRowElement'));
209 expect(node.tagName, 'TR');
210 expect(node.parent, isNull);
211 expect(node.cells.mappedBy((c) => c.innerHtml), ['foo', 'bar']);
212 });
213
214 test('.html td', () {
215 var node = new Element.html('<td>foobar');
216 expect(node, predicate((x) => x is TableCellElement,
217 'is a TableCellElement'));
218 expect(node.tagName, 'TD');
219 expect(node.parent, isNull);
220 expect(node.innerHtml, 'foobar');
221 });
222
223 test('.html th', () {
224 var node = new Element.html('<th>foobar');
225 expect(node, predicate((x) => x is TableCellElement,
226 'is a TableCellElement'));
227 expect(node.tagName, 'TH');
228 expect(node.parent, isNull);
229 expect(node.innerHtml, 'foobar');
230 });
108 }); 231 });
109 232
110 group('eventListening', () { 233 group('eventListening', () {
111 test('eventListeners', () { 234 test('eventListeners', () {
112 final element = new Element.tag('div'); 235 final element = new Element.tag('div');
113 final on = element.on; 236 final on = element.on;
114 237
115 testEventHelper(on.abort, 'abort', 238 testEventHelper(on.abort, 'abort',
116 (listener) => Testing.addEventListener( 239 (listener) => Testing.addEventListener(
117 element, 'abort', listener, true)); 240 element, 'abort', listener, true));
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 }); 734 });
612 735
613 test('getRange', () { 736 test('getRange', () {
614 var range = makeElList().getRange(1, 2); 737 var range = makeElList().getRange(1, 2);
615 expect(range, isElementList); 738 expect(range, isElementList);
616 expect(range[0], isImageElement); 739 expect(range[0], isImageElement);
617 expect(range[1], isInputElement); 740 expect(range[1], isInputElement);
618 }); 741 });
619 }); 742 });
620 } 743 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Element.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698