accessible/tests/mochitest/relations/test_general.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/accessible/tests/mochitest/relations/test_general.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,400 @@
     1.4 +<html>
     1.5 +
     1.6 +<head>
     1.7 +  <title>nsIAccessible::getAccessibleRelated() tests</title>
     1.8 +  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
     1.9 +
    1.10 +  <script type="application/javascript"
    1.11 +          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +
    1.13 +  <script type="application/javascript"
    1.14 +          src="../common.js"></script>
    1.15 +  <script type="application/javascript"
    1.16 +          src="../relations.js"></script>
    1.17 +  <script type="application/javascript"
    1.18 +          src="../role.js"></script>
    1.19 +
    1.20 +  <script type="application/javascript">
    1.21 +    function doTest()
    1.22 +    {
    1.23 +      // html:label@for
    1.24 +      testRelation("label1_1", RELATION_LABEL_FOR, "control1_1");
    1.25 +      testRelation("control1_1", RELATION_LABELLED_BY, "label1_1");
    1.26 +
    1.27 +      // html:label@for, multiple
    1.28 +      testRelation("label1_2", RELATION_LABEL_FOR, "control1_2");
    1.29 +      testRelation("label1_3", RELATION_LABEL_FOR, "control1_2");
    1.30 +      testRelation("control1_2", RELATION_LABELLED_BY,
    1.31 +                   [ "label1_2", "label1_3" ]);
    1.32 +
    1.33 +      // ancestor html:label (implicit association)
    1.34 +      testRelation("label1_4", RELATION_LABEL_FOR, "control1_4");
    1.35 +      testRelation("control1_4", RELATION_LABELLED_BY, "label1_4");
    1.36 +      testRelation("control1_4_option1", RELATION_LABELLED_BY, null);
    1.37 +      testRelation("label1_5", RELATION_LABEL_FOR, "control1_5");
    1.38 +      testRelation("control1_5", RELATION_LABELLED_BY, "label1_5");
    1.39 +      testRelation("label1_6", RELATION_LABEL_FOR, "control1_6");
    1.40 +      testRelation("control1_6", RELATION_LABELLED_BY, "label1_6");
    1.41 +      testRelation("label1_7", RELATION_LABEL_FOR, "control1_7");
    1.42 +      testRelation("control1_7", RELATION_LABELLED_BY, "label1_7");
    1.43 +      testRelation("label1_8", RELATION_LABEL_FOR, "control1_8");
    1.44 +      testRelation("control1_8", RELATION_LABELLED_BY, "label1_8");
    1.45 +      testRelation("label1_9", RELATION_LABEL_FOR, "control1_9");
    1.46 +      testRelation("control1_9", RELATION_LABELLED_BY, "label1_9");
    1.47 +      testRelation("label1_10", RELATION_LABEL_FOR, "control1_10");
    1.48 +      testRelation("control1_10", RELATION_LABELLED_BY, "label1_10");
    1.49 +      testRelation("label1_11", RELATION_LABEL_FOR, "control1_11");
    1.50 +      testRelation("control1_11", RELATION_LABELLED_BY, "label1_11");
    1.51 +      testRelation("label1_12", RELATION_LABEL_FOR, "control1_12");
    1.52 +      testRelation("control1_12", RELATION_LABELLED_BY, "label1_12");
    1.53 +
    1.54 +      testRelation("label1_13", RELATION_LABEL_FOR, null);
    1.55 +      testRelation("control1_13", RELATION_LABELLED_BY, null);
    1.56 +      testRelation("control1_14", RELATION_LABELLED_BY, "label1_14");
    1.57 +
    1.58 +      // aria-labelledby
    1.59 +      testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
    1.60 +      testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
    1.61 +
    1.62 +      // aria-labelledby, multiple relations
    1.63 +      testRelation("label3", RELATION_LABEL_FOR, "checkbox3");
    1.64 +      testRelation("label4", RELATION_LABEL_FOR, "checkbox3");
    1.65 +      testRelation("checkbox3", RELATION_LABELLED_BY, ["label3", "label4"]);
    1.66 +
    1.67 +      // aria-describedby
    1.68 +      testRelation("descr1", RELATION_DESCRIPTION_FOR, "checkbox4");
    1.69 +      testRelation("checkbox4", RELATION_DESCRIBED_BY, "descr1");
    1.70 +
    1.71 +      // aria-describedby, multiple relations
    1.72 +      testRelation("descr2", RELATION_DESCRIPTION_FOR, "checkbox5");
    1.73 +      testRelation("descr3", RELATION_DESCRIPTION_FOR, "checkbox5");
    1.74 +      testRelation("checkbox5", RELATION_DESCRIBED_BY, ["descr2", "descr3"]);
    1.75 +
    1.76 +      // aria_owns, multiple relations
    1.77 +      testRelation("treeitem1", RELATION_NODE_CHILD_OF, "tree");
    1.78 +      testRelation("treeitem2", RELATION_NODE_CHILD_OF, "tree");
    1.79 +
    1.80 +      // 'node child of' relation for outlineitem role
    1.81 +      testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree");
    1.82 +      testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree");
    1.83 +      testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4");
    1.84 +      testRelation("treeitem6", RELATION_NODE_CHILD_OF, "tree");
    1.85 +      testRelation("treeitem7", RELATION_NODE_CHILD_OF, "treeitem6");
    1.86 +      testRelation("tree2_ti1", RELATION_NODE_CHILD_OF, "tree2");
    1.87 +      testRelation("tree2_ti1a", RELATION_NODE_CHILD_OF, "tree2_ti1");
    1.88 +      testRelation("tree2_ti1b", RELATION_NODE_CHILD_OF, "tree2_ti1");
    1.89 +
    1.90 +      // 'node child of' relation for row role in grid.
    1.91 +      // Relation for row associated using aria-owns should exist.
    1.92 +      testRelation("simplegrid-ownrow", RELATION_NODE_CHILD_OF, "simplegrid");
    1.93 +      // Relation for row associated using aria-level should exist.
    1.94 +      testRelation("simplegrid-row3", RELATION_NODE_CHILD_OF,
    1.95 +                   "simplegrid-row2");
    1.96 +      // Relations for hierarchical children elements shouldn't exist.
    1.97 +      testAbsentRelation("simplegrid-row1", RELATION_NODE_CHILD_OF,
    1.98 +                         "simplegrid");
    1.99 +      testAbsentRelation("simplegrid-row2", RELATION_NODE_CHILD_OF,
   1.100 +                         "simplegrid");
   1.101 +
   1.102 +      // 'node child of' relation for row role of treegrid
   1.103 +      testRelation("treegridrow1", RELATION_NODE_CHILD_OF, "treegrid");
   1.104 +      testRelation("treegridrow2", RELATION_NODE_CHILD_OF, "treegrid");
   1.105 +      testRelation("treegridrow3", RELATION_NODE_CHILD_OF, "treegridrow2");
   1.106 +
   1.107 +      // 'node child of' relation for lists organized by groups
   1.108 +      testRelation("listitem1", RELATION_NODE_CHILD_OF, "list");
   1.109 +      testRelation("listitem1.1", RELATION_NODE_CHILD_OF, "listitem1");
   1.110 +      testRelation("listitem1.2", RELATION_NODE_CHILD_OF, "listitem1");
   1.111 +
   1.112 +      // 'node child of' relation for the document having window, returns
   1.113 +      // direct accessible parent (fixed in bug 419770).
   1.114 +      var iframeElmObj = {};
   1.115 +      var iframeAcc = getAccessible("iframe", null, iframeElmObj);
   1.116 +      var iframeDoc = iframeElmObj.value.contentDocument;
   1.117 +      var iframeDocAcc = getAccessible(iframeDoc);
   1.118 +      testRelation(iframeDocAcc, RELATION_NODE_CHILD_OF, iframeAcc);
   1.119 +
   1.120 +      // 'node parent of' relation on ARIA tree and treegrid.
   1.121 +      testRelation("tree", RELATION_NODE_PARENT_OF,
   1.122 +                    ["treeitem1", "treeitem2", // aria-owns
   1.123 +                     "treeitem3", "treeitem4", "treeitem6"]); // children
   1.124 +      testRelation("treeitem4", RELATION_NODE_PARENT_OF,
   1.125 +                   "treeitem5"); // aria-level
   1.126 +      testRelation("treeitem6", RELATION_NODE_PARENT_OF,
   1.127 +                   "treeitem7"); // // group role
   1.128 +      testRelation("tree2", RELATION_NODE_PARENT_OF, "tree2_ti1"); // group role
   1.129 +      testRelation("tree2_ti1", RELATION_NODE_PARENT_OF,
   1.130 +                   ["tree2_ti1a", "tree2_ti1b"]); // group role
   1.131 +
   1.132 +      testRelation("treegridrow2", RELATION_NODE_PARENT_OF, "treegridrow3");
   1.133 +      testRelation("treegrid", RELATION_NODE_PARENT_OF,
   1.134 +                   ["treegridrow1", "treegridrow2"]);
   1.135 +
   1.136 +      // 'node parent of' relation on ARIA grid.
   1.137 +      // Should only have relation to child added through aria-owns.
   1.138 +      testRelation("simplegrid", RELATION_NODE_PARENT_OF, "simplegrid-ownrow");
   1.139 +      // 'node parent of' relation on ARIA grid's row.
   1.140 +      // Should only have relation to child through aria-level.
   1.141 +      testRelation("simplegrid-row2", RELATION_NODE_PARENT_OF,
   1.142 +                   "simplegrid-row3");
   1.143 +
   1.144 +      // 'node parent of' relation on ARIA list structured by groups
   1.145 +      testRelation("list", RELATION_NODE_PARENT_OF,
   1.146 +                   "listitem1");
   1.147 +      testRelation("listitem1", RELATION_NODE_PARENT_OF,
   1.148 +                   [ "listitem1.1", "listitem1.2" ]);
   1.149 +
   1.150 +      // aria-atomic
   1.151 +      testRelation(getNode("atomic").firstChild, RELATION_MEMBER_OF, "atomic");
   1.152 +
   1.153 +      // aria-controls
   1.154 +      getAccessible("tab");
   1.155 +      todo(false,
   1.156 +           "Getting an accessible tab, otherwise relations for tabpanel aren't cached. Bug 606924 will fix that.");
   1.157 +      testRelation("tabpanel", RELATION_CONTROLLED_BY, "tab");
   1.158 +      testRelation("tab", RELATION_CONTROLLER_FOR, "tabpanel");
   1.159 +
   1.160 +      // aria-controls, multiple relations
   1.161 +      testRelation("lr1", RELATION_CONTROLLED_BY, "button");
   1.162 +      testRelation("lr2", RELATION_CONTROLLED_BY, "button");
   1.163 +      testRelation("button", RELATION_CONTROLLER_FOR, ["lr1", "lr2"]);
   1.164 +
   1.165 +      // aria-flowto
   1.166 +      testRelation("flowto", RELATION_FLOWS_TO, "flowfrom");
   1.167 +      testRelation("flowfrom", RELATION_FLOWS_FROM, "flowto");
   1.168 +
   1.169 +      // aria-flowto, multiple relations
   1.170 +      testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]);
   1.171 +      testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1");
   1.172 +      testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1");
   1.173 +
   1.174 +      // 'default button' relation
   1.175 +      testRelation("input", RELATION_DEFAULT_BUTTON, "submit");
   1.176 +
   1.177 +      // output 'for' relations
   1.178 +      testRelation("output", RELATION_CONTROLLED_BY, ["input", "input2"]);
   1.179 +      testRelation("output2", RELATION_CONTROLLED_BY, ["input", "input2"]);
   1.180 +      testRelation("input", RELATION_CONTROLLER_FOR, ["output", "output2"]);
   1.181 +      testRelation("input2", RELATION_CONTROLLER_FOR, ["output", "output2"]);
   1.182 +
   1.183 +      // 'described by'/'description for' relation for html:table and
   1.184 +      // html:caption
   1.185 +      testRelation("caption", RELATION_LABEL_FOR, "table");
   1.186 +      testRelation("table", RELATION_LABELLED_BY, "caption");
   1.187 +
   1.188 +      // 'labelled by'/'label for' relation for html:fieldset and
   1.189 +      // html:legend
   1.190 +      testRelation("legend", RELATION_LABEL_FOR, "fieldset");
   1.191 +      testRelation("fieldset", RELATION_LABELLED_BY, "legend");
   1.192 +
   1.193 +      // containing relations
   1.194 +      testRelation("control1_1", RELATION_CONTAINING_DOCUMENT, document);
   1.195 +      testRelation("control1_1", RELATION_CONTAINING_TAB_PANE, getTabDocAccessible("control1_1"));
   1.196 +      testRelation("control1_1", RELATION_CONTAINING_APPLICATION, getApplicationAccessible());
   1.197 +
   1.198 +      // finish test
   1.199 +      SimpleTest.finish();
   1.200 +    }
   1.201 +
   1.202 +    disableLogging(); // from test_embeds.xul
   1.203 +    SimpleTest.waitForExplicitFinish();
   1.204 +    addA11yLoadEvent(doTest);
   1.205 +  </script>
   1.206 +
   1.207 +</head>
   1.208 +
   1.209 +<body>
   1.210 +
   1.211 +  <a target="_blank"
   1.212 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=475298"
   1.213 +     title="mochitests for accessible relations">
   1.214 +    Bug 475298
   1.215 +  </a>
   1.216 +  <a target="_blank"
   1.217 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=527461"
   1.218 +     title="Implement RELATION_NODE_PARENT_OF">
   1.219 +    Bug 527461
   1.220 +  </a>
   1.221 +  <a target="_blank"
   1.222 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=558036"
   1.223 +     title="make HTML <output> accessible">
   1.224 +    Bug 558036
   1.225 +  </a>
   1.226 +  <a target="_blank"
   1.227 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=682790"
   1.228 +     title="Ignore implicit label association when it's associated explicitly">
   1.229 +    Bug 682790
   1.230 +  </a>
   1.231 +  <a target="_blank"
   1.232 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=687393"
   1.233 +     title="HTML select options gets relation from containing label">
   1.234 +    Bug 687393
   1.235 +  </a>
   1.236 +  <a target="_blank"
   1.237 +     href="https://bugzilla.mozilla.org/show_bug.cgi?id=864224"
   1.238 +     title="Support nested ARIA listitems structured by role='group'">
   1.239 +    Bug 864224
   1.240 +  </a>
   1.241 +  <p id="display"></p>
   1.242 +  <div id="content" style="display: none"></div>
   1.243 +  <pre id="test">
   1.244 +  </pre>
   1.245 +
   1.246 +  <label id="label1_1" for="control1_1">label</label>
   1.247 +  <input id="control1_1">
   1.248 +
   1.249 +  <label id="label1_2" for="control1_2">label</label>
   1.250 +  <label id="label1_3" for="control1_2">label</label>
   1.251 +  <input id="control1_2">
   1.252 +
   1.253 +  <label id="label1_4">Label
   1.254 +    <select id="control1_4">
   1.255 +      <option id="control1_4_option1">option</option>
   1.256 +    </select>
   1.257 +  </label>
   1.258 +  <label id="label1_5">Label
   1.259 +    <button id="control1_5">button</button>
   1.260 +  </label>
   1.261 +  <label id="label1_6">Label
   1.262 +    <input id="control1_6">
   1.263 +  </label>
   1.264 +  <label id="label1_7">Label
   1.265 +    <input id="control1_7" type="checkbox">
   1.266 +  </label>
   1.267 +  <label id="label1_8">Label
   1.268 +    <input id="control1_8" type="radio">
   1.269 +  </label>
   1.270 +  <label id="label1_9">Label
   1.271 +    <input id="control1_9" type="button" value="button">
   1.272 +  </label>
   1.273 +  <label id="label1_10">Label
   1.274 +    <input id="control1_10" type="submit">
   1.275 +  </label>
   1.276 +  <label id="label1_11">Label
   1.277 +    <input id="control1_11" type="image">
   1.278 +  </label>
   1.279 +  <label id="label1_12">Label
   1.280 +    <progress id="control1_12"></progress>
   1.281 +  </label>
   1.282 +
   1.283 +  <label id="label1_13" for="">Label
   1.284 +    <input id="control1_13">
   1.285 +  </label>
   1.286 +  <label id="label1_14" for="control1_14">Label
   1.287 +    <input id="control1_14">
   1.288 +  </label>
   1.289 +
   1.290 +  <span id="label2">label</span>
   1.291 +  <span role="checkbox" id="checkbox2" aria-labelledby="label2"></span>
   1.292 +
   1.293 +  <span id="label3">label1</span>
   1.294 +  <span id="label4">label2</span>
   1.295 +  <span role="checkbox" id="checkbox3" aria-labelledby="label3 label4"></span>
   1.296 +
   1.297 +  <span id="descr1">description</span>
   1.298 +  <span role="checkbox" id="checkbox4" aria-describedby="descr1"></span>
   1.299 +
   1.300 +  <span id="descr2">description1</span>
   1.301 +  <span id="descr3">description2</span>
   1.302 +  <span role="checkbox" id="checkbox5" aria-describedby="descr2 descr3"></span>
   1.303 +
   1.304 +  <div role="treeitem" id="treeitem1">Yellow</div>
   1.305 +  <div role="treeitem" id="treeitem2">Orange</div>
   1.306 +  <div id="tree" role="tree" aria-owns="treeitem1 treeitem2">
   1.307 +    <div role="treeitem" id="treeitem3">Blue</div>
   1.308 +    <div role="treeitem" id="treeitem4" aria-level="1">Green</div>
   1.309 +    <div role="treeitem" id="treeitem5" aria-level="2">Light green</div>
   1.310 +    <div role="treeitem" id="treeitem6" aria-level="1">Green2</div>
   1.311 +    <div role="group">
   1.312 +      <div role="treeitem" id="treeitem7">Super light green</div>
   1.313 +    </div>
   1.314 +  </div>
   1.315 +
   1.316 +  <div aria-owns="simplegrid-ownrow" role="grid" id="simplegrid">
   1.317 +    <div role="row" id="simplegrid-row1" aria-level="1">
   1.318 +      <div role="gridcell">cell 1,1</div>
   1.319 +      <div role="gridcell">cell 1,2</div>
   1.320 +    </div>
   1.321 +    <div role="row" id="simplegrid-row2" aria-level="1">
   1.322 +      <div role="gridcell">cell 2,1</div>
   1.323 +      <div role="gridcell">cell 2,2</div>
   1.324 +    </div>
   1.325 +    <div role="row" id="simplegrid-row3" aria-level="2">
   1.326 +      <div role="gridcell">cell 3,1</div>
   1.327 +      <div role="gridcell">cell 3,2</div>
   1.328 +    </div>
   1.329 +  </div>
   1.330 +  <div role="row" id="simplegrid-ownrow"></div>
   1.331 +
   1.332 +  <ul role="tree" id="tree2">
   1.333 +    <li role="treeitem" id="tree2_ti1">Item 1
   1.334 +      <ul role="group">
   1.335 +        <li role="treeitem" id="tree2_ti1a">Item 1A</li>
   1.336 +        <li role="treeitem" id="tree2_ti1b">Item 1B</li>
   1.337 +      </ul>
   1.338 +    </li>
   1.339 +  </ul>
   1.340 +
   1.341 +  <div role="treegrid" id="treegrid">
   1.342 +    <div role="row" id="treegridrow1">
   1.343 +      <span role="gridcell">cell1</span><span role="gridcell">cell2</span>
   1.344 +    </div>
   1.345 +    <div role="row" id="treegridrow2" aria-level="1">
   1.346 +      <span role="gridcell">cell3</span><span role="gridcell">cell4</span>
   1.347 +    </div>
   1.348 +    <div role="row" id="treegridrow3" aria-level="2">
   1.349 +      <span role="gridcell">cell5</span><span role="gridcell">cell6</span>
   1.350 +    </div>
   1.351 +  </div>
   1.352 +
   1.353 +  <div role="list" id="list">
   1.354 +    <div role="listitem" id="listitem1">Item 1
   1.355 +      <div role="group">
   1.356 +        <div role="listitem" id="listitem1.1">Item 1A</div>
   1.357 +        <div role="listitem" id="listitem1.2">Item 1B</div>
   1.358 +      </div>
   1.359 +    </div>
   1.360 +  </div>
   1.361 +
   1.362 +  <iframe id="iframe"></iframe>
   1.363 +
   1.364 +  <div id="tablist" role="tablist">
   1.365 +    <div id="tab" role="tab" aria-controls="tabpanel">tab</div>
   1.366 +  </div>
   1.367 +  <div id="tabpanel" role="tabpanel">tabpanel</div>
   1.368 +
   1.369 +  <div id="lr1" aria-live="assertive">1</div>
   1.370 +  <div id="lr2" aria-live="assertive">a</div>
   1.371 +  <input type="button" id="button" aria-controls="lr1 lr2"
   1.372 +         onclick="getNode('lr1').textContent += '1'; getNode('lr2').textContent += 'a';"/>
   1.373 +
   1.374 +  <div id="atomic" aria-atomic="true">live region</div>
   1.375 +
   1.376 +  <span id="flowto" aria-flowto="flowfrom">flow to</span>
   1.377 +  <span id="flowfrom">flow from</span>
   1.378 +
   1.379 +  <span id="flowto1" aria-flowto="flowfrom1 flowfrom2">flow to</span>
   1.380 +  <span id="flowfrom1">flow from</span>
   1.381 +  <span id="flowfrom2">flow from</span>
   1.382 +
   1.383 +  <form id="form">
   1.384 +    <input id="input" />
   1.385 +    <input id="input2" />
   1.386 +    <input type="submit" id="submit" />
   1.387 +    <output id="output" style="display:block" for="input input2"></output>
   1.388 +    <output id="output2" for="input input2"></output>
   1.389 +  </form>
   1.390 +
   1.391 +  <table id="table">
   1.392 +    <caption id="caption">tabple caption</caption>
   1.393 +    <tr>
   1.394 +      <td>cell1</td><td>cell2</td>
   1.395 +    </tr>
   1.396 +  </table>
   1.397 +
   1.398 +  <fieldset id="fieldset">
   1.399 +    <legend id="legend">legend</legend>
   1.400 +    <input />
   1.401 +  </fieldset>
   1.402 +</body>
   1.403 +</html>

mercurial