Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <html>
2 <head>
3 <title>[AccessFu] Improve reading of table semantics</title>
5 <link rel="stylesheet" type="text/css"
6 href="chrome://mochikit/content/tests/SimpleTest/test.css" />
7 <script type="application/javascript"
8 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
9 <script type="application/javascript"
10 src="../common.js"></script>
11 <script type="application/javascript"
12 src="output.js"></script>
13 <script type="application/javascript">
15 function doTest() {
16 // Test the following accOrElmOrID.
17 var tests = [{
18 accOrElmOrID: "table1",
19 expectedUtterance: [["table with 2 columns and 2 rows",
20 "Column 1 Row 1", "col1", "Column 2 Row 1", "col2",
21 "Column 1 Row 2 col1", "cell1", "Column 2 Row 2 col2", "cell2"], [
22 "col1", "Column 1 Row 1", "col2", "Column 2 Row 1", "cell1",
23 "Column 1 Row 2 col1", "cell2", "Column 2 Row 2 col2",
24 "table with 2 columns and 2 rows"]],
25 expectedBraille: [["tbl 2c 2r", "c1r1", "col1", "c2r1", "col2",
26 "c1r2 col1", "cell1", "c2r2 col2", "cell2"], ["col1", "c1r1", "col2",
27 "c2r1", "cell1", "c1r2 col1", "cell2", "c2r2 col2", "tbl 2c 2r"]]
28 }, {
29 accOrElmOrID: "table2",
30 expectedUtterance: [["table with 2 columns and 2 rows",
31 "Column 1 Row 1 col1", "cell1", "Column 2 Row 1 col2",
32 "table with 1 column and 2 rows", "Column 1 Row 1", "colheader",
33 "Column 1 Row 2 colheader", "bla", "Column 1 Row 2", "col1",
34 "Column 2 Row 2", "col2"], ["cell1", "Column 1 Row 1 col1",
35 "colheader", "Column 1 Row 1", "bla", "Column 1 Row 2 colheader",
36 "table with 1 column and 2 rows", "Column 2 Row 1 col2", "col1",
37 "Column 1 Row 2", "col2", "Column 2 Row 2",
38 "table with 2 columns and 2 rows"]],
39 expectedBraille: [["tbl 2c 2r", "c1r1 col1", "cell1", "c2r1 col2",
40 "tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader", "bla", "c1r2",
41 "col1", "c2r2", "col2"], ["cell1", "c1r1 col1", "colheader", "c1r1",
42 "bla", "c1r2 colheader", "tbl 1c 2r", "c2r1 col2", "col1", "c1r2",
43 "col2", "c2r2", "tbl 2c 2r"]]
44 }, {
45 accOrElmOrID: "table3",
46 expectedUtterance: [["table with 2 columns and 2 rows",
47 "Column 2 Row 1 col2", "table with 1 column and 2 rows",
48 "Column 1 Row 1", "colheader", "Column 1 Row 2 colheader", "bla"], [
49 "colheader", "Column 1 Row 1", "bla", "Column 1 Row 2 colheader",
50 "table with 1 column and 2 rows", "Column 2 Row 1 col2",
51 "table with 2 columns and 2 rows"]],
52 expectedBraille: [["tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader",
53 "bla"], ["colheader", "c1r1", "bla", "c1r2 colheader", "tbl 1c 2r"]]
54 }, {
55 accOrElmOrID: "table4",
56 expectedUtterance: [["table with 4 columns and 3 rows",
57 "Column 1 Row 1", "col1", "Column 2 Row 1", "col2", "Column 3 Row 1",
58 "col3", "Column 1 Row 2 spans 2 columns col1", "row1",
59 "Column 3 Row 2 col3 row1", "cell1",
60 "Column 4 Row 2 spans 2 rows row1", "cell2", "Column 1 Row 3 col1",
61 "row2", "Column 2 Row 3 col2 row2", "cell3",
62 "Column 3 Row 3 col3 row2", "cell4"], ["col1", "Column 1 Row 1",
63 "col2", "Column 2 Row 1", "col3", "Column 3 Row 1", "row1",
64 "Column 1 Row 2 spans 2 columns col1", "cell1",
65 "Column 3 Row 2 col3 row1", "cell2",
66 "Column 4 Row 2 spans 2 rows row1", "row2", "Column 1 Row 3 col1",
67 "cell3", "Column 2 Row 3 col2 row2", "cell4",
68 "Column 3 Row 3 col3 row2", "table with 4 columns and 3 rows"]],
69 expectedBraille: [["tbl 4c 3r", "c1r1", "col1", "c2r1", "col2", "c3r1",
70 "col3", "c1r2 col1", "row1", "c3r2 col3 row1", "cell1", "c4r2 row1",
71 "cell2", "c1r3 col1", "row2", "c2r3 col2 row2", "cell3",
72 "c3r3 col3 row2", "cell4"], ["col1", "c1r1", "col2", "c2r1", "col3",
73 "c3r1", "row1", "c1r2 col1", "cell1", "c3r2 col3 row1", "cell2",
74 "c4r2 row1", "row2", "c1r3 col1", "cell3", "c2r3 col2 row2", "cell4",
75 "c3r3 col3 row2", "tbl 4c 3r"]]
76 }, {
77 accOrElmOrID: "table5",
78 expectedUtterance: [["Row1", "Row2"], ["Row1", "Row2"]],
79 expectedBraille: [["Row1", "Row2"], ["Row1", "Row2"]]
80 }, {
81 // Test pivot to table1_th1 from table1.
82 accOrElmOrID: "table1_th1",
83 oldAccOrElmOrID: "table1",
84 expectedUtterance: [["Column 1 Row 1", "col1"], ["col1",
85 "Column 1 Row 1"]],
86 expectedBraille: [["c1r1", "col1"], ["col1", "c1r1"]]
87 }, {
88 // Test pivot to table1_td2 from table1.
89 accOrElmOrID: "table1_td2",
90 oldAccOrElmOrID: "table1",
91 expectedUtterance: [["Column 2 Row 2 col2", "cell2"], ["cell2",
92 "Column 2 Row 2 col2"]],
93 expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]]
94 }, {
95 // Test pivot to table1_td2 from table1_th1.
96 accOrElmOrID: "table1_td2",
97 oldAccOrElmOrID: "table1_th1",
98 expectedUtterance: [["Column 2 Row 2 col2", "cell2"], ["cell2",
99 "Column 2 Row 2 col2"]],
100 expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]]
101 }, {
102 // Test pivot to table1_td2 from table1_td1.
103 accOrElmOrID: "table1_td2",
104 oldAccOrElmOrID: "table1_td1",
105 expectedUtterance: [["Column 2 col2", "cell2"], ["cell2",
106 "Column 2 col2"]],
107 expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]]
108 }, {
109 // Test pivot to table2_cell_1 from table2.
110 accOrElmOrID: "table2_cell_1",
111 oldAccOrElmOrID: "table2",
112 expectedUtterance: [["Column 1 Row 1 col1", "cell1"], ["cell1",
113 "Column 1 Row 1 col1"]],
114 expectedBraille: [["c1r1 col1", "cell1"], ["cell1", "c1r1 col1"]]
115 }, {
116 // Test pivot to table2_cell_2 from table2.
117 accOrElmOrID: "table2_cell_2",
118 oldAccOrElmOrID: "table2",
119 expectedUtterance: [["Column 2 Row 1 col2",
120 "table with 1 column and 2 rows", "Column 1 Row 1", "colheader",
121 "Column 1 Row 2 colheader", "bla"], ["colheader", "Column 1 Row 1",
122 "bla", "Column 1 Row 2 colheader", "table with 1 column and 2 rows",
123 "Column 2 Row 1 col2"]],
124 expectedBraille: [["c2r1 col2", "tbl 1c 2r", "c1r1", "colheader",
125 "c1r2 colheader", "bla"], ["colheader", "c1r1", "bla",
126 "c1r2 colheader", "tbl 1c 2r", "c2r1 col2"]]
127 }, {
128 // Test pivot to table2_cell_1 from table2_cell_2.
129 accOrElmOrID: "table2_cell_1",
130 oldAccOrElmOrID: "table2_cell_2",
131 expectedUtterance: [["Column 1 col1", "cell1"], ["cell1",
132 "Column 1 col1"]],
133 expectedBraille: [["c1r1 col1", "cell1"], ["cell1", "c1r1 col1"]]
134 }, {
135 // Test pivot to table3_cell from table2.
136 accOrElmOrID: "table3_cell",
137 oldAccOrElmOrID: "table2",
138 expectedUtterance: [["Column 2 Row 1 col2",
139 "table with 1 column and 2 rows", "Column 1 Row 2 colheader",
140 "bla"], ["bla", "Column 1 Row 2 colheader",
141 "table with 1 column and 2 rows", "Column 2 Row 1 col2"]],
142 expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]]
143 }, {
144 // Test pivot to table3_cell from table2_cell_1.
145 accOrElmOrID: "table3_cell",
146 oldAccOrElmOrID: "table2_cell_1",
147 expectedUtterance: [["Column 2 col2", "table with 1 column and 2 rows",
148 "Column 1 Row 2 colheader", "bla"], ["bla",
149 "Column 1 Row 2 colheader", "table with 1 column and 2 rows",
150 "Column 2 Row 1 col2"]],
151 expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]]
152 }, {
153 // Test pivot to table3_cell from table3_ch.
154 accOrElmOrID: "table3_cell",
155 oldAccOrElmOrID: "table3_ch",
156 expectedUtterance: [["Row 2", "bla"], ["bla", "Row 2"]],
157 expectedBraille: [["c1r2", "bla"], ["bla", "c1r2"]]
158 }, {
159 // Test pivot to table3_cell from table1_td1.
160 accOrElmOrID: "table3_cell",
161 oldAccOrElmOrID: "table1_td1",
162 expectedUtterance: [["table with 2 columns and 2 rows",
163 "Column 2 Row 1 col2", "table with 1 column and 2 rows",
164 "Column 1 Row 2 colheader", "bla"], ["bla",
165 "Column 1 Row 2 colheader", "table with 1 column and 2 rows",
166 "Column 2 Row 1 col2", "table with 2 columns and 2 rows"]],
167 expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]]
168 }, {
169 // Test pivot to table4_ch_3 from table4.
170 accOrElmOrID: "table4_ch_3",
171 oldAccOrElmOrID: "table4",
172 expectedUtterance: [["Column 3 Row 1", "col3"], ["col3",
173 "Column 3 Row 1"]],
174 expectedBraille: [["c3r1", "col3"], ["col3", "c3r1"]]
175 }, {
176 // Test pivot to table4_rh_1 from table4_ch_3.
177 accOrElmOrID: "table4_rh_1",
178 oldAccOrElmOrID: "table4_ch_3",
179 expectedUtterance: [["Column 1 Row 2 spans 2 columns col1", "row1"], [
180 "row1", "Column 1 Row 2 spans 2 columns col1"]],
181 expectedBraille: [["c1r2 col1", "row1"], ["row1", "c1r2 col1"]]
182 }, {
183 // Test pivot to table4_cell_3 from table4_rh_1.
184 accOrElmOrID: "table4_cell_3",
185 oldAccOrElmOrID: "table4_rh_1",
186 expectedUtterance: [["Column 4 spans 2 rows", "cell2"], ["cell2",
187 "Column 4 spans 2 rows"]],
188 expectedBraille: [["c4r2", "cell2"], ["cell2", "c4r2"]]
189 }, {
190 // Test pivot to table4_cell_5 from table4_cell_3.
191 accOrElmOrID: "table4_cell_5",
192 oldAccOrElmOrID: "table4_cell_3",
193 expectedUtterance: [["Column 2 Row 3 col2 row2", "cell3"], ["cell3",
194 "Column 2 Row 3 col2 row2"]],
195 expectedBraille: [["c2r3 col2 row2", "cell3"], ["cell3",
196 "c2r3 col2 row2"]]
197 }];
199 SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, 0);
201 // Test outputs (utterance and braille) for tables including their
202 // headers and cells.
203 tests.forEach(function run(test) {
204 var outputOrderValues = [0, 1];
205 outputOrderValues.forEach(function testOutputOrder(outputOrder) {
206 SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, outputOrder);
207 testOutput(test.expectedUtterance[outputOrder], test.accOrElmOrID,
208 test.oldAccOrElmOrID, 1);
209 testOutput(test.expectedBraille[outputOrder], test.accOrElmOrID,
210 test.oldAccOrElmOrID, 0);
211 });
212 });
214 // If there was an original utterance order preference, revert to it.
215 SpecialPowers.clearUserPref(PREF_UTTERANCE_ORDER);
216 SimpleTest.finish();
217 }
219 SimpleTest.waitForExplicitFinish();
220 addA11yLoadEvent(doTest);
221 </script>
222 </head>
223 <body>
224 <div id="root">
225 <a target="_blank"
226 href="https://bugzilla.mozilla.org/show_bug.cgi?id=830748"
227 title="[AccessFu] Improve reading of table semantics">
228 Mozilla Bug 830748
229 </a>
230 <p id="display"></p>
231 <div id="content" style="display: none"></div>
232 <pre id="test"></pre>
233 <table id="table1">
234 <thead>
235 <tr>
236 <th id="table1_th1">col1</th>
237 <th>col2</th>
238 </tr>
239 </thead>
240 <tbody>
241 <tr>
242 <td id="table1_td1">cell1</td>
243 <td id="table1_td2">cell2</td>
244 </tr>
245 </tbody>
246 </table>
247 <table id="table2" border="1">
248 <tr>
249 <td id="table2_cell_1" headers="table2_ch_1">cell1</td>
250 <td id="table2_cell_2" headers="table2_ch_2">
251 <table id="table3">
252 <thead>
253 <tr>
254 <th id="table3_ch">colheader</th>
255 </tr>
256 </thead>
257 <tbody>
258 <tr>
259 <td id="table3_cell">bla</td>
260 </tr>
261 </tbody>
262 </table>
263 </td>
264 </tr>
265 <tr>
266 <td id="table2_ch_1" scope="col">col1</td>
267 <td id="table2_ch_2" scope="col">col2</td>
268 </tr>
269 </table>
270 <table id="table4" border="1">
271 <thead>
272 <tr>
273 <th id="table4_ch_1">col1</th>
274 <th id="table4_ch_2">col2</th>
275 <td id="table4_ch_3" scope="col">col3</td>
276 </tr>
277 </thead>
278 <tbody>
279 <tr>
280 <th id="table4_rh_1" colspan="2">row1</th>
281 <td id="table4_cell_2">cell1</td>
282 <td id="table4_cell_3" rowspan="2">cell2</td>
283 </tr>
284 <tr>
285 <td id="table4_rh_2" scope="row">row2</td>
286 <td id="table4_cell_5">cell3</td>
287 <td id="table4_cell_6">cell4</td>
288 </tr>
289 </tbody>
290 </table>
291 <table id="table5">
292 <tr><td>Row1</td></tr>
293 <tr><td>Row2</td></tr>
294 </table>
295 </div>
296 </body>
297 </html>