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=411236 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 411236</title> |
michael@0 | 8 | <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 9 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=411236">Mozilla Bug 411236</a> |
michael@0 | 13 | <p id="display"></p> |
michael@0 | 14 | <div id="content"> |
michael@0 | 15 | <input type="file" onfocus="window.oTarget = event.originalTarget;" |
michael@0 | 16 | onclick="window.fileInputGotClick = true; return false;" |
michael@0 | 17 | id="fileinput"> |
michael@0 | 18 | </div> |
michael@0 | 19 | <pre id="test"> |
michael@0 | 20 | <script class="testbody" type="text/javascript"> |
michael@0 | 21 | |
michael@0 | 22 | /** Test for Bug 411236 **/ |
michael@0 | 23 | |
michael@0 | 24 | window.oTarget = null; |
michael@0 | 25 | window.fileInputGotClick = false; |
michael@0 | 26 | |
michael@0 | 27 | function tab() { |
michael@0 | 28 | var utils = SpecialPowers.DOMWindowUtils; |
michael@0 | 29 | // Send tab key events. |
michael@0 | 30 | var key = SpecialPowers.Ci.nsIDOMKeyEvent.DOM_VK_TAB; |
michael@0 | 31 | utils.sendKeyEvent("keydown", key, 0, 0); |
michael@0 | 32 | utils.sendKeyEvent("keypress", key, 0, 0); |
michael@0 | 33 | utils.sendKeyEvent("keyup", key, 0, 0); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function test() { |
michael@0 | 37 | // Try to find the 'Browse...' using tabbing. |
michael@0 | 38 | var i = 0; |
michael@0 | 39 | while (!window.oTarget && i < 100) { |
michael@0 | 40 | ++i; |
michael@0 | 41 | tab(); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | if (i >= 100) { |
michael@0 | 45 | ok(false, "Couldn't find an input element!"); |
michael@0 | 46 | SimpleTest.finish(); |
michael@0 | 47 | return; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | ok(window.oTarget instanceof HTMLButtonElement, "Should have focused an input element!") |
michael@0 | 51 | ok(SpecialPowers.wrap(window.oTarget).type == "button", "Should have focused 'Browse...' button!"); |
michael@0 | 52 | var e = document.createEvent("mouseevents"); |
michael@0 | 53 | e.initMouseEvent("click", true, true, window, 0, 1, 1, 1, 1, |
michael@0 | 54 | false, false, false, false, 0, null); |
michael@0 | 55 | SpecialPowers.wrap(window.oTarget).dispatchEvent(e); |
michael@0 | 56 | ok(window.fileInputGotClick, |
michael@0 | 57 | "File input should have got a click event, but not open the file dialog."); |
michael@0 | 58 | SimpleTest.finish(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function beginTest() { |
michael@0 | 62 | // accessibility.tabfocus must be set to value 7 before running test also |
michael@0 | 63 | // on a mac. |
michael@0 | 64 | SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}, do_test); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | function do_test() { |
michael@0 | 68 | window.focus(); |
michael@0 | 69 | document.getElementById('fileinput').focus(); |
michael@0 | 70 | setTimeout(test, 100); |
michael@0 | 71 | } |
michael@0 | 72 | |
michael@0 | 73 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 74 | addLoadEvent(beginTest); |
michael@0 | 75 | |
michael@0 | 76 | </script> |
michael@0 | 77 | </pre> |
michael@0 | 78 | </body> |
michael@0 | 79 | </html> |