Backed out changeset db55605b2a4c (relanding bug 121341)
[wine-gecko.git] / accessible / tests / mochitest / test_table_indexes.html
bloba291a5e19d755ce1635eec620450abd8b7b5e3be
1 <!DOCTYPE html>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=410052
5 -->
6 <head>
7 <title>Table indexes chrome tests</title>
8 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
10 <script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
11 <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
13 <script type="application/javascript">
14 const nsIAccessibleRetrieval = Components.interfaces.nsIAccessibleRetrieval;
15 const nsIAccessibleTable = Components.interfaces.nsIAccessibleTable;
17 var gAccService = null;
19 function doTest()
21 gAccService = Components.classes["@mozilla.org/accessibleRetrieval;1"].
22 getService(nsIAccessibleRetrieval);
24 //////////////////////////////////////////////////////////////////////////
25 // table
26 var tRow = new Array(0,0,0,1,1,1,2,2,3,3);
27 var tCol = new Array(0,1,2,0,1,2,0,1,1,2);
29 testTable("table", 10, tRow, tCol);
31 //////////////////////////////////////////////////////////////////////////
32 // tableinsane1
33 tRow = [0,0,0,1,1,1,2,2,3,3];
34 tCol = [0,1,2,0,1,2,0,1,1,2];
36 testTable("tableinsane1", 10, tRow, tCol);
38 //////////////////////////////////////////////////////////////////////////
39 // tableinsane2
40 tRow = [0,0,0,1,1,1,2,2,3,3,4,4,4];
41 tCol = [0,1,2,0,1,2,0,1,1,2,1,3,4];
43 testTable("tableinsane2", 13, tRow, tCol);
45 //////////////////////////////////////////////////////////////////////////
46 // tableinsane4
47 tRow = [0,0,0,1,1,1,2,2,3,4];
48 tCol = [0,1,2,0,1,2,0,2,0,0];
50 testTable("tableinsane4", 10, tRow, tCol);
52 //////////////////////////////////////////////////////////////////////////
53 // tableborder
54 tRow = [0,0,0,1,1,1,2,2,3,3];
55 tCol = [0,1,2,0,1,2,0,1,1,2];
57 testTable("tableborder", 10, tRow, tCol);
59 SimpleTest.finish();
62 function testTable(aId, aLen, aRowIdxes, aColIdxes)
64 var table = document.getElementById(aId);
65 var tableAcc = gAccService.getAccessibleFor(table).
66 QueryInterface(nsIAccessibleTable);
68 var row, column, index;
69 var cellAcc;
71 for (var i = 0; i < aLen; i++) {
72 row = tableAcc.getRowAtIndex(i);
73 column = tableAcc.getColumnAtIndex(i);
74 index = tableAcc.getIndexAt(aRowIdxes[i], aColIdxes[i]);
76 is(row, aRowIdxes[i], aId + ": row for index " + i +" is nor correct");
77 is(column, aColIdxes[i],
78 aId + ": column for index " + i +"is nor correct");
79 is(index, i,
80 aId + ": row " + row + " /column " + column + " and index " + index + " aren't inconsistent.");
82 try {
83 cellAcc = null;
84 cellAcc = tableAcc.cellRefAt(row, column);
85 } catch (e) { }
87 ok(cellAcc,
88 aId + ": Can't get cell accessible at row = " + row + ", column = " + column);
90 if (cellAcc) {
91 var attrs = cellAcc.attributes;
92 is (parseInt(attrs.getStringProperty("table-cell-index")), index,
93 aId + ": cell index from object attributes of cell accessible isn't corrent.");
98 SimpleTest.waitForExplicitFinish();
99 addLoadEvent(doTest);
100 </script>
101 </head>
102 <body>
104 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=410052">Mozilla Bug 410052</a>
105 <p id="display"></p>
106 <div id="content" style="display: none"></div>
107 <pre id="test">
108 </pre>
110 <!--
111 If you change the structure of the table please make sure to change
112 the indexes count in 'for' statement in the script above.
114 <table border="1" id="table">
115 <caption><strong><b><font size="29">this is a caption for this table</font></b></strong></caption>
116 <thead>
117 <tr>
118 <th>col1</th>
119 <th>col2</th>
120 <th>col3</th>
121 </tr>
122 </thead>
123 <tbody>
124 <tr>
125 <td>1</td>
126 <td>2</td>
127 <td>3</td>
128 </tr>
129 <tr>
130 <td rowspan="0">4</td>
131 <td colspan="2">5</td>
132 </tr>
133 <tr>
134 <td>6</td>
135 <td>7</td>
136 </tr>
137 </tbody>
138 </table>
140 <table border="1" id="tableborder" style="border-collapse:collapse">
141 <caption><strong><b><font size="29">this is a caption for this bc table</font></b></strong></caption>
142 <thead>
143 <tr>
144 <th>col1</th>
145 <th>col2</th>
146 <th>col3</th>
147 </tr>
148 </thead>
149 <tbody>
150 <tr>
151 <td>1</td>
152 <td>2</td>
153 <td>3</td>
154 </tr>
155 <tr>
156 <td rowspan="2">4</td>
157 <td colspan="2">5</td>
158 </tr>
159 <tr>
160 <td>6</td>
161 <td>7</td>
162 </tr>
163 </tbody>
164 </table>
166 <table border="1" id="tableinsane1">
167 <caption>test empty row groups</caption>
168 <thead>
169 <tr>
170 <th>col1</th>
171 <th>col2</th>
172 <th>col3</th>
173 </tr>
174 </thead>
175 <tbody></tbody>
176 <tbody></tbody>
177 <tbody></tbody>
178 <tbody>
179 <tr>
180 <td>1</td>
181 <td>2</td>
182 <td>3</td>
183 </tr>
184 <tr>
185 <td rowspan="2">4</td>
186 <td colspan="2">5</td>
187 </tr>
188 <tr>
189 <td>6</td>
190 <td>7</td>
191 </tr>
192 </tbody>
193 </table>
195 <table border="1" id="tableinsane2" >
196 <caption>empty rowgroup + empty rows</caption>
197 <thead>
198 <tr>
199 <th>col1</th>
200 <th>col2</th>
201 <th>col3</th>
202 </tr>
203 </thead>
204 <tbody><tr></tr></tbody>
205 <tbody></tbody>
206 <tbody></tbody>
207 <tbody>
208 <tr>
209 <td>1</td>
210 <td>2</td>
211 <td>3</td>
212 </tr>
213 <tr>
214 <td rowspan="0">4</td>
215 <td colspan="0">5</td>
216 </tr>
217 <tr>
218 <td>6</td>
219 <td rowspan="0">7</td>
220 </tr>
221 <tr>
222 <td>8</td>
223 <td>9</td>
224 <td>10</td>
225 </tr>
227 </tbody>
229 <table border="1" id="tableinsane4" >
230 <caption>test cellmap holes</caption>
231 <thead>
232 <tr>
233 <th>col1</th>
234 <th>col2</th>
235 <th>col3</th>
236 </tr>
237 </thead>
238 <tbody><tr></tr></tbody>
239 <tbody></tbody>
240 <tbody></tbody>
241 <tbody>
242 <tr>
243 <td>1</td>
244 <td>2</td>
245 <td>3</td>
246 </tr>
247 <tr>
248 <td colspan="2">4</td>
249 <td rowspan="2">5</td>
250 </tr>
251 <tr>
252 <td>6</td>
253 </tr>
254 <tr>
255 <td colspan="3">7</td>
256 </tr>
258 </tbody>
259 </table>
261 </body>
262 </html>