|
1 <!DOCTYPE html> |
|
2 <html> |
|
3 <head> |
|
4 <title>HTML table tests</title> |
|
5 <link rel="stylesheet" type="text/css" |
|
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
7 |
|
8 <script type="application/javascript" |
|
9 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
10 |
|
11 <script type="application/javascript" |
|
12 src="../common.js"></script> |
|
13 <script type="application/javascript" |
|
14 src="../role.js"></script> |
|
15 |
|
16 <script type="application/javascript"> |
|
17 function doTest() |
|
18 { |
|
19 ////////////////////////////////////////////////////////////////////////// |
|
20 // tables having captions |
|
21 |
|
22 // Two captions, first is used, second is ignored. |
|
23 var accTree = |
|
24 { TABLE: [ |
|
25 { CAPTION: [ |
|
26 { |
|
27 role: ROLE_TEXT_LEAF, |
|
28 name: "caption" |
|
29 } |
|
30 ] }, |
|
31 { ROW: [ |
|
32 { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] }, |
|
33 { COLUMNHEADER: [ { TEXT_LEAF: [ ] } ] } |
|
34 ] }, |
|
35 { ROW: [ |
|
36 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
37 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
38 ] }, |
|
39 { ROW: [ |
|
40 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
41 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
42 ] }, |
|
43 { ROW: [ |
|
44 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
45 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
46 ] } |
|
47 ] }; |
|
48 |
|
49 testAccessibleTree("table", accTree); |
|
50 |
|
51 // One caption, empty text, caption is ignored. |
|
52 accTree = |
|
53 { TABLE: [ |
|
54 { ROW: [ |
|
55 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
56 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
57 ] } |
|
58 ] }; |
|
59 |
|
60 testAccessibleTree("table_caption_empty", accTree); |
|
61 |
|
62 // Two captions, first has empty text, both are ignored. |
|
63 accTree = |
|
64 { TABLE: [ |
|
65 { ROW: [ |
|
66 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
67 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
68 ] } |
|
69 ] }; |
|
70 |
|
71 testAccessibleTree("table_caption_firstempty", accTree); |
|
72 |
|
73 // One caption, placed in the end of table. In use. |
|
74 accTree = |
|
75 { TABLE: [ |
|
76 { CAPTION: [ |
|
77 { |
|
78 role: ROLE_TEXT_LEAF, |
|
79 name: "caption" |
|
80 } |
|
81 ] }, |
|
82 { ROW: [ |
|
83 { CELL: [ { TEXT_LEAF: [ ] } ] }, |
|
84 { CELL: [ { TEXT_LEAF: [ ] } ] } |
|
85 ] } |
|
86 ] }; |
|
87 |
|
88 testAccessibleTree("table_caption_intheend", accTree); |
|
89 |
|
90 ////////////////////////////////////////////////////////////////////////// |
|
91 // table2 (consist of one column) |
|
92 |
|
93 accTree = { |
|
94 role: ROLE_TABLE, |
|
95 children: [ |
|
96 { |
|
97 role: ROLE_ROW, |
|
98 children: [ |
|
99 { |
|
100 role: ROLE_COLUMNHEADER |
|
101 } |
|
102 ] |
|
103 }, |
|
104 { |
|
105 role: ROLE_ROW, |
|
106 children: [ |
|
107 { |
|
108 role: ROLE_CELL |
|
109 } |
|
110 ] |
|
111 } |
|
112 ] |
|
113 }; |
|
114 |
|
115 testAccessibleTree("table2", accTree); |
|
116 |
|
117 ////////////////////////////////////////////////////////////////////////// |
|
118 // table3 (consist of one row) |
|
119 |
|
120 accTree = { |
|
121 role: ROLE_TABLE, |
|
122 children: [ |
|
123 { |
|
124 role: ROLE_ROW, |
|
125 children: [ |
|
126 { |
|
127 role: ROLE_ROWHEADER |
|
128 }, |
|
129 { |
|
130 role: ROLE_CELL |
|
131 } |
|
132 ] |
|
133 } |
|
134 ] |
|
135 }; |
|
136 |
|
137 testAccessibleTree("table3", accTree); |
|
138 |
|
139 ///////////////////////////////////////////////////////////////////////// |
|
140 // table4 (display: table-row) |
|
141 accTree = |
|
142 { TABLE: [ |
|
143 { ROW: [ |
|
144 { CELL: [ |
|
145 { TEXT_LEAF: [ ] } |
|
146 ] } |
|
147 ] } ] |
|
148 }; |
|
149 testAccessibleTree("table4", accTree); |
|
150 |
|
151 SimpleTest.finish(); |
|
152 } |
|
153 |
|
154 SimpleTest.waitForExplicitFinish(); |
|
155 addA11yLoadEvent(doTest); |
|
156 </script> |
|
157 </head> |
|
158 <body> |
|
159 |
|
160 <a target="_blank" |
|
161 title="When a table has only one column per row and that column happens to be a column header its role is exposed wrong" |
|
162 href="https://bugzilla.mozilla.org/show_bug.cgi?id=529621"> |
|
163 Mozilla Bug 529621 |
|
164 </a> |
|
165 <a target="_blank" |
|
166 title="when div has display style table-row" |
|
167 href="https://bugzilla.mozilla.org/show_bug.cgi?id=727722"> |
|
168 Mozilla Bug 727722 |
|
169 </a> |
|
170 <p id="display"></p> |
|
171 <div id="content" style="display: none"></div> |
|
172 <pre id="test"> |
|
173 </pre> |
|
174 |
|
175 <table id="table"> |
|
176 <thead> |
|
177 <tr> |
|
178 <th>col1</th><th>col2</th> |
|
179 </tr> |
|
180 </thead> |
|
181 <caption>caption</caption> |
|
182 <tbody> |
|
183 <tr> |
|
184 <td>cell1</td><td>cell2</td> |
|
185 </tr> |
|
186 </tbody> |
|
187 <tr> |
|
188 <td>cell3</td><td>cell4</td> |
|
189 </tr> |
|
190 <caption>caption2</caption> |
|
191 <tfoot> |
|
192 <tr> |
|
193 <td>cell5</td><td>cell6</td> |
|
194 </tr> |
|
195 </tfoot> |
|
196 </table> |
|
197 |
|
198 <table id="table_caption_empty"> |
|
199 <caption></caption> |
|
200 <tr> |
|
201 <td>cell1</td><td>cell2</td> |
|
202 </tr> |
|
203 </table> |
|
204 |
|
205 <table id="table_caption_firstempty"> |
|
206 <caption></caption> |
|
207 <tr> |
|
208 <td>cell1</td><td>cell2</td> |
|
209 </tr> |
|
210 <caption>caption</caption> |
|
211 </table> |
|
212 |
|
213 <table id="table_caption_intheend"> |
|
214 <tr> |
|
215 <td>cell1</td><td>cell2</td> |
|
216 </tr> |
|
217 <caption>caption</caption> |
|
218 </table> |
|
219 |
|
220 <table id="table2"> |
|
221 <thead> |
|
222 <tr> |
|
223 <th>colheader</th> |
|
224 </tr> |
|
225 </thead> |
|
226 <tbody> |
|
227 <tr> |
|
228 <td>bla</td> |
|
229 </tr> |
|
230 </tbody> |
|
231 </table> |
|
232 |
|
233 <table id="table3"> |
|
234 <tr> |
|
235 <th>rowheader</th> |
|
236 <td>cell</td> |
|
237 </tr> |
|
238 </table> |
|
239 |
|
240 <table id="table4"> |
|
241 <div style="display: table-row"> |
|
242 <td>cell1</td> |
|
243 </div> |
|
244 </table> |
|
245 </body> |
|
246 </html> |