Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | <html> |
michael@0 | 2 | |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Accessible state change event testing</title> |
michael@0 | 5 | |
michael@0 | 6 | <link rel="stylesheet" type="text/css" |
michael@0 | 7 | href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
michael@0 | 8 | |
michael@0 | 9 | <script type="application/javascript" |
michael@0 | 10 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 11 | |
michael@0 | 12 | <script type="application/javascript" |
michael@0 | 13 | src="../common.js"></script> |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="../events.js"></script> |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="../role.js"></script> |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="../states.js"></script> |
michael@0 | 20 | |
michael@0 | 21 | <script type="application/javascript"> |
michael@0 | 22 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 23 | // Invokers |
michael@0 | 24 | |
michael@0 | 25 | function makeEditableDoc(aDocNode, aIsEnabled) |
michael@0 | 26 | { |
michael@0 | 27 | this.DOMNode = aDocNode; |
michael@0 | 28 | |
michael@0 | 29 | this.invoke = function editabledoc_invoke() { |
michael@0 | 30 | // Note: this should fire an EVENT_STATE_CHANGE |
michael@0 | 31 | this.DOMNode.designMode = 'on'; |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | this.check = function editabledoc_check(aEvent) { |
michael@0 | 35 | |
michael@0 | 36 | testStates(aDocNode, 0, EXT_STATE_EDITABLE); |
michael@0 | 37 | |
michael@0 | 38 | var event = null; |
michael@0 | 39 | try { |
michael@0 | 40 | var event = aEvent.QueryInterface(nsIAccessibleStateChangeEvent); |
michael@0 | 41 | } catch (e) { |
michael@0 | 42 | ok(false, "State change event was expected"); |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | if (!event) { return; } |
michael@0 | 46 | |
michael@0 | 47 | ok(event.isExtraState, "Extra state change was expected"); |
michael@0 | 48 | is(event.state, EXT_STATE_EDITABLE, "Wrong state of statechange event"); |
michael@0 | 49 | ok(event.isEnabled, "Expected editable state to be enabled"); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | this.getID = function editabledoc_getID() { |
michael@0 | 53 | return prettyName(aDocNode) + " editable state changed"; |
michael@0 | 54 | }; |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | function invalidInput(aNodeOrID) |
michael@0 | 58 | { |
michael@0 | 59 | this.DOMNode = getNode(aNodeOrID); |
michael@0 | 60 | |
michael@0 | 61 | this.invoke = function invalidInput_invoke() { |
michael@0 | 62 | // Note: this should fire an EVENT_STATE_CHANGE |
michael@0 | 63 | this.DOMNode.value = "I am not an email"; |
michael@0 | 64 | }; |
michael@0 | 65 | |
michael@0 | 66 | this.check = function invalidInput_check() { |
michael@0 | 67 | testStates(aNodeOrID, STATE_INVALID); |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | this.getID = function invalidInput_getID() { |
michael@0 | 71 | return prettyName(aNodeOrID) + " became invalid"; |
michael@0 | 72 | }; |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | function changeCheckInput(aID, aIsChecked) |
michael@0 | 76 | { |
michael@0 | 77 | this.DOMNode = getNode(aID); |
michael@0 | 78 | |
michael@0 | 79 | this.eventSeq = [ |
michael@0 | 80 | new stateChangeChecker(STATE_CHECKED, false, aIsChecked, this.DOMNode) |
michael@0 | 81 | ]; |
michael@0 | 82 | |
michael@0 | 83 | this.invoke = function changeCheckInput_invoke() |
michael@0 | 84 | { |
michael@0 | 85 | this.DOMNode.checked = aIsChecked; |
michael@0 | 86 | } |
michael@0 | 87 | |
michael@0 | 88 | this.getID = function changeCheckInput_getID() |
michael@0 | 89 | { |
michael@0 | 90 | return "change checked state to '" + aIsChecked + "' for " + |
michael@0 | 91 | prettyName(aID); |
michael@0 | 92 | } |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | function stateChangeOnFileInput(aID, aAttr, aValue, |
michael@0 | 96 | aState, aIsExtraState, aIsEnabled) |
michael@0 | 97 | { |
michael@0 | 98 | this.fileControlNode = getNode(aID); |
michael@0 | 99 | this.fileControl = getAccessible(this.fileControlNode); |
michael@0 | 100 | this.browseButton = this.fileControl.firstChild; |
michael@0 | 101 | // No state change events on the label. |
michael@0 | 102 | |
michael@0 | 103 | this.invoke = function stateChangeOnFileInput_invoke() |
michael@0 | 104 | { |
michael@0 | 105 | this.fileControlNode.setAttribute(aAttr, aValue); |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | this.eventSeq = [ |
michael@0 | 109 | new stateChangeChecker(aState, aIsExtraState, aIsEnabled, this.fileControl), |
michael@0 | 110 | new stateChangeChecker(aState, aIsExtraState, aIsEnabled, this.browseButton) |
michael@0 | 111 | ]; |
michael@0 | 112 | |
michael@0 | 113 | this.getID = function stateChangeOnFileInput_getID() |
michael@0 | 114 | { |
michael@0 | 115 | return "inherited state change on file input on attribute '" + aAttr + "' change"; |
michael@0 | 116 | } |
michael@0 | 117 | } |
michael@0 | 118 | |
michael@0 | 119 | function dupeStateChange(aID, aAttr, aValue, |
michael@0 | 120 | aState, aIsExtraState, aIsEnabled) |
michael@0 | 121 | { |
michael@0 | 122 | this.eventSeq = [ |
michael@0 | 123 | new stateChangeChecker(aState, aIsExtraState, aIsEnabled, getNode(aID)) |
michael@0 | 124 | ]; |
michael@0 | 125 | |
michael@0 | 126 | this.invoke = function dupeStateChange_invoke() |
michael@0 | 127 | { |
michael@0 | 128 | getNode(aID).setAttribute(aAttr, aValue); |
michael@0 | 129 | getNode(aID).setAttribute(aAttr, aValue); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | this.getID = function dupeStateChange_getID() |
michael@0 | 133 | { |
michael@0 | 134 | return "duped state change events"; |
michael@0 | 135 | } |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | function oppositeStateChange(aID, aAttr, aState, aIsExtraState) |
michael@0 | 139 | { |
michael@0 | 140 | this.eventSeq = [ ]; |
michael@0 | 141 | this.unexpectedEventSeq = [ |
michael@0 | 142 | new stateChangeChecker(aState, aIsExtraState, false, getNode(aID)), |
michael@0 | 143 | new stateChangeChecker(aState, aIsExtraState, true, getNode(aID)) |
michael@0 | 144 | ]; |
michael@0 | 145 | |
michael@0 | 146 | this.invoke = function oppositeStateChange_invoke() |
michael@0 | 147 | { |
michael@0 | 148 | getNode(aID).setAttribute(aAttr, "false"); |
michael@0 | 149 | getNode(aID).setAttribute(aAttr, "true"); |
michael@0 | 150 | } |
michael@0 | 151 | |
michael@0 | 152 | this.getID = function oppositeStateChange_getID() |
michael@0 | 153 | { |
michael@0 | 154 | return "opposite state change events"; |
michael@0 | 155 | } |
michael@0 | 156 | } |
michael@0 | 157 | |
michael@0 | 158 | /** |
michael@0 | 159 | * Change concomitant ARIA and native attribute at once. |
michael@0 | 160 | */ |
michael@0 | 161 | function echoingStateChange(aID, aARIAAttr, aAttr, aValue, |
michael@0 | 162 | aState, aIsExtraState, aIsEnabled) |
michael@0 | 163 | { |
michael@0 | 164 | this.eventSeq = [ |
michael@0 | 165 | new stateChangeChecker(aState, aIsExtraState, aIsEnabled, getNode(aID)) |
michael@0 | 166 | ]; |
michael@0 | 167 | |
michael@0 | 168 | this.invoke = function echoingStateChange_invoke() |
michael@0 | 169 | { |
michael@0 | 170 | if (aValue == null) { |
michael@0 | 171 | getNode(aID).removeAttribute(aARIAAttr); |
michael@0 | 172 | getNode(aID).removeAttribute(aAttr); |
michael@0 | 173 | |
michael@0 | 174 | } else { |
michael@0 | 175 | getNode(aID).setAttribute(aARIAAttr, aValue); |
michael@0 | 176 | getNode(aID).setAttribute(aAttr, aValue); |
michael@0 | 177 | } |
michael@0 | 178 | } |
michael@0 | 179 | |
michael@0 | 180 | this.getID = function echoingStateChange_getID() |
michael@0 | 181 | { |
michael@0 | 182 | return "enchoing ARIA and native attributes change"; |
michael@0 | 183 | } |
michael@0 | 184 | } |
michael@0 | 185 | |
michael@0 | 186 | //////////////////////////////////////////////////////////////////////////// |
michael@0 | 187 | // Do tests |
michael@0 | 188 | |
michael@0 | 189 | var gQueue = null; |
michael@0 | 190 | |
michael@0 | 191 | // var gA11yEventDumpID = "eventdump"; // debug stuff |
michael@0 | 192 | //gA11yEventDumpToConsole = true; // debug stuff |
michael@0 | 193 | |
michael@0 | 194 | function doTests() |
michael@0 | 195 | { |
michael@0 | 196 | gQueue = new eventQueue(nsIAccessibleEvent.EVENT_STATE_CHANGE); |
michael@0 | 197 | |
michael@0 | 198 | // Test delayed editable state change |
michael@0 | 199 | var doc = document.getElementById("iframe").contentDocument; |
michael@0 | 200 | gQueue.push(new makeEditableDoc(doc)); |
michael@0 | 201 | |
michael@0 | 202 | // invalid state change |
michael@0 | 203 | gQueue.push(new invalidInput("email")); |
michael@0 | 204 | |
michael@0 | 205 | // checked state change |
michael@0 | 206 | gQueue.push(new changeCheckInput("checkbox", true)); |
michael@0 | 207 | gQueue.push(new changeCheckInput("checkbox", false)); |
michael@0 | 208 | gQueue.push(new changeCheckInput("radio", true)); |
michael@0 | 209 | gQueue.push(new changeCheckInput("radio", false)); |
michael@0 | 210 | |
michael@0 | 211 | // file input inherited state changes |
michael@0 | 212 | gQueue.push(new stateChangeOnFileInput("file", "aria-busy", "true", |
michael@0 | 213 | STATE_BUSY, false, true)); |
michael@0 | 214 | gQueue.push(new stateChangeOnFileInput("file", "aria-required", "true", |
michael@0 | 215 | STATE_REQUIRED, false, true)); |
michael@0 | 216 | gQueue.push(new stateChangeOnFileInput("file", "aria-invalid", "true", |
michael@0 | 217 | STATE_INVALID, false, true)); |
michael@0 | 218 | |
michael@0 | 219 | gQueue.push(new dupeStateChange("div", "aria-busy", "true", |
michael@0 | 220 | STATE_BUSY, false, true)); |
michael@0 | 221 | gQueue.push(new oppositeStateChange("div", "aria-busy", |
michael@0 | 222 | STATE_BUSY, false)); |
michael@0 | 223 | |
michael@0 | 224 | gQueue.push(new echoingStateChange("text1", "aria-disabled", "disabled", "true", |
michael@0 | 225 | EXT_STATE_ENABLED, true, false)); |
michael@0 | 226 | gQueue.push(new echoingStateChange("text1", "aria-disabled", "disabled", null, |
michael@0 | 227 | EXT_STATE_ENABLED, true, true)); |
michael@0 | 228 | |
michael@0 | 229 | gQueue.invoke(); // Will call SimpleTest.finish(); |
michael@0 | 230 | } |
michael@0 | 231 | |
michael@0 | 232 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 233 | addA11yLoadEvent(doTests); |
michael@0 | 234 | </script> |
michael@0 | 235 | </head> |
michael@0 | 236 | |
michael@0 | 237 | <body> |
michael@0 | 238 | |
michael@0 | 239 | <a target="_blank" |
michael@0 | 240 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=564471" |
michael@0 | 241 | title="Make state change events async"> |
michael@0 | 242 | Bug 564471 |
michael@0 | 243 | </a> |
michael@0 | 244 | <a target="_blank" |
michael@0 | 245 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=555728" |
michael@0 | 246 | title="Fire a11y event based on HTML5 constraint validation"> |
michael@0 | 247 | Bug 555728 |
michael@0 | 248 | </a> |
michael@0 | 249 | <a target="_blank" |
michael@0 | 250 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=699017" |
michael@0 | 251 | title="File input control should be propogate states to descendants"> |
michael@0 | 252 | Bug 699017 |
michael@0 | 253 | </a> |
michael@0 | 254 | <a target="_blank" |
michael@0 | 255 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=788389" |
michael@0 | 256 | title="Fire statechange event whenever checked state is changed not depending on focused state"> |
michael@0 | 257 | Bug 788389 |
michael@0 | 258 | </a> |
michael@0 | 259 | <a target="_blank" |
michael@0 | 260 | href="https://bugzilla.mozilla.org/show_bug.cgi?id=926812" |
michael@0 | 261 | title="State change event not fired when both disabled and aria-disabled are toggled"> |
michael@0 | 262 | Bug 926812 |
michael@0 | 263 | </a> |
michael@0 | 264 | |
michael@0 | 265 | <p id="display"></p> |
michael@0 | 266 | <div id="content" style="display: none"></div> |
michael@0 | 267 | <pre id="test"> |
michael@0 | 268 | </pre> |
michael@0 | 269 | |
michael@0 | 270 | <div id="testContainer"> |
michael@0 | 271 | <iframe id="iframe"></iframe> |
michael@0 | 272 | </div> |
michael@0 | 273 | |
michael@0 | 274 | <input id="email" type='email'> |
michael@0 | 275 | |
michael@0 | 276 | <input id="checkbox" type="checkbox"> |
michael@0 | 277 | <input id="radio" type="radio"> |
michael@0 | 278 | |
michael@0 | 279 | <input id="file" type="file"> |
michael@0 | 280 | |
michael@0 | 281 | <div id="div"></div> |
michael@0 | 282 | |
michael@0 | 283 | <input id="text1"> |
michael@0 | 284 | |
michael@0 | 285 | <div id="eventdump"></div> |
michael@0 | 286 | </body> |
michael@0 | 287 | </html> |