1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/tests/mochitest/tree/test_brokencontext.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,265 @@ 1.4 +<!DOCTYPE html> 1.5 +<html> 1.6 +<head> 1.7 + <title>Broken context hierarchy</title> 1.8 + <link rel="stylesheet" type="text/css" 1.9 + href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 1.10 + 1.11 + <script type="application/javascript" 1.12 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.13 + 1.14 + <script type="application/javascript" 1.15 + src="../common.js"></script> 1.16 + <script type="application/javascript" 1.17 + src="../role.js"></script> 1.18 + <script type="application/javascript" 1.19 + src="../states.js"></script> 1.20 + 1.21 + <script type="application/javascript"> 1.22 + /** 1.23 + * Return true if TD element has a generic accessible. 1.24 + */ 1.25 + function isTDGeneric(aID) 1.26 + { 1.27 + return isAccessible(aID) && !isAccessible(aID, nsIAccessibleTableCell); 1.28 + } 1.29 + 1.30 + function checkIfNotAccessible(aID) 1.31 + { 1.32 + ok(!isAccessible(aID), "'" + aID + "' shouldn't be accessible"); 1.33 + } 1.34 + function checkIfTDGeneric(aID) 1.35 + { 1.36 + ok(isTDGeneric(aID), "'" + aID + "' shouldn't have cell accessible"); 1.37 + } 1.38 + 1.39 + function doTest() 1.40 + { 1.41 + //////////////////////////////////////////////////////////////////////////// 1.42 + // HTML table elements outside table context. 1.43 + 1.44 + // HTML table role="presentation" 1.45 + checkIfNotAccessible("tr_in_presentation_table"); 1.46 + checkIfTDGeneric("th_in_presentation_table"); 1.47 + checkIfTDGeneric("td_in_presentation_table"); 1.48 + 1.49 + // HTML table role="button" 1.50 + var tree = 1.51 + { PUSHBUTTON: [ // table 1.52 + { NOTHING: [ // tr 1.53 + { NOTHING: [ // th 1.54 + { TEXT_LEAF: [ ] } 1.55 + ] }, 1.56 + { NOTHING: [ // td 1.57 + { TEXT_LEAF: [ ] } 1.58 + ] } 1.59 + ] } 1.60 + ] }; 1.61 + testAccessibleTree("button_table", tree); 1.62 + 1.63 + // HTML table display:inline 1.64 + checkIfNotAccessible("inline_table1"); 1.65 + checkIfNotAccessible("tr_in_inline_table1"); 1.66 + checkIfTDGeneric("td1_in_inline_table1"); 1.67 + checkIfTDGeneric("td2_in_inline_table1"); 1.68 + 1.69 + // HTML table display:inline inside table. We shouldn't be fooled 1.70 + // by the outside table and shouldn't create table accessible and table cell 1.71 + // accessible in this case. 1.72 + checkIfNotAccessible("inline_table2"); 1.73 + checkIfNotAccessible("tr_in_inline_table2"); 1.74 + checkIfTDGeneric("td_in_inline_table2"); 1.75 + 1.76 + // HTML table display:block inside table. 1.77 + checkIfNotAccessible("block_table"); 1.78 + checkIfNotAccessible("tr_in_block_table"); 1.79 + checkIfTDGeneric("td_in_block_table"); 1.80 + 1.81 + //////////////////////////////////////////////////////////////////////////// 1.82 + // HTML list elements outside list context. 1.83 + 1.84 + ok(!isAccessible("presentation_ul"), 1.85 + "presentational ul shouldn't be accessible"); 1.86 + ok(!isAccessible("item_in_presentation_ul"), 1.87 + "li in presentational ul shouldn't be accessible"); 1.88 + ok(!isAccessible("styleditem_in_presentation_ul"), 1.89 + "list styled span in presentational ul shouldn't be accessible"); 1.90 + 1.91 + ok(!isAccessible("presentation_ol"), 1.92 + "presentational ol shouldn't be accessible"); 1.93 + ok(!isAccessible("item_in_presentation_ol"), 1.94 + "li in presentational ol shouldn't be accessible"); 1.95 + 1.96 + ok(!isAccessible("presentation_dl"), 1.97 + "presentational dl shouldn't be accessible"); 1.98 + ok(!isAccessible("dt_in_presentation_dl"), 1.99 + "dt in presentational dl shouldn't be accessible"); 1.100 + ok(!isAccessible("dd_in_presentation_dl"), 1.101 + "dd in presentational dl shouldn't be accessible"); 1.102 + 1.103 + tree = 1.104 + { PUSHBUTTON: [ // ul 1.105 + { NOTHING: [ // li 1.106 + { STATICTEXT: [ ] }, 1.107 + { TEXT_LEAF: [ ] } 1.108 + ] }, 1.109 + { NOTHING: [ // span styled as a list 1.110 + { STATICTEXT: [ ] }, 1.111 + { TEXT_LEAF: [ ] } 1.112 + ] } 1.113 + ] }; 1.114 + testAccessibleTree("button_ul", tree); 1.115 + 1.116 + tree = 1.117 + { PUSHBUTTON: [ // ol 1.118 + { NOTHING: [ // li 1.119 + { STATICTEXT: [ ] }, 1.120 + { TEXT_LEAF: [ ] } 1.121 + ] } 1.122 + ] }; 1.123 + testAccessibleTree("button_ol", tree); 1.124 + 1.125 + tree = 1.126 + { PUSHBUTTON: [ // dl 1.127 + { NOTHING: [ // dt 1.128 + { TEXT_LEAF: [ ] } 1.129 + ] }, 1.130 + { NOTHING: [ // dd 1.131 + { TEXT_LEAF: [ ] } 1.132 + ] } 1.133 + ] }; 1.134 + testAccessibleTree("button_dl", tree); 1.135 + 1.136 + //////////////////////////////////////////////////////////////////////////// 1.137 + // Styled as HTML table elements, accessible is created by tag name 1.138 + 1.139 + tree = 1.140 + { LINK: [ // a 1.141 + { TEXT_LEAF: [ ] } 1.142 + ] }; 1.143 + testAccessibleTree("a_as_td", tree); 1.144 + 1.145 + tree = 1.146 + { HEADING: [ 1.147 + { TEXT_LEAF: [ ] } 1.148 + ] }; 1.149 + testAccessibleTree("h1_as_td", tree); 1.150 + testAccessibleTree("h2_as_td", tree); 1.151 + testAccessibleTree("h3_as_td", tree); 1.152 + testAccessibleTree("h4_as_td", tree); 1.153 + testAccessibleTree("h5_as_td", tree); 1.154 + testAccessibleTree("h6_as_td", tree); 1.155 + 1.156 + SimpleTest.finish(); 1.157 + } 1.158 + 1.159 + SimpleTest.waitForExplicitFinish(); 1.160 + addA11yLoadEvent(doTest); 1.161 + </script> 1.162 +</head> 1.163 + 1.164 +<body> 1.165 + <a target="_blank" 1.166 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=706849" 1.167 + title="Create accessible by tag name as fallback if table descendant style is used out of table context"> 1.168 + Bug 706849 1.169 + </a> 1.170 + <a target="_blank" 1.171 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=804461" 1.172 + title="Build the context dependent tree "> 1.173 + Bug 804461 1.174 + </a> 1.175 + <a target="_blank" 1.176 + href="https://bugzilla.mozilla.org/show_bug.cgi?id=945435" 1.177 + title="Create generic accessible for td to not jamm the cell text"> 1.178 + Bug 945435 1.179 + </a> 1.180 + <p id="display"></p> 1.181 + <div id="content" style="display: none"></div> 1.182 + <pre id="test"> 1.183 + </pre> 1.184 + 1.185 + <!-- HTML table elements out of table --> 1.186 + <table role="presentation"> 1.187 + <tr id="tr_in_presentation_table"> 1.188 + <th id="th_in_presentation_table">not a header</th> 1.189 + <td id="td_in_presentation_table">not a cell</td> 1.190 + </tr> 1.191 + </table> 1.192 + 1.193 + <table role="button" id="button_table"> 1.194 + <tr id="tr_in_button_table"> 1.195 + <th id="th_in_button_table">not a header</th> 1.196 + <td id="td_in_button_table">not a cell</td> 1.197 + </tr> 1.198 + </table> 1.199 + 1.200 + <table id="inline_table1" border="1" style="display:inline"> 1.201 + <tr id="tr_in_inline_table1"> 1.202 + <td id="td1_in_inline_table1">table1 cell1</td> 1.203 + <td id="td2_in_inline_table1">table1 cell2</td> 1.204 + </tr> 1.205 + </table> 1.206 + 1.207 + <table id="table_containing_inlinetable"><tr><td> 1.208 + <table id="inline_table2" border="1" style="display:inline"> 1.209 + <tr id="tr_in_inline_table2"> 1.210 + <td id="td_in_inline_table2">cell</td> 1.211 + </tr> 1.212 + </table> 1.213 + </td></tr></table> 1.214 + 1.215 + <table> 1.216 + <tr> 1.217 + <td style="display:block"> 1.218 + <table id="block_table" style="display:inline"> 1.219 + <tr id="tr_in_block_table"> 1.220 + <td id="td_in_block_table">cell0</td> 1.221 + </tr> 1.222 + </table> 1.223 + </td> 1.224 + <td>cell1</td> 1.225 + </tr> 1.226 + </table> 1.227 + 1.228 + <!-- HTML list elements out of list --> 1.229 + <ul role="presentation" id="presentation_ul"> 1.230 + <li id="item_in_presentation_ul">item</li> 1.231 + <span id="styleditem_in_presentation_ul" 1.232 + style="display:list-item">Oranges</span> 1.233 + </ul> 1.234 + 1.235 + <ol role="presentation" id="presentation_ol"> 1.236 + <li id="item_in_presentation_ol">item</li> 1.237 + </ol> 1.238 + 1.239 + <dl role="presentation" id="presentation_dl"> 1.240 + <dt id="dt_in_presentation_dl">term</dt> 1.241 + <dd id="dd_in_presentation_dl">definition</dd> 1.242 + </dl> 1.243 + 1.244 + <ul role="button" id="button_ul"> 1.245 + <li id="item_in_button_ul">item</li> 1.246 + <span id="styleditem_in_button_ul" 1.247 + style="display:list-item">Oranges</span> 1.248 + </ul> 1.249 + 1.250 + <ol role="button" id="button_ol"> 1.251 + <li id="item_in_button_ul">item</li> 1.252 + </ol> 1.253 + 1.254 + <dl role="button" id="button_dl"> 1.255 + <dt id="dt_in_button_dl">term</ld> 1.256 + <dd id="dd_in_button_dl">definition</dd> 1.257 + </dl> 1.258 + 1.259 + <!-- styled as HTML table elements --> 1.260 + <a id="a_as_td" style="display:table-cell;" href="http://www.google.com">Google</a> 1.261 + <h1 id="h1_as_td" style="display: table-cell;">h1</h1> 1.262 + <h2 id="h2_as_td" style="display: table-cell;">h2</h2> 1.263 + <h3 id="h3_as_td" style="display: table-cell;">h3</h3> 1.264 + <h4 id="h4_as_td" style="display: table-cell;">h4</h4> 1.265 + <h5 id="h5_as_td" style="display: table-cell;">h5</h5> 1.266 + <h6 id="h6_as_td" style="display: table-cell;">h6</h6> 1.267 +</body> 1.268 +</html>