accessible/tests/mochitest/relations/test_general.xul

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 4 type="text/css"?>
michael@0 5
michael@0 6 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 7 title="nsIAccessible::getAccessibleRelated() tests">
michael@0 8
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 11
michael@0 12 <script type="application/javascript"
michael@0 13 src="../common.js" />
michael@0 14 <script type="application/javascript"
michael@0 15 src="../relations.js" />
michael@0 16 <script type="application/javascript"
michael@0 17 src="../role.js" />
michael@0 18
michael@0 19 <script type="application/javascript">
michael@0 20 <![CDATA[
michael@0 21 function doTest()
michael@0 22 {
michael@0 23 // xul:label@control
michael@0 24 testRelation("label1", RELATION_LABEL_FOR, "checkbox1");
michael@0 25 testRelation("checkbox1", RELATION_LABELLED_BY, "label1");
michael@0 26
michael@0 27 // xul:label@control, multiple
michael@0 28 testRelation("label1_1", RELATION_LABEL_FOR, "checkbox1_1");
michael@0 29 testRelation("label1_2", RELATION_LABEL_FOR, "checkbox1_1");
michael@0 30 testRelation("checkbox1_1", RELATION_LABELLED_BY,
michael@0 31 [ "label1_1", "label1_2" ]);
michael@0 32
michael@0 33 // aria-labelledby
michael@0 34 testRelation("label2", RELATION_LABEL_FOR, "checkbox2");
michael@0 35 testRelation("checkbox2", RELATION_LABELLED_BY, "label2");
michael@0 36
michael@0 37 // aria-labelledby, multiple relations
michael@0 38 testRelation("label3", RELATION_LABEL_FOR, "checkbox3");
michael@0 39 testRelation("label4", RELATION_LABEL_FOR, "checkbox3");
michael@0 40 testRelation("checkbox3", RELATION_LABELLED_BY, ["label3", "label4"]);
michael@0 41
michael@0 42 // aria-describedby
michael@0 43 testRelation("descr1", RELATION_DESCRIPTION_FOR, "checkbox4");
michael@0 44 testRelation("checkbox4", RELATION_DESCRIBED_BY, "descr1");
michael@0 45
michael@0 46 // aria-describedby, multiple relations
michael@0 47 testRelation("descr2", RELATION_DESCRIPTION_FOR, "checkbox5");
michael@0 48 testRelation("descr3", RELATION_DESCRIPTION_FOR, "checkbox5");
michael@0 49 testRelation("checkbox5", RELATION_DESCRIBED_BY, ["descr2", "descr3"]);
michael@0 50
michael@0 51 // xul:description@control
michael@0 52 testRelation("descr4", RELATION_DESCRIPTION_FOR, "checkbox6");
michael@0 53 testRelation("checkbox6", RELATION_DESCRIBED_BY, "descr4");
michael@0 54
michael@0 55 // xul:description@control, multiple
michael@0 56 testRelation("descr5", RELATION_DESCRIPTION_FOR, "checkbox7");
michael@0 57 testRelation("descr6", RELATION_DESCRIPTION_FOR, "checkbox7");
michael@0 58 testRelation("checkbox7", RELATION_DESCRIBED_BY,
michael@0 59 [ "descr5", "descr6" ]);
michael@0 60
michael@0 61 // aria_owns, multiple relations
michael@0 62 testRelation("treeitem1", RELATION_NODE_CHILD_OF, "tree");
michael@0 63 testRelation("treeitem2", RELATION_NODE_CHILD_OF, "tree");
michael@0 64
michael@0 65 // 'node child of' relation for outlineitem role
michael@0 66 testRelation("treeitem3", RELATION_NODE_CHILD_OF, "tree");
michael@0 67 testRelation("treeitem4", RELATION_NODE_CHILD_OF, "tree");
michael@0 68 testRelation("treeitem5", RELATION_NODE_CHILD_OF, "treeitem4");
michael@0 69
michael@0 70 // no relation node_child_of for accessible contained in an unexpected
michael@0 71 // parent
michael@0 72 testRelation("treeitem6", RELATION_NODE_CHILD_OF, null);
michael@0 73
michael@0 74 // 'node child of' relation for the document having window, returns
michael@0 75 // direct accessible parent (fixed in bug 419770).
michael@0 76 var iframeElmObj = {};
michael@0 77 var iframeAcc = getAccessible("iframe", null, iframeElmObj);
michael@0 78 var iframeDoc = iframeElmObj.value.contentDocument;
michael@0 79 var iframeDocAcc = getAccessible(iframeDoc);
michael@0 80 testRelation(iframeDocAcc, RELATION_NODE_CHILD_OF, iframeAcc);
michael@0 81
michael@0 82 // aria-controls
michael@0 83 getAccessible("tab");
michael@0 84 todo(false,
michael@0 85 "Getting an accessible tab, otherwise relations for tabpanel aren't cached. Bug 606924 will fix that.");
michael@0 86 testRelation("tabpanel", RELATION_CONTROLLED_BY, "tab");
michael@0 87 testRelation("tab", RELATION_CONTROLLER_FOR, "tabpanel");
michael@0 88
michael@0 89 // aria-controls, multiple relations
michael@0 90 testRelation("lr1", RELATION_CONTROLLED_BY, "button");
michael@0 91 testRelation("lr2", RELATION_CONTROLLED_BY, "button");
michael@0 92 testRelation("button", RELATION_CONTROLLER_FOR, ["lr1", "lr2"]);
michael@0 93
michael@0 94 // aria-flowto
michael@0 95 testRelation("flowto", RELATION_FLOWS_TO, "flowfrom");
michael@0 96 testRelation("flowfrom", RELATION_FLOWS_FROM, "flowto");
michael@0 97
michael@0 98 // aria-flowto, multiple relations
michael@0 99 testRelation("flowto1", RELATION_FLOWS_TO, ["flowfrom1", "flowfrom2"]);
michael@0 100 testRelation("flowfrom1", RELATION_FLOWS_FROM, "flowto1");
michael@0 101 testRelation("flowfrom2", RELATION_FLOWS_FROM, "flowto1");
michael@0 102
michael@0 103 // 'default button' relation
michael@0 104 testRelation("textbox", RELATION_DEFAULT_BUTTON, "submit");
michael@0 105
michael@0 106 // 'labelled by'/'label for' relation for xul:goupbox and xul:label of
michael@0 107 // xul:caption
michael@0 108 var groupboxAcc = getAccessible("groupbox");
michael@0 109 var labelAcc = groupboxAcc.firstChild;
michael@0 110 testRelation(labelAcc, RELATION_LABEL_FOR, groupboxAcc);
michael@0 111 testRelation(groupboxAcc, RELATION_LABELLED_BY, labelAcc);
michael@0 112
michael@0 113 // 'labelled by'/'label for' relations for xul:tab and xul:tabpanel
michael@0 114 // (fixed in bug 366527)
michael@0 115 testRelation("tabpanel1", RELATION_LABELLED_BY, "tab1");
michael@0 116 testRelation("tab1", RELATION_LABEL_FOR, "tabpanel1");
michael@0 117 testRelation("tabpanel2", RELATION_LABELLED_BY, "tab2");
michael@0 118 testRelation("tab2", RELATION_LABEL_FOR, "tabpanel2");
michael@0 119 testRelation("tabpanel3", RELATION_LABELLED_BY, "tab3");
michael@0 120 testRelation("tab3", RELATION_LABEL_FOR, "tabpanel3");
michael@0 121
michael@0 122 // finish test
michael@0 123 SimpleTest.finish();
michael@0 124 }
michael@0 125
michael@0 126 SimpleTest.waitForExplicitFinish();
michael@0 127 addA11yLoadEvent(doTest);
michael@0 128 ]]>
michael@0 129 </script>
michael@0 130
michael@0 131 <vbox style="overflow: auto;" flex="1">
michael@0 132 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 133 <a target="_blank"
michael@0 134 href="https://bugzilla.mozilla.org/show_bug.cgi?id=475298"
michael@0 135 title="mochitests for accessible relations">
michael@0 136 Mozilla Bug 475298
michael@0 137 </a><br/>
michael@0 138 <a target="_blank"
michael@0 139 href="https://bugzilla.mozilla.org/show_bug.cgi?id=673389"
michael@0 140 title="node_child_of on an item not in a proper container">
michael@0 141 Mozilla Bug 67389
michael@0 142 </a><br/>
michael@0 143
michael@0 144 <p id="display"></p>
michael@0 145 <div id="content" style="display: none">
michael@0 146 </div>
michael@0 147 <pre id="test">
michael@0 148 </pre>
michael@0 149 </body>
michael@0 150
michael@0 151 <label id="label1" control="checkbox1">label</label>
michael@0 152 <checkbox id="checkbox1"/>
michael@0 153
michael@0 154 <label id="label1_1" control="checkbox1_1">label</label>
michael@0 155 <label id="label1_2" control="checkbox1_1">label</label>
michael@0 156 <checkbox id="checkbox1_1"/>
michael@0 157
michael@0 158 <description id="label2">label</description>
michael@0 159 <description role="checkbox" id="checkbox2" aria-labelledby="label2"/>
michael@0 160
michael@0 161 <description id="label3">label</description>
michael@0 162 <description id="label4">label</description>
michael@0 163 <description role="checkbox" id="checkbox3"
michael@0 164 aria-labelledby="label3 label4"/>
michael@0 165
michael@0 166 <description id="descr1">description</description>
michael@0 167 <description role="checkbox" id="checkbox4" aria-describedby="descr1"/>
michael@0 168
michael@0 169 <description id="descr2">label</description>
michael@0 170 <description id="descr3">label</description>
michael@0 171 <description role="checkbox" id="checkbox5"
michael@0 172 aria-describedby="descr2 descr3"/>
michael@0 173
michael@0 174 <description id="descr4" control="checkbox6">description</description>
michael@0 175 <checkbox id="checkbox6"/>
michael@0 176
michael@0 177 <description id="descr5" control="checkbox7">description</description>
michael@0 178 <description id="descr6" control="checkbox7">description</description>
michael@0 179 <checkbox id="checkbox7"/>
michael@0 180
michael@0 181 <description role="treeitem" id="treeitem1">Yellow</description>
michael@0 182 <description role="treeitem" id="treeitem2">Orange</description>
michael@0 183 <vbox id="tree" role="tree" aria-owns="treeitem1 treeitem2">
michael@0 184 <description role="treeitem" id="treeitem3">Blue</description>
michael@0 185 <description role="treeitem" id="treeitem4" aria-level="1">Green</description>
michael@0 186 <description role="treeitem" id="treeitem5" aria-level="2">Light green</description>
michael@0 187 </vbox>
michael@0 188
michael@0 189 <description role="treeitem" id="treeitem6">Dark green</description>
michael@0 190
michael@0 191 <iframe id="iframe"/>
michael@0 192
michael@0 193 <hbox id="tablist" role="tablist">
michael@0 194 <description id="tab" role="tab" aria-controls="tabpanel">tab</description>
michael@0 195 </hbox>
michael@0 196 <description id="tabpanel" role="tabpanel">tabpanel</description>
michael@0 197
michael@0 198 <description id="lr1" aria-live="assertive">1</description>
michael@0 199 <description id="lr2" aria-live="assertive">a</description>
michael@0 200 <button id="button" aria-controls="lr1 lr2" label="button"
michael@0 201 oncommand="getNode('lr1').textContent += '1'; getNode('lr2').textContent += 'a';"/>
michael@0 202
michael@0 203 <description id="flowto1" aria-flowto="flowfrom1 flowfrom2">flow to</description>
michael@0 204 <description id="flowfrom1">flow from</description>
michael@0 205 <description id="flowfrom2">flow from</description>
michael@0 206
michael@0 207 <description id="flowto" aria-flowto="flowfrom">flow to</description>
michael@0 208 <description id="flowfrom">flow from</description>
michael@0 209
michael@0 210 <textbox id="textbox"/>
michael@0 211 <button id="submit" default="true" label="Default"/>
michael@0 212
michael@0 213 <groupbox id="groupbox">
michael@0 214 <caption label="caption"/>
michael@0 215 </groupbox>
michael@0 216
michael@0 217 <tabbox>
michael@0 218 <tabs>
michael@0 219 <tab label="tab1" id="tab1"/>
michael@0 220 <tab label="tab2" id="tab2" linkedpanel="tabpanel2"/>
michael@0 221 <tab label="tab3" id="tab3" linkedpanel="tabpanel3"/>
michael@0 222 </tabs>
michael@0 223 <tabpanels>
michael@0 224 <tabpanel id="tabpanel1">
michael@0 225 <description>tabpanel1</description>
michael@0 226 </tabpanel>
michael@0 227 <tabpanel id="tabpanel3">
michael@0 228 <description>tabpanel3</description>
michael@0 229 </tabpanel>
michael@0 230 <tabpanel id="tabpanel2">
michael@0 231 <description>tabpanel2</description>
michael@0 232 </tabpanel>
michael@0 233 </tabpanels>
michael@0 234 </tabbox>
michael@0 235
michael@0 236 </vbox>
michael@0 237 </window>
michael@0 238

mercurial