1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/jsat/test_tables.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,297 @@ 1.4 +<html> 1.5 +<head> 1.6 + <title>[AccessFu] Improve reading of table semantics</title> 1.7 + 1.8 + <link rel="stylesheet" type="text/css" 1.9 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + <script type="application/javascript" 1.11 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <script type="application/javascript" 1.13 + src="../common.js"></script> 1.14 + <script type="application/javascript" 1.15 + src="output.js"></script> 1.16 + <script type="application/javascript"> 1.17 + 1.18 + function doTest() { 1.19 + // Test the following accOrElmOrID. 1.20 + var tests = [{ 1.21 + accOrElmOrID: "table1", 1.22 + expectedUtterance: [["table with 2 columns and 2 rows", 1.23 + "Column 1 Row 1", "col1", "Column 2 Row 1", "col2", 1.24 + "Column 1 Row 2 col1", "cell1", "Column 2 Row 2 col2", "cell2"], [ 1.25 + "col1", "Column 1 Row 1", "col2", "Column 2 Row 1", "cell1", 1.26 + "Column 1 Row 2 col1", "cell2", "Column 2 Row 2 col2", 1.27 + "table with 2 columns and 2 rows"]], 1.28 + expectedBraille: [["tbl 2c 2r", "c1r1", "col1", "c2r1", "col2", 1.29 + "c1r2 col1", "cell1", "c2r2 col2", "cell2"], ["col1", "c1r1", "col2", 1.30 + "c2r1", "cell1", "c1r2 col1", "cell2", "c2r2 col2", "tbl 2c 2r"]] 1.31 + }, { 1.32 + accOrElmOrID: "table2", 1.33 + expectedUtterance: [["table with 2 columns and 2 rows", 1.34 + "Column 1 Row 1 col1", "cell1", "Column 2 Row 1 col2", 1.35 + "table with 1 column and 2 rows", "Column 1 Row 1", "colheader", 1.36 + "Column 1 Row 2 colheader", "bla", "Column 1 Row 2", "col1", 1.37 + "Column 2 Row 2", "col2"], ["cell1", "Column 1 Row 1 col1", 1.38 + "colheader", "Column 1 Row 1", "bla", "Column 1 Row 2 colheader", 1.39 + "table with 1 column and 2 rows", "Column 2 Row 1 col2", "col1", 1.40 + "Column 1 Row 2", "col2", "Column 2 Row 2", 1.41 + "table with 2 columns and 2 rows"]], 1.42 + expectedBraille: [["tbl 2c 2r", "c1r1 col1", "cell1", "c2r1 col2", 1.43 + "tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader", "bla", "c1r2", 1.44 + "col1", "c2r2", "col2"], ["cell1", "c1r1 col1", "colheader", "c1r1", 1.45 + "bla", "c1r2 colheader", "tbl 1c 2r", "c2r1 col2", "col1", "c1r2", 1.46 + "col2", "c2r2", "tbl 2c 2r"]] 1.47 + }, { 1.48 + accOrElmOrID: "table3", 1.49 + expectedUtterance: [["table with 2 columns and 2 rows", 1.50 + "Column 2 Row 1 col2", "table with 1 column and 2 rows", 1.51 + "Column 1 Row 1", "colheader", "Column 1 Row 2 colheader", "bla"], [ 1.52 + "colheader", "Column 1 Row 1", "bla", "Column 1 Row 2 colheader", 1.53 + "table with 1 column and 2 rows", "Column 2 Row 1 col2", 1.54 + "table with 2 columns and 2 rows"]], 1.55 + expectedBraille: [["tbl 1c 2r", "c1r1", "colheader", "c1r2 colheader", 1.56 + "bla"], ["colheader", "c1r1", "bla", "c1r2 colheader", "tbl 1c 2r"]] 1.57 + }, { 1.58 + accOrElmOrID: "table4", 1.59 + expectedUtterance: [["table with 4 columns and 3 rows", 1.60 + "Column 1 Row 1", "col1", "Column 2 Row 1", "col2", "Column 3 Row 1", 1.61 + "col3", "Column 1 Row 2 spans 2 columns col1", "row1", 1.62 + "Column 3 Row 2 col3 row1", "cell1", 1.63 + "Column 4 Row 2 spans 2 rows row1", "cell2", "Column 1 Row 3 col1", 1.64 + "row2", "Column 2 Row 3 col2 row2", "cell3", 1.65 + "Column 3 Row 3 col3 row2", "cell4"], ["col1", "Column 1 Row 1", 1.66 + "col2", "Column 2 Row 1", "col3", "Column 3 Row 1", "row1", 1.67 + "Column 1 Row 2 spans 2 columns col1", "cell1", 1.68 + "Column 3 Row 2 col3 row1", "cell2", 1.69 + "Column 4 Row 2 spans 2 rows row1", "row2", "Column 1 Row 3 col1", 1.70 + "cell3", "Column 2 Row 3 col2 row2", "cell4", 1.71 + "Column 3 Row 3 col3 row2", "table with 4 columns and 3 rows"]], 1.72 + expectedBraille: [["tbl 4c 3r", "c1r1", "col1", "c2r1", "col2", "c3r1", 1.73 + "col3", "c1r2 col1", "row1", "c3r2 col3 row1", "cell1", "c4r2 row1", 1.74 + "cell2", "c1r3 col1", "row2", "c2r3 col2 row2", "cell3", 1.75 + "c3r3 col3 row2", "cell4"], ["col1", "c1r1", "col2", "c2r1", "col3", 1.76 + "c3r1", "row1", "c1r2 col1", "cell1", "c3r2 col3 row1", "cell2", 1.77 + "c4r2 row1", "row2", "c1r3 col1", "cell3", "c2r3 col2 row2", "cell4", 1.78 + "c3r3 col3 row2", "tbl 4c 3r"]] 1.79 + }, { 1.80 + accOrElmOrID: "table5", 1.81 + expectedUtterance: [["Row1", "Row2"], ["Row1", "Row2"]], 1.82 + expectedBraille: [["Row1", "Row2"], ["Row1", "Row2"]] 1.83 + }, { 1.84 + // Test pivot to table1_th1 from table1. 1.85 + accOrElmOrID: "table1_th1", 1.86 + oldAccOrElmOrID: "table1", 1.87 + expectedUtterance: [["Column 1 Row 1", "col1"], ["col1", 1.88 + "Column 1 Row 1"]], 1.89 + expectedBraille: [["c1r1", "col1"], ["col1", "c1r1"]] 1.90 + }, { 1.91 + // Test pivot to table1_td2 from table1. 1.92 + accOrElmOrID: "table1_td2", 1.93 + oldAccOrElmOrID: "table1", 1.94 + expectedUtterance: [["Column 2 Row 2 col2", "cell2"], ["cell2", 1.95 + "Column 2 Row 2 col2"]], 1.96 + expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]] 1.97 + }, { 1.98 + // Test pivot to table1_td2 from table1_th1. 1.99 + accOrElmOrID: "table1_td2", 1.100 + oldAccOrElmOrID: "table1_th1", 1.101 + expectedUtterance: [["Column 2 Row 2 col2", "cell2"], ["cell2", 1.102 + "Column 2 Row 2 col2"]], 1.103 + expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]] 1.104 + }, { 1.105 + // Test pivot to table1_td2 from table1_td1. 1.106 + accOrElmOrID: "table1_td2", 1.107 + oldAccOrElmOrID: "table1_td1", 1.108 + expectedUtterance: [["Column 2 col2", "cell2"], ["cell2", 1.109 + "Column 2 col2"]], 1.110 + expectedBraille: [["c2r2 col2", "cell2"], ["cell2", "c2r2 col2"]] 1.111 + }, { 1.112 + // Test pivot to table2_cell_1 from table2. 1.113 + accOrElmOrID: "table2_cell_1", 1.114 + oldAccOrElmOrID: "table2", 1.115 + expectedUtterance: [["Column 1 Row 1 col1", "cell1"], ["cell1", 1.116 + "Column 1 Row 1 col1"]], 1.117 + expectedBraille: [["c1r1 col1", "cell1"], ["cell1", "c1r1 col1"]] 1.118 + }, { 1.119 + // Test pivot to table2_cell_2 from table2. 1.120 + accOrElmOrID: "table2_cell_2", 1.121 + oldAccOrElmOrID: "table2", 1.122 + expectedUtterance: [["Column 2 Row 1 col2", 1.123 + "table with 1 column and 2 rows", "Column 1 Row 1", "colheader", 1.124 + "Column 1 Row 2 colheader", "bla"], ["colheader", "Column 1 Row 1", 1.125 + "bla", "Column 1 Row 2 colheader", "table with 1 column and 2 rows", 1.126 + "Column 2 Row 1 col2"]], 1.127 + expectedBraille: [["c2r1 col2", "tbl 1c 2r", "c1r1", "colheader", 1.128 + "c1r2 colheader", "bla"], ["colheader", "c1r1", "bla", 1.129 + "c1r2 colheader", "tbl 1c 2r", "c2r1 col2"]] 1.130 + }, { 1.131 + // Test pivot to table2_cell_1 from table2_cell_2. 1.132 + accOrElmOrID: "table2_cell_1", 1.133 + oldAccOrElmOrID: "table2_cell_2", 1.134 + expectedUtterance: [["Column 1 col1", "cell1"], ["cell1", 1.135 + "Column 1 col1"]], 1.136 + expectedBraille: [["c1r1 col1", "cell1"], ["cell1", "c1r1 col1"]] 1.137 + }, { 1.138 + // Test pivot to table3_cell from table2. 1.139 + accOrElmOrID: "table3_cell", 1.140 + oldAccOrElmOrID: "table2", 1.141 + expectedUtterance: [["Column 2 Row 1 col2", 1.142 + "table with 1 column and 2 rows", "Column 1 Row 2 colheader", 1.143 + "bla"], ["bla", "Column 1 Row 2 colheader", 1.144 + "table with 1 column and 2 rows", "Column 2 Row 1 col2"]], 1.145 + expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]] 1.146 + }, { 1.147 + // Test pivot to table3_cell from table2_cell_1. 1.148 + accOrElmOrID: "table3_cell", 1.149 + oldAccOrElmOrID: "table2_cell_1", 1.150 + expectedUtterance: [["Column 2 col2", "table with 1 column and 2 rows", 1.151 + "Column 1 Row 2 colheader", "bla"], ["bla", 1.152 + "Column 1 Row 2 colheader", "table with 1 column and 2 rows", 1.153 + "Column 2 Row 1 col2"]], 1.154 + expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]] 1.155 + }, { 1.156 + // Test pivot to table3_cell from table3_ch. 1.157 + accOrElmOrID: "table3_cell", 1.158 + oldAccOrElmOrID: "table3_ch", 1.159 + expectedUtterance: [["Row 2", "bla"], ["bla", "Row 2"]], 1.160 + expectedBraille: [["c1r2", "bla"], ["bla", "c1r2"]] 1.161 + }, { 1.162 + // Test pivot to table3_cell from table1_td1. 1.163 + accOrElmOrID: "table3_cell", 1.164 + oldAccOrElmOrID: "table1_td1", 1.165 + expectedUtterance: [["table with 2 columns and 2 rows", 1.166 + "Column 2 Row 1 col2", "table with 1 column and 2 rows", 1.167 + "Column 1 Row 2 colheader", "bla"], ["bla", 1.168 + "Column 1 Row 2 colheader", "table with 1 column and 2 rows", 1.169 + "Column 2 Row 1 col2", "table with 2 columns and 2 rows"]], 1.170 + expectedBraille: [["c1r2 colheader", "bla"], ["bla", "c1r2 colheader"]] 1.171 + }, { 1.172 + // Test pivot to table4_ch_3 from table4. 1.173 + accOrElmOrID: "table4_ch_3", 1.174 + oldAccOrElmOrID: "table4", 1.175 + expectedUtterance: [["Column 3 Row 1", "col3"], ["col3", 1.176 + "Column 3 Row 1"]], 1.177 + expectedBraille: [["c3r1", "col3"], ["col3", "c3r1"]] 1.178 + }, { 1.179 + // Test pivot to table4_rh_1 from table4_ch_3. 1.180 + accOrElmOrID: "table4_rh_1", 1.181 + oldAccOrElmOrID: "table4_ch_3", 1.182 + expectedUtterance: [["Column 1 Row 2 spans 2 columns col1", "row1"], [ 1.183 + "row1", "Column 1 Row 2 spans 2 columns col1"]], 1.184 + expectedBraille: [["c1r2 col1", "row1"], ["row1", "c1r2 col1"]] 1.185 + }, { 1.186 + // Test pivot to table4_cell_3 from table4_rh_1. 1.187 + accOrElmOrID: "table4_cell_3", 1.188 + oldAccOrElmOrID: "table4_rh_1", 1.189 + expectedUtterance: [["Column 4 spans 2 rows", "cell2"], ["cell2", 1.190 + "Column 4 spans 2 rows"]], 1.191 + expectedBraille: [["c4r2", "cell2"], ["cell2", "c4r2"]] 1.192 + }, { 1.193 + // Test pivot to table4_cell_5 from table4_cell_3. 1.194 + accOrElmOrID: "table4_cell_5", 1.195 + oldAccOrElmOrID: "table4_cell_3", 1.196 + expectedUtterance: [["Column 2 Row 3 col2 row2", "cell3"], ["cell3", 1.197 + "Column 2 Row 3 col2 row2"]], 1.198 + expectedBraille: [["c2r3 col2 row2", "cell3"], ["cell3", 1.199 + "c2r3 col2 row2"]] 1.200 + }]; 1.201 + 1.202 + SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, 0); 1.203 + 1.204 + // Test outputs (utterance and braille) for tables including their 1.205 + // headers and cells. 1.206 + tests.forEach(function run(test) { 1.207 + var outputOrderValues = [0, 1]; 1.208 + outputOrderValues.forEach(function testOutputOrder(outputOrder) { 1.209 + SpecialPowers.setIntPref(PREF_UTTERANCE_ORDER, outputOrder); 1.210 + testOutput(test.expectedUtterance[outputOrder], test.accOrElmOrID, 1.211 + test.oldAccOrElmOrID, 1); 1.212 + testOutput(test.expectedBraille[outputOrder], test.accOrElmOrID, 1.213 + test.oldAccOrElmOrID, 0); 1.214 + }); 1.215 + }); 1.216 + 1.217 + // If there was an original utterance order preference, revert to it. 1.218 + SpecialPowers.clearUserPref(PREF_UTTERANCE_ORDER); 1.219 + SimpleTest.finish(); 1.220 + } 1.221 + 1.222 + SimpleTest.waitForExplicitFinish(); 1.223 + addA11yLoadEvent(doTest); 1.224 + </script> 1.225 +</head> 1.226 +<body> 1.227 + <div id="root"> 1.228 + <a target="_blank" 1.229 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=830748" 1.230 + title="[AccessFu] Improve reading of table semantics"> 1.231 + Mozilla Bug 830748 1.232 + </a> 1.233 + <p id="display"></p> 1.234 + <div id="content" style="display: none"></div> 1.235 + <pre id="test"></pre> 1.236 + <table id="table1"> 1.237 + <thead> 1.238 + <tr> 1.239 + <th id="table1_th1">col1</th> 1.240 + <th>col2</th> 1.241 + </tr> 1.242 + </thead> 1.243 + <tbody> 1.244 + <tr> 1.245 + <td id="table1_td1">cell1</td> 1.246 + <td id="table1_td2">cell2</td> 1.247 + </tr> 1.248 + </tbody> 1.249 + </table> 1.250 + <table id="table2" border="1"> 1.251 + <tr> 1.252 + <td id="table2_cell_1" headers="table2_ch_1">cell1</td> 1.253 + <td id="table2_cell_2" headers="table2_ch_2"> 1.254 + <table id="table3"> 1.255 + <thead> 1.256 + <tr> 1.257 + <th id="table3_ch">colheader</th> 1.258 + </tr> 1.259 + </thead> 1.260 + <tbody> 1.261 + <tr> 1.262 + <td id="table3_cell">bla</td> 1.263 + </tr> 1.264 + </tbody> 1.265 + </table> 1.266 + </td> 1.267 + </tr> 1.268 + <tr> 1.269 + <td id="table2_ch_1" scope="col">col1</td> 1.270 + <td id="table2_ch_2" scope="col">col2</td> 1.271 + </tr> 1.272 + </table> 1.273 + <table id="table4" border="1"> 1.274 + <thead> 1.275 + <tr> 1.276 + <th id="table4_ch_1">col1</th> 1.277 + <th id="table4_ch_2">col2</th> 1.278 + <td id="table4_ch_3" scope="col">col3</td> 1.279 + </tr> 1.280 + </thead> 1.281 + <tbody> 1.282 + <tr> 1.283 + <th id="table4_rh_1" colspan="2">row1</th> 1.284 + <td id="table4_cell_2">cell1</td> 1.285 + <td id="table4_cell_3" rowspan="2">cell2</td> 1.286 + </tr> 1.287 + <tr> 1.288 + <td id="table4_rh_2" scope="row">row2</td> 1.289 + <td id="table4_cell_5">cell3</td> 1.290 + <td id="table4_cell_6">cell4</td> 1.291 + </tr> 1.292 + </tbody> 1.293 + </table> 1.294 + <table id="table5"> 1.295 + <tr><td>Row1</td></tr> 1.296 + <tr><td>Row2</td></tr> 1.297 + </table> 1.298 + </div> 1.299 +</body> 1.300 +</html> 1.301 \ No newline at end of file