test_brokencontext.html (6747B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>Broken context hierarchy</title> 5 <link rel="stylesheet" type="text/css" 6 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> 7 8 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 9 10 <script type="application/javascript" 11 src="../common.js"></script> 12 <script type="application/javascript" 13 src="../role.js"></script> 14 <script type="application/javascript" 15 src="../states.js"></script> 16 17 <script type="application/javascript"> 18 /** 19 * Return true if TD element has a generic accessible. 20 */ 21 function isTDGeneric(aID) { 22 return isAccessible(aID) && !isAccessible(aID, nsIAccessibleTableCell); 23 } 24 25 function checkIfNotAccessible(aID) { 26 ok(!isAccessible(aID), "'" + aID + "' shouldn't be accessible"); 27 } 28 function checkIfTDGeneric(aID) { 29 ok(isTDGeneric(aID), "'" + aID + "' shouldn't have cell accessible"); 30 } 31 32 function doTest() { 33 // ////////////////////////////////////////////////////////////////////////// 34 // HTML table elements outside table context. 35 36 // HTML table role="presentation" 37 checkIfNotAccessible("tr_in_presentation_table"); 38 checkIfTDGeneric("th_in_presentation_table"); 39 checkIfTDGeneric("td_in_presentation_table"); 40 41 // HTML table role="button" 42 var tree = 43 { PUSHBUTTON: [ // table 44 { TEXT_CONTAINER: [ // tr 45 { TEXT_CONTAINER: [ // th 46 { TEXT_LEAF: [ ] }, 47 ] }, 48 { TEXT_CONTAINER: [ // td 49 { TEXT_LEAF: [ ] }, 50 ] }, 51 ] }, 52 ] }; 53 testAccessibleTree("button_table", tree); 54 55 // ////////////////////////////////////////////////////////////////////////// 56 // HTML list elements outside list context. 57 58 ok(!isAccessible("presentation_ul"), 59 "presentational ul shouldn't be accessible"); 60 ok(isAccessible("item_in_presentation_ul"), 61 "li in presentational ul should have generic accessible"); 62 ok(isAccessible("styleditem_in_presentation_ul"), 63 "list styled span in presentational ul should have generic accessible"); 64 65 ok(!isAccessible("presentation_ol"), 66 "presentational ol shouldn't be accessible"); 67 ok(isAccessible("item_in_presentation_ol"), 68 "li in presentational ol should have generic accessible"); 69 70 ok(!isAccessible("presentation_dl"), 71 "presentational dl shouldn't be accessible"); 72 ok(!isAccessible("dt_in_presentation_dl"), 73 "dt in presentational dl shouldn't be accessible"); 74 ok(!isAccessible("dd_in_presentation_dl"), 75 "dd in presentational dl shouldn't be accessible"); 76 77 tree = 78 { PUSHBUTTON: [ // ul 79 { TEXT_CONTAINER: [ // li 80 { LISTITEM_MARKER: [ ] }, 81 { TEXT_LEAF: [ ] }, 82 ] }, 83 { TEXT_CONTAINER: [ // span styled as a list 84 { LISTITEM_MARKER: [ ] }, 85 { TEXT_LEAF: [ ] }, 86 ] }, 87 ] }; 88 testAccessibleTree("button_ul", tree); 89 90 tree = 91 { PUSHBUTTON: [ // ol 92 { TEXT_CONTAINER: [ // li 93 { LISTITEM_MARKER: [ ] }, 94 { TEXT_LEAF: [ ] }, 95 ] }, 96 ] }; 97 testAccessibleTree("button_ol", tree); 98 99 tree = 100 { PUSHBUTTON: [ // dl 101 { TEXT_CONTAINER: [ // dt 102 { TEXT_LEAF: [ ] }, 103 ] }, 104 { TEXT_CONTAINER: [ // dd 105 { TEXT_LEAF: [ ] }, 106 ] }, 107 ] }; 108 testAccessibleTree("button_dl", tree); 109 110 // ////////////////////////////////////////////////////////////////////////// 111 // Styled as HTML table elements, accessible is created by tag name 112 113 tree = 114 { LINK: [ // a 115 { TEXT_LEAF: [ ] }, 116 ] }; 117 testAccessibleTree("a_as_td", tree); 118 119 tree = 120 { HEADING: [ 121 { TEXT_LEAF: [ ] }, 122 ] }; 123 testAccessibleTree("h1_as_td", tree); 124 testAccessibleTree("h2_as_td", tree); 125 testAccessibleTree("h3_as_td", tree); 126 testAccessibleTree("h4_as_td", tree); 127 testAccessibleTree("h5_as_td", tree); 128 testAccessibleTree("h6_as_td", tree); 129 130 SimpleTest.finish(); 131 } 132 133 SimpleTest.waitForExplicitFinish(); 134 addA11yLoadEvent(doTest); 135 </script> 136 </head> 137 138 <body> 139 <a target="_blank" 140 href="https://bugzilla.mozilla.org/show_bug.cgi?id=706849" 141 title="Create accessible by tag name as fallback if table descendant style is used out of table context"> 142 Bug 706849 143 </a> 144 <a target="_blank" 145 href="https://bugzilla.mozilla.org/show_bug.cgi?id=804461" 146 title="Build the context dependent tree "> 147 Bug 804461 148 </a> 149 <a target="_blank" 150 href="https://bugzilla.mozilla.org/show_bug.cgi?id=945435" 151 title="Create generic accessible for td to not jamm the cell text"> 152 Bug 945435 153 </a> 154 <p id="display"></p> 155 <div id="content" style="display: none"></div> 156 <pre id="test"> 157 </pre> 158 159 <!-- HTML table elements out of table --> 160 <table role="presentation"> 161 <tr id="tr_in_presentation_table"> 162 <th id="th_in_presentation_table">not a header</th> 163 <td id="td_in_presentation_table">not a cell</td> 164 </tr> 165 </table> 166 167 <table role="button" id="button_table"> 168 <tr id="tr_in_button_table"> 169 <th id="th_in_button_table">not a header</th> 170 <td id="td_in_button_table">not a cell</td> 171 </tr> 172 </table> 173 174 <!-- HTML list elements out of list --> 175 <ul role="presentation" id="presentation_ul"> 176 <li id="item_in_presentation_ul">item</li> 177 <span id="styleditem_in_presentation_ul" 178 style="display:list-item">Oranges</span> 179 </ul> 180 181 <ol role="presentation" id="presentation_ol"> 182 <li id="item_in_presentation_ol">item</li> 183 </ol> 184 185 <dl role="presentation" id="presentation_dl"> 186 <dt id="dt_in_presentation_dl">term</dt> 187 <dd id="dd_in_presentation_dl">definition</dd> 188 </dl> 189 190 <ul role="button" id="button_ul"> 191 <li id="item_in_button_ul">item</li> 192 <span id="styleditem_in_button_ul" 193 style="display:list-item">Oranges</span> 194 </ul> 195 196 <ol role="button" id="button_ol"> 197 <li id="item_in_button_ul">item</li> 198 </ol> 199 200 <dl role="button" id="button_dl"> 201 <dt id="dt_in_button_dl">term</ld> 202 <dd id="dd_in_button_dl">definition</dd> 203 </dl> 204 205 <!-- styled as HTML table elements --> 206 <a id="a_as_td" style="display:table-cell;" href="http://www.google.com">Google</a> 207 <h1 id="h1_as_td" style="display: table-cell;">h1</h1> 208 <h2 id="h2_as_td" style="display: table-cell;">h2</h2> 209 <h3 id="h3_as_td" style="display: table-cell;">h3</h3> 210 <h4 id="h4_as_td" style="display: table-cell;">h4</h4> 211 <h5 id="h5_as_td" style="display: table-cell;">h5</h5> 212 <h6 id="h6_as_td" style="display: table-cell;">h6</h6> 213 </body> 214 </html>