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 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <!-- |
michael@0 | 4 | https://bugzilla.mozilla.org/show_bug.cgi?id=935876 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 935876</title> |
michael@0 | 9 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 11 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 12 | </head> |
michael@0 | 13 | <body> |
michael@0 | 14 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=935876">Mozilla Bug 935876</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div> |
michael@0 | 17 | <select id="listbox" size="3"> |
michael@0 | 18 | <option selected>1</option> |
michael@0 | 19 | <option>2</option> |
michael@0 | 20 | <option>3</option> |
michael@0 | 21 | <option>4</option> |
michael@0 | 22 | <option>5</option> |
michael@0 | 23 | <option>6</option> |
michael@0 | 24 | <option>7</option> |
michael@0 | 25 | </select> |
michael@0 | 26 | <select id="multipleListbox" size="3" multiple> |
michael@0 | 27 | <option selected>1</option> |
michael@0 | 28 | <option>2</option> |
michael@0 | 29 | <option>3</option> |
michael@0 | 30 | <option>4</option> |
michael@0 | 31 | <option>5</option> |
michael@0 | 32 | <option>6</option> |
michael@0 | 33 | <option>7</option> |
michael@0 | 34 | </select> |
michael@0 | 35 | <select id="combobox"> |
michael@0 | 36 | <option selected>1</option> |
michael@0 | 37 | <option>2</option> |
michael@0 | 38 | <option>3</option> |
michael@0 | 39 | <option>4</option> |
michael@0 | 40 | <option>5</option> |
michael@0 | 41 | <option>6</option> |
michael@0 | 42 | <option>7</option> |
michael@0 | 43 | </select> |
michael@0 | 44 | </div> |
michael@0 | 45 | <pre id="test"> |
michael@0 | 46 | </pre> |
michael@0 | 47 | <script type="application/javascript"> |
michael@0 | 48 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 49 | |
michael@0 | 50 | const kIsWin = navigator.platform.indexOf("Win") == 0; |
michael@0 | 51 | const kIsMac = navigator.platform.indexOf("Mac") == 0; |
michael@0 | 52 | const kIsAndroid = navigator.appVersion.indexOf("Android") != 0; |
michael@0 | 53 | |
michael@0 | 54 | function runTests() |
michael@0 | 55 | { |
michael@0 | 56 | var doPreventDefault = false; |
michael@0 | 57 | function onKeydown(aEvent) |
michael@0 | 58 | { |
michael@0 | 59 | if (doPreventDefault) { |
michael@0 | 60 | aEvent.preventDefault(); |
michael@0 | 61 | } |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | var keyPressEventFired = false; |
michael@0 | 65 | function onKeypress(aEvent) |
michael@0 | 66 | { |
michael@0 | 67 | keyPressEventFired = true; |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | var keyDownEventConsumedByJS = false; |
michael@0 | 71 | var keyDownEventConsumed = false; |
michael@0 | 72 | function onkeydownInSystemEventGroup(aEvent) |
michael@0 | 73 | { |
michael@0 | 74 | keyDownEventConsumedByJS = aEvent.defaultPrevented; |
michael@0 | 75 | keyDownEventConsumed = aEvent.getPreventDefault(); |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | function reset() |
michael@0 | 79 | { |
michael@0 | 80 | keyPressEventFired = false; |
michael@0 | 81 | keyDownEventConsumedByJS = false; |
michael@0 | 82 | keyDownEventConsumed = false; |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | function check(aExpectingKeydownConsumed, aDescription) |
michael@0 | 86 | { |
michael@0 | 87 | if (doPreventDefault) { |
michael@0 | 88 | ok(!keyPressEventFired, "keypress event shouldn't be fired for " + aDescription + |
michael@0 | 89 | " if preventDefault() of keydown event was called"); |
michael@0 | 90 | ok(keyDownEventConsumedByJS, "keydown event of " + aDescription + |
michael@0 | 91 | " should be consumed in content level if preventDefault() of keydown event is called"); |
michael@0 | 92 | ok(keyDownEventConsumed, "keydown event of " + aDescription + |
michael@0 | 93 | " should be consumed in system level if preventDefault() of keydown event is called"); |
michael@0 | 94 | } else if (aExpectingKeydownConsumed) { |
michael@0 | 95 | ok(!keyPressEventFired, "keypress event shouldn't be fired for " + aDescription); |
michael@0 | 96 | ok(!keyDownEventConsumedByJS, "keydown event of " + aDescription + " shouldn't be consumed in content level"); |
michael@0 | 97 | ok(keyDownEventConsumed, "keydown event of " + aDescription + " should be consumed in system level"); |
michael@0 | 98 | } else { |
michael@0 | 99 | ok(keyPressEventFired, "keypress event should be fired for " + aDescription); |
michael@0 | 100 | ok(!keyDownEventConsumedByJS, "keydown event of " + aDescription + " shouldn't be consumed in content level"); |
michael@0 | 101 | ok(!keyDownEventConsumed, "keydown event of " + aDescription + " should be consumed in system level"); |
michael@0 | 102 | } |
michael@0 | 103 | } |
michael@0 | 104 | |
michael@0 | 105 | var listbox = document.getElementById("listbox"); |
michael@0 | 106 | listbox.addEventListener("keydown", onKeydown, false); |
michael@0 | 107 | listbox.addEventListener("keypress", onKeypress, false); |
michael@0 | 108 | SpecialPowers.addSystemEventListener(listbox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 109 | |
michael@0 | 110 | listbox.focus(); |
michael@0 | 111 | |
michael@0 | 112 | [ false, true ].forEach(function (consume) { |
michael@0 | 113 | doPreventDefault = consume; |
michael@0 | 114 | for (var i = 0; i < listbox.options.length + 1; i++) { |
michael@0 | 115 | reset() |
michael@0 | 116 | synthesizeKey("VK_DOWN", {}); |
michael@0 | 117 | check(true, "DownArrow key on listbox #" + i); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | for (var i = 0; i < listbox.options.length + 1; i++) { |
michael@0 | 121 | reset() |
michael@0 | 122 | synthesizeKey("VK_UP", {}); |
michael@0 | 123 | check(true, "UpArrow key on listbox #" + i); |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | for (var i = 0; i < listbox.options.length + 1; i++) { |
michael@0 | 127 | reset() |
michael@0 | 128 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 129 | check(true, "RightArrow key on listbox #" + i); |
michael@0 | 130 | } |
michael@0 | 131 | |
michael@0 | 132 | for (var i = 0; i < listbox.options.length + 1; i++) { |
michael@0 | 133 | reset() |
michael@0 | 134 | synthesizeKey("VK_LEFT", {}); |
michael@0 | 135 | check(true, "LeftArrow key on listbox #" + i); |
michael@0 | 136 | } |
michael@0 | 137 | |
michael@0 | 138 | for (var i = 0; i < 4; i++) { |
michael@0 | 139 | reset() |
michael@0 | 140 | synthesizeKey("VK_PAGE_DOWN", {}); |
michael@0 | 141 | check(true, "PageDown key on listbox #" + i); |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | for (var i = 0; i < 4; i++) { |
michael@0 | 145 | reset() |
michael@0 | 146 | synthesizeKey("VK_PAGE_UP", {}); |
michael@0 | 147 | check(true, "PageUp key on listbox #" + i); |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | for (var i = 0; i < 2; i++) { |
michael@0 | 151 | reset() |
michael@0 | 152 | synthesizeKey("VK_END", {}); |
michael@0 | 153 | check(true, "End key on listbox #" + i); |
michael@0 | 154 | } |
michael@0 | 155 | |
michael@0 | 156 | for (var i = 0; i < 2; i++) { |
michael@0 | 157 | reset() |
michael@0 | 158 | synthesizeKey("VK_HOME", {}); |
michael@0 | 159 | check(true, "Home key on listbox #" + i); |
michael@0 | 160 | } |
michael@0 | 161 | |
michael@0 | 162 | reset() |
michael@0 | 163 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 164 | check(false, "Enter key on listbox"); |
michael@0 | 165 | |
michael@0 | 166 | reset() |
michael@0 | 167 | synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 168 | check(false, "Esc key on listbox"); |
michael@0 | 169 | |
michael@0 | 170 | reset() |
michael@0 | 171 | synthesizeKey("VK_F4", {}); |
michael@0 | 172 | check(false, "F4 key on listbox"); |
michael@0 | 173 | |
michael@0 | 174 | reset() |
michael@0 | 175 | synthesizeKey("a", {}); |
michael@0 | 176 | check(false, "'A' key on listbox"); |
michael@0 | 177 | }); |
michael@0 | 178 | |
michael@0 | 179 | listbox.removeEventListener("keydown", onKeydown, false); |
michael@0 | 180 | listbox.removeEventListener("keypress", onKeypress, false); |
michael@0 | 181 | SpecialPowers.removeSystemEventListener(listbox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 182 | |
michael@0 | 183 | |
michael@0 | 184 | |
michael@0 | 185 | var multipleListbox = document.getElementById("multipleListbox"); |
michael@0 | 186 | multipleListbox.addEventListener("keydown", onKeydown, false); |
michael@0 | 187 | multipleListbox.addEventListener("keypress", onKeypress, false); |
michael@0 | 188 | SpecialPowers.addSystemEventListener(multipleListbox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 189 | |
michael@0 | 190 | multipleListbox.focus(); |
michael@0 | 191 | |
michael@0 | 192 | [ false, true ].forEach(function (consume) { |
michael@0 | 193 | doPreventDefault = consume; |
michael@0 | 194 | for (var i = 0; i < multipleListbox.options.length + 1; i++) { |
michael@0 | 195 | reset() |
michael@0 | 196 | synthesizeKey("VK_DOWN", {}); |
michael@0 | 197 | check(true, "DownArrow key on multiple listbox #" + i); |
michael@0 | 198 | } |
michael@0 | 199 | |
michael@0 | 200 | for (var i = 0; i < multipleListbox.options.length + 1; i++) { |
michael@0 | 201 | reset() |
michael@0 | 202 | synthesizeKey("VK_UP", {}); |
michael@0 | 203 | check(true, "UpArrow key on multiple listbox #" + i); |
michael@0 | 204 | } |
michael@0 | 205 | |
michael@0 | 206 | for (var i = 0; i < multipleListbox.options.length + 1; i++) { |
michael@0 | 207 | reset() |
michael@0 | 208 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 209 | check(true, "RightArrow key on multiple listbox #" + i); |
michael@0 | 210 | } |
michael@0 | 211 | |
michael@0 | 212 | for (var i = 0; i < multipleListbox.options.length + 1; i++) { |
michael@0 | 213 | reset() |
michael@0 | 214 | synthesizeKey("VK_LEFT", {}); |
michael@0 | 215 | check(true, "LeftArrow key on multiple listbox #" + i); |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | for (var i = 0; i < 4; i++) { |
michael@0 | 219 | reset() |
michael@0 | 220 | synthesizeKey("VK_PAGE_DOWN", {}); |
michael@0 | 221 | check(true, "PageDown key on multiple listbox #" + i); |
michael@0 | 222 | } |
michael@0 | 223 | |
michael@0 | 224 | for (var i = 0; i < 4; i++) { |
michael@0 | 225 | reset() |
michael@0 | 226 | synthesizeKey("VK_PAGE_UP", {}); |
michael@0 | 227 | check(true, "PageUp key on multiple listbox #" + i); |
michael@0 | 228 | } |
michael@0 | 229 | |
michael@0 | 230 | for (var i = 0; i < 2; i++) { |
michael@0 | 231 | reset() |
michael@0 | 232 | synthesizeKey("VK_END", {}); |
michael@0 | 233 | check(true, "End key on multiple listbox #" + i); |
michael@0 | 234 | } |
michael@0 | 235 | |
michael@0 | 236 | for (var i = 0; i < 2; i++) { |
michael@0 | 237 | reset() |
michael@0 | 238 | synthesizeKey("VK_HOME", {}); |
michael@0 | 239 | check(true, "Home key on multiple listbox #" + i); |
michael@0 | 240 | } |
michael@0 | 241 | |
michael@0 | 242 | reset() |
michael@0 | 243 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 244 | check(true, "Enter key on multiple listbox"); |
michael@0 | 245 | |
michael@0 | 246 | reset() |
michael@0 | 247 | synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 248 | check(false, "Esc key on multiple listbox"); |
michael@0 | 249 | |
michael@0 | 250 | reset() |
michael@0 | 251 | synthesizeKey("VK_F4", {}); |
michael@0 | 252 | check(false, "F4 key on multiple listbox"); |
michael@0 | 253 | |
michael@0 | 254 | reset() |
michael@0 | 255 | synthesizeKey("a", {}); |
michael@0 | 256 | check(false, "'A' key on multiple listbox"); |
michael@0 | 257 | }); |
michael@0 | 258 | |
michael@0 | 259 | multipleListbox.removeEventListener("keydown", onKeydown, false); |
michael@0 | 260 | multipleListbox.removeEventListener("keypress", onKeypress, false); |
michael@0 | 261 | SpecialPowers.removeSystemEventListener(multipleListbox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 262 | |
michael@0 | 263 | |
michael@0 | 264 | |
michael@0 | 265 | var combobox = document.getElementById("combobox"); |
michael@0 | 266 | combobox.addEventListener("keydown", onKeydown, false); |
michael@0 | 267 | combobox.addEventListener("keypress", onKeypress, false); |
michael@0 | 268 | SpecialPowers.addSystemEventListener(combobox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 269 | |
michael@0 | 270 | combobox.focus(); |
michael@0 | 271 | |
michael@0 | 272 | [ false, true ].forEach(function (consume) { |
michael@0 | 273 | doPreventDefault = consume; |
michael@0 | 274 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 275 | reset() |
michael@0 | 276 | synthesizeKey("VK_DOWN", {}); |
michael@0 | 277 | check(true, "DownArrow key on combobox #" + i); |
michael@0 | 278 | } |
michael@0 | 279 | |
michael@0 | 280 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 281 | reset() |
michael@0 | 282 | synthesizeKey("VK_UP", {}); |
michael@0 | 283 | check(true, "UpArrow key on combobox #" + i); |
michael@0 | 284 | } |
michael@0 | 285 | |
michael@0 | 286 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 287 | reset() |
michael@0 | 288 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 289 | check(true, "RightArrow key on combobox #" + i); |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 293 | reset() |
michael@0 | 294 | synthesizeKey("VK_LEFT", {}); |
michael@0 | 295 | check(true, "LeftArrow key on combobox #" + i); |
michael@0 | 296 | } |
michael@0 | 297 | |
michael@0 | 298 | for (var i = 0; i < 4; i++) { |
michael@0 | 299 | reset() |
michael@0 | 300 | synthesizeKey("VK_PAGE_DOWN", {}); |
michael@0 | 301 | check(true, "PageDown key on combobox #" + i); |
michael@0 | 302 | } |
michael@0 | 303 | |
michael@0 | 304 | for (var i = 0; i < 4; i++) { |
michael@0 | 305 | reset() |
michael@0 | 306 | synthesizeKey("VK_PAGE_UP", {}); |
michael@0 | 307 | check(true, "PageUp key on combobox #" + i); |
michael@0 | 308 | } |
michael@0 | 309 | |
michael@0 | 310 | for (var i = 0; i < 2; i++) { |
michael@0 | 311 | reset() |
michael@0 | 312 | synthesizeKey("VK_END", {}); |
michael@0 | 313 | check(true, "End key on combobox #" + i); |
michael@0 | 314 | } |
michael@0 | 315 | |
michael@0 | 316 | for (var i = 0; i < 2; i++) { |
michael@0 | 317 | reset() |
michael@0 | 318 | synthesizeKey("VK_HOME", {}); |
michael@0 | 319 | check(true, "Home key on combobox #" + i); |
michael@0 | 320 | } |
michael@0 | 321 | |
michael@0 | 322 | reset() |
michael@0 | 323 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 324 | check(false, "Enter key on combobox"); |
michael@0 | 325 | |
michael@0 | 326 | reset() |
michael@0 | 327 | synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 328 | check(true, "Esc key on combobox"); |
michael@0 | 329 | |
michael@0 | 330 | if (!kIsWin) { |
michael@0 | 331 | reset() |
michael@0 | 332 | synthesizeKey("VK_F4", {}); |
michael@0 | 333 | check(false, "F4 key on combobox"); |
michael@0 | 334 | } |
michael@0 | 335 | |
michael@0 | 336 | reset() |
michael@0 | 337 | synthesizeKey("a", {}); |
michael@0 | 338 | check(false, "'A' key on combobox"); |
michael@0 | 339 | }); |
michael@0 | 340 | |
michael@0 | 341 | function finish() |
michael@0 | 342 | { |
michael@0 | 343 | combobox.removeEventListener("keydown", onKeydown, false); |
michael@0 | 344 | combobox.removeEventListener("keypress", onKeypress, false); |
michael@0 | 345 | SpecialPowers.removeSystemEventListener(combobox, "keydown", onkeydownInSystemEventGroup, false); |
michael@0 | 346 | SimpleTest.finish(); |
michael@0 | 347 | } |
michael@0 | 348 | |
michael@0 | 349 | // Mac uses native popup for dropdown. Let's skip the tests for popup |
michael@0 | 350 | // since it's not handled in nsListControlFrame. |
michael@0 | 351 | // Similarly, Android doesn't use popup for dropdown. |
michael@0 | 352 | if (kIsMac || kIsAndroid) { |
michael@0 | 353 | finish(); |
michael@0 | 354 | return; |
michael@0 | 355 | } |
michael@0 | 356 | |
michael@0 | 357 | function testDropDown(aCallback) |
michael@0 | 358 | { |
michael@0 | 359 | testOpenDropDown(function () { |
michael@0 | 360 | reset() |
michael@0 | 361 | synthesizeKey("VK_DOWN", { altKey: true }); |
michael@0 | 362 | }, function () { |
michael@0 | 363 | check(true, "Alt + DownArrow key on combobox at opening dropdown"); |
michael@0 | 364 | |
michael@0 | 365 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 366 | reset() |
michael@0 | 367 | synthesizeKey("VK_DOWN", {}); |
michael@0 | 368 | check(true, "DownArrow key on combobox during dropdown open #" + i); |
michael@0 | 369 | } |
michael@0 | 370 | |
michael@0 | 371 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 372 | reset() |
michael@0 | 373 | synthesizeKey("VK_UP", {}); |
michael@0 | 374 | check(true, "UpArrow key on combobox during dropdown open #" + i); |
michael@0 | 375 | } |
michael@0 | 376 | |
michael@0 | 377 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 378 | reset() |
michael@0 | 379 | synthesizeKey("VK_RIGHT", {}); |
michael@0 | 380 | check(true, "RightArrow key on combobox during dropdown open #" + i); |
michael@0 | 381 | } |
michael@0 | 382 | |
michael@0 | 383 | for (var i = 0; i < combobox.options.length + 1; i++) { |
michael@0 | 384 | reset() |
michael@0 | 385 | synthesizeKey("VK_LEFT", {}); |
michael@0 | 386 | check(true, "LeftArrow key on combobox during dropdown open #" + i); |
michael@0 | 387 | } |
michael@0 | 388 | |
michael@0 | 389 | for (var i = 0; i < 4; i++) { |
michael@0 | 390 | reset() |
michael@0 | 391 | synthesizeKey("VK_PAGE_DOWN", {}); |
michael@0 | 392 | check(true, "PageDown key on combobox during dropdown open #" + i); |
michael@0 | 393 | } |
michael@0 | 394 | |
michael@0 | 395 | for (var i = 0; i < 4; i++) { |
michael@0 | 396 | reset() |
michael@0 | 397 | synthesizeKey("VK_PAGE_UP", {}); |
michael@0 | 398 | check(true, "PageUp key on combobox during dropdown open #" + i); |
michael@0 | 399 | } |
michael@0 | 400 | |
michael@0 | 401 | for (var i = 0; i < 2; i++) { |
michael@0 | 402 | reset() |
michael@0 | 403 | synthesizeKey("VK_END", {}); |
michael@0 | 404 | check(true, "End key on combobox during dropdown open #" + i); |
michael@0 | 405 | } |
michael@0 | 406 | |
michael@0 | 407 | for (var i = 0; i < 2; i++) { |
michael@0 | 408 | reset() |
michael@0 | 409 | synthesizeKey("VK_HOME", {}); |
michael@0 | 410 | check(true, "Home key on combobox during dropdown open #" + i); |
michael@0 | 411 | } |
michael@0 | 412 | |
michael@0 | 413 | testCloseDropDown(function () { |
michael@0 | 414 | reset() |
michael@0 | 415 | synthesizeKey("VK_RETURN", {}); |
michael@0 | 416 | }, function () { |
michael@0 | 417 | testOpenDropDown(function () { |
michael@0 | 418 | check(true, "Enter key on combobox at closing dropdown"); |
michael@0 | 419 | |
michael@0 | 420 | synthesizeKey("VK_UP", { altKey: true }); |
michael@0 | 421 | }, function () { |
michael@0 | 422 | check(true, "Alt + UpArrow key on combobox at opening dropdown"); |
michael@0 | 423 | |
michael@0 | 424 | testCloseDropDown(function () { |
michael@0 | 425 | reset() |
michael@0 | 426 | synthesizeKey("VK_ESCAPE", {}); |
michael@0 | 427 | }, function () { |
michael@0 | 428 | check(true, "Esc key on combobox at closing dropdown"); |
michael@0 | 429 | |
michael@0 | 430 | // F4 key opens/closes dropdown only on Windows. So, other platforms |
michael@0 | 431 | // don't need to do anymore. |
michael@0 | 432 | if (!kIsWin) { |
michael@0 | 433 | aCallback(); |
michael@0 | 434 | return; |
michael@0 | 435 | } |
michael@0 | 436 | |
michael@0 | 437 | testOpenDropDown(function () { |
michael@0 | 438 | reset() |
michael@0 | 439 | synthesizeKey("VK_F4", {}); |
michael@0 | 440 | }, function () { |
michael@0 | 441 | check(true, "F4 key on combobox at opening dropdown on Windows"); |
michael@0 | 442 | |
michael@0 | 443 | testCloseDropDown(function () { |
michael@0 | 444 | reset() |
michael@0 | 445 | synthesizeKey("VK_F4", {}); |
michael@0 | 446 | }, function () { |
michael@0 | 447 | check(true, "F4 key on combobox at closing dropdown on Windows"); |
michael@0 | 448 | |
michael@0 | 449 | aCallback(); |
michael@0 | 450 | return; |
michael@0 | 451 | }); |
michael@0 | 452 | }); |
michael@0 | 453 | }); |
michael@0 | 454 | }); |
michael@0 | 455 | }); |
michael@0 | 456 | }); |
michael@0 | 457 | } |
michael@0 | 458 | |
michael@0 | 459 | doPreventDefault = false; |
michael@0 | 460 | testDropDown(function () { |
michael@0 | 461 | // Even if keydown event is consumed by JS, opening/closing dropdown |
michael@0 | 462 | // should work for a11y and security (e.g., cannot close dropdown causes |
michael@0 | 463 | // staying top-most window on the screen). If it's blocked by JS, this |
michael@0 | 464 | // test would cause permanent timeout. |
michael@0 | 465 | doPreventDefault = true; |
michael@0 | 466 | testDropDown(finish); |
michael@0 | 467 | }); |
michael@0 | 468 | } |
michael@0 | 469 | |
michael@0 | 470 | function testOpenDropDown(aTest, aOnOpenDropDown) |
michael@0 | 471 | { |
michael@0 | 472 | document.addEventListener("popupshowing", function (aEvent) { |
michael@0 | 473 | document.removeEventListener(aEvent.type, arguments.callee, false); |
michael@0 | 474 | setTimeout(aOnOpenDropDown, 0); |
michael@0 | 475 | }, false); |
michael@0 | 476 | aTest(); |
michael@0 | 477 | } |
michael@0 | 478 | |
michael@0 | 479 | function testCloseDropDown(aTest, aOnCloseDropDown) |
michael@0 | 480 | { |
michael@0 | 481 | document.addEventListener("popuphiding", function (aEvent) { |
michael@0 | 482 | document.removeEventListener(aEvent.type, arguments.callee, false); |
michael@0 | 483 | setTimeout(aOnCloseDropDown, 0) |
michael@0 | 484 | }, false); |
michael@0 | 485 | aTest(); |
michael@0 | 486 | } |
michael@0 | 487 | |
michael@0 | 488 | SimpleTest.waitForFocus(runTests); |
michael@0 | 489 | </script> |
michael@0 | 490 | </body> |
michael@0 | 491 | </html> |