Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test updating of accessible relations</title> |
michael@0 | 5 | <link rel="stylesheet" type="text/css" |
michael@0 | 6 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 7 | |
michael@0 | 8 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="../common.js"></script> |
michael@0 | 13 | <script type="application/javascript" |
michael@0 | 14 | src="../relations.js"></script> |
michael@0 | 15 | <script type="application/javascript" |
michael@0 | 16 | src="../role.js"></script> |
michael@0 | 17 | <script type="application/javascript" |
michael@0 | 18 | src="../events.js"></script> |
michael@0 | 19 | |
michael@0 | 20 | <script type="application/javascript"> |
michael@0 | 21 | function testRelated(aRelAttr, aHostRelation, aDependentRelation, |
michael@0 | 22 | aHostID, aHostNodeID, aDependent1ID, aDependent2ID) |
michael@0 | 23 | { |
michael@0 | 24 | // no attribute |
michael@0 | 25 | testRelation(aDependent1ID, aDependentRelation, null); |
michael@0 | 26 | testRelation(aDependent2ID, aDependentRelation, null); |
michael@0 | 27 | if (aHostRelation) |
michael@0 | 28 | testRelation(aHostID, aHostRelation, null); |
michael@0 | 29 | |
michael@0 | 30 | // set attribute |
michael@0 | 31 | getNode(aHostNodeID).setAttribute(aRelAttr, aDependent1ID); |
michael@0 | 32 | testRelation(aDependent1ID, aDependentRelation, aHostID); |
michael@0 | 33 | testRelation(aDependent2ID, aDependentRelation, null); |
michael@0 | 34 | if (aHostRelation) |
michael@0 | 35 | testRelation(aHostID, aHostRelation, aDependent1ID); |
michael@0 | 36 | |
michael@0 | 37 | // change attribute |
michael@0 | 38 | getNode(aHostNodeID).setAttribute(aRelAttr, aDependent2ID); |
michael@0 | 39 | testRelation(aDependent1ID, aDependentRelation, null); |
michael@0 | 40 | testRelation(aDependent2ID, aDependentRelation, aHostID); |
michael@0 | 41 | if (aHostRelation) |
michael@0 | 42 | testRelation(aHostID, aHostRelation, aDependent2ID); |
michael@0 | 43 | |
michael@0 | 44 | // remove attribute |
michael@0 | 45 | getNode(aHostNodeID).removeAttribute(aRelAttr); |
michael@0 | 46 | testRelation(aDependent1ID, aDependentRelation, null); |
michael@0 | 47 | testRelation(aDependent2ID, aDependentRelation, null); |
michael@0 | 48 | if (aHostRelation) |
michael@0 | 49 | testRelation(aHostID, aHostRelation, null); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | function insertRelated(aHostRelAttr, aDependentID, aInsertHostFirst, |
michael@0 | 53 | aHostRelation, aDependentRelation) |
michael@0 | 54 | { |
michael@0 | 55 | this.eventSeq = [ |
michael@0 | 56 | new invokerChecker(EVENT_REORDER, document) |
michael@0 | 57 | ]; |
michael@0 | 58 | |
michael@0 | 59 | this.invoke = function insertRelated_invoke() |
michael@0 | 60 | { |
michael@0 | 61 | this.hostNode = document.createElement("div"); |
michael@0 | 62 | this.hostNode.setAttribute(aHostRelAttr, aDependentID); |
michael@0 | 63 | |
michael@0 | 64 | this.dependentNode = document.createElement("div"); |
michael@0 | 65 | this.dependentNode.setAttribute("id", aDependentID); |
michael@0 | 66 | |
michael@0 | 67 | if (aInsertHostFirst) { |
michael@0 | 68 | document.body.appendChild(this.hostNode); |
michael@0 | 69 | document.body.appendChild(this.dependentNode); |
michael@0 | 70 | } else { |
michael@0 | 71 | document.body.appendChild(this.dependentNode); |
michael@0 | 72 | document.body.appendChild(this.hostNode); |
michael@0 | 73 | } |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | this.finalCheck = function insertRelated_finalCheck() |
michael@0 | 77 | { |
michael@0 | 78 | testRelation(this.dependentNode, aDependentRelation, this.hostNode); |
michael@0 | 79 | if (aHostRelation) |
michael@0 | 80 | testRelation(this.hostNode, aHostRelation, this.dependentNode); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | this.getID = function insertRelated_getID() |
michael@0 | 84 | { |
michael@0 | 85 | return "Insert " + aHostRelAttr + "='" + aDependentID + "' node" + |
michael@0 | 86 | (aInsertHostFirst ? " before" : "after") + " dependent node"; |
michael@0 | 87 | } |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * Relative accessible recreation shouldn't break accessible relations. |
michael@0 | 92 | * Note: modify this case if the invoke function doesn't change accessible |
michael@0 | 93 | * tree due to changes in layout module. It can be changed on any case |
michael@0 | 94 | * when accessibles are recreated. |
michael@0 | 95 | */ |
michael@0 | 96 | function recreateRelatives(aContainerID, aLabelID, aElmID) |
michael@0 | 97 | { |
michael@0 | 98 | this.containerNode = getNode(aContainerID); |
michael@0 | 99 | this.container = getNode(this.containerNode); |
michael@0 | 100 | |
michael@0 | 101 | this.eventSeq = [ |
michael@0 | 102 | new invokerChecker(EVENT_HIDE, this.container), |
michael@0 | 103 | new invokerChecker(EVENT_SHOW, this.containerNode) |
michael@0 | 104 | ]; |
michael@0 | 105 | |
michael@0 | 106 | this.invoke = function recreateRelatives_invoke() |
michael@0 | 107 | { |
michael@0 | 108 | testRelation(aLabelID, RELATION_LABEL_FOR, aElmID); |
michael@0 | 109 | testRelation(aElmID, RELATION_LABELLED_BY, aLabelID); |
michael@0 | 110 | |
michael@0 | 111 | this.containerNode.style.overflow = "visible"; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | this.finalCheck = function recreateRelatives_finalCheck() |
michael@0 | 115 | { |
michael@0 | 116 | testRelation(aLabelID, RELATION_LABEL_FOR, aElmID); |
michael@0 | 117 | testRelation(aElmID, RELATION_LABELLED_BY, aLabelID); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | this.getID = function recreateRelatives_getID() |
michael@0 | 121 | { |
michael@0 | 122 | return "recreate relatives "; |
michael@0 | 123 | } |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | //gA11yEventDumpToConsole = true; // debug |
michael@0 | 127 | |
michael@0 | 128 | var gQueue = null; |
michael@0 | 129 | |
michael@0 | 130 | function doTest() |
michael@0 | 131 | { |
michael@0 | 132 | // Relation updates on ARIA attribute changes. |
michael@0 | 133 | testRelated("aria-labelledby", |
michael@0 | 134 | RELATION_LABELLED_BY, RELATION_LABEL_FOR, |
michael@0 | 135 | "host", "host", "dependent1", "dependent2"); |
michael@0 | 136 | |
michael@0 | 137 | testRelated("aria-describedby", |
michael@0 | 138 | RELATION_DESCRIBED_BY, RELATION_DESCRIPTION_FOR, |
michael@0 | 139 | "host", "host", "dependent1", "dependent2"); |
michael@0 | 140 | |
michael@0 | 141 | testRelated("aria-owns", |
michael@0 | 142 | null, RELATION_NODE_CHILD_OF, |
michael@0 | 143 | "host", "host", "dependent1", "dependent2"); |
michael@0 | 144 | |
michael@0 | 145 | testRelated("aria-controls", |
michael@0 | 146 | RELATION_CONTROLLER_FOR, RELATION_CONTROLLED_BY, |
michael@0 | 147 | "host", "host", "dependent1", "dependent2"); |
michael@0 | 148 | |
michael@0 | 149 | testRelated("aria-flowto", |
michael@0 | 150 | RELATION_FLOWS_TO, RELATION_FLOWS_FROM, |
michael@0 | 151 | "host", "host", "dependent1", "dependent2"); |
michael@0 | 152 | |
michael@0 | 153 | // Document relation updates on ARIA attribute change. |
michael@0 | 154 | testRelated("aria-labelledby", |
michael@0 | 155 | RELATION_LABELLED_BY, RELATION_LABEL_FOR, |
michael@0 | 156 | document, "body", "dependent1", "dependent2"); |
michael@0 | 157 | |
michael@0 | 158 | // Insert related accessibles into tree. |
michael@0 | 159 | gQueue = new eventQueue(); |
michael@0 | 160 | gQueue.push(new insertRelated("aria-labelledby", "dependent3", true, |
michael@0 | 161 | RELATION_LABELLED_BY, RELATION_LABEL_FOR)); |
michael@0 | 162 | gQueue.push(new insertRelated("aria-labelledby", "dependent4", false, |
michael@0 | 163 | RELATION_LABELLED_BY, RELATION_LABEL_FOR)); |
michael@0 | 164 | |
michael@0 | 165 | gQueue.push(new insertRelated("aria-describedby", "dependent5", true, |
michael@0 | 166 | RELATION_DESCRIBED_BY, |
michael@0 | 167 | RELATION_DESCRIPTION_FOR)); |
michael@0 | 168 | gQueue.push(new insertRelated("aria-describedby", "dependent6", false, |
michael@0 | 169 | RELATION_DESCRIBED_BY, |
michael@0 | 170 | RELATION_DESCRIPTION_FOR)); |
michael@0 | 171 | |
michael@0 | 172 | gQueue.push(new insertRelated("aria-owns", "dependent7", true, |
michael@0 | 173 | null, RELATION_NODE_CHILD_OF)); |
michael@0 | 174 | gQueue.push(new insertRelated("aria-owns", "dependent8", false, |
michael@0 | 175 | null, RELATION_NODE_CHILD_OF)); |
michael@0 | 176 | |
michael@0 | 177 | gQueue.push(new insertRelated("aria-controls", "dependent9", true, |
michael@0 | 178 | RELATION_CONTROLLER_FOR, |
michael@0 | 179 | RELATION_CONTROLLED_BY)); |
michael@0 | 180 | gQueue.push(new insertRelated("aria-controls", "dependent10", false, |
michael@0 | 181 | RELATION_CONTROLLER_FOR, |
michael@0 | 182 | RELATION_CONTROLLED_BY)); |
michael@0 | 183 | |
michael@0 | 184 | gQueue.push(new insertRelated("aria-flowto", "dependent11", true, |
michael@0 | 185 | RELATION_FLOWS_TO, RELATION_FLOWS_FROM)); |
michael@0 | 186 | gQueue.push(new insertRelated("aria-flowto", "dependent12", false, |
michael@0 | 187 | RELATION_FLOWS_TO, RELATION_FLOWS_FROM)); |
michael@0 | 188 | |
michael@0 | 189 | // Update relations when accessibles are recreated |
michael@0 | 190 | gQueue.push(new recreateRelatives("container", "label", "input")); |
michael@0 | 191 | |
michael@0 | 192 | gQueue.invoke(); // will call SimpleTest.finish() |
michael@0 | 193 | |
michael@0 | 194 | } |
michael@0 | 195 | |
michael@0 | 196 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 197 | addA11yLoadEvent(doTest); |
michael@0 | 198 | </script> |
michael@0 | 199 | |
michael@0 | 200 | </head> |
michael@0 | 201 | |
michael@0 | 202 | <body id="body"> |
michael@0 | 203 | |
michael@0 | 204 | <a target="_blank" |
michael@0 | 205 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=573469" |
michael@0 | 206 | title="Cache relations defined by ARIA attributes"> |
michael@0 | 207 | Mozilla Bug 573469 |
michael@0 | 208 | </a> |
michael@0 | 209 | <a target="_blank" |
michael@0 | 210 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=631068" |
michael@0 | 211 | title="Accessible recreation breaks relations"> |
michael@0 | 212 | Mozilla Bug 631068 |
michael@0 | 213 | </a> |
michael@0 | 214 | <a target="_blank" |
michael@0 | 215 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=635346" |
michael@0 | 216 | title="Allow relations for document defined on document content"> |
michael@0 | 217 | Mozilla Bug 635346 |
michael@0 | 218 | </a> |
michael@0 | 219 | <br> |
michael@0 | 220 | <p id="display"></p> |
michael@0 | 221 | <div id="content" style="display: none"></div> |
michael@0 | 222 | <pre id="test"> |
michael@0 | 223 | </pre> |
michael@0 | 224 | |
michael@0 | 225 | <div id="dependent1">label</div> |
michael@0 | 226 | <div id="dependent2">label2</div> |
michael@0 | 227 | <div role="checkbox" id="host"></div> |
michael@0 | 228 | |
michael@0 | 229 | <form id="container" style="overflow: hidden;"> |
michael@0 | 230 | <label for="input" id="label">label</label> |
michael@0 | 231 | <input id="input"> |
michael@0 | 232 | </form> |
michael@0 | 233 | </body> |
michael@0 | 234 | </html> |