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=903715 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <meta charset="utf-8"> |
michael@0 | 8 | <title>Test for Bug 903715</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=903715">Mozilla Bug 903715</a> |
michael@0 | 15 | <p id="display"></p> |
michael@0 | 16 | <div id="content"> |
michael@0 | 17 | <form id="form" action="/"> |
michael@0 | 18 | <select id="select" name="select"> |
michael@0 | 19 | <option>1</option> |
michael@0 | 20 | <option>2</option> |
michael@0 | 21 | <option>3</option> |
michael@0 | 22 | <option>4</option> |
michael@0 | 23 | <option>5</option> |
michael@0 | 24 | <option>6</option> |
michael@0 | 25 | <option>7</option> |
michael@0 | 26 | <option>8</option> |
michael@0 | 27 | <option>9</option> |
michael@0 | 28 | </select> |
michael@0 | 29 | <input id="input-text" name="text" value="some text"> |
michael@0 | 30 | <input id="input-submit" type="submit"> |
michael@0 | 31 | </form> |
michael@0 | 32 | </div> |
michael@0 | 33 | <pre id="test"> |
michael@0 | 34 | </pre> |
michael@0 | 35 | <script type="application/javascript"> |
michael@0 | 36 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 37 | SimpleTest.waitForFocus(runTests, window); |
michael@0 | 38 | |
michael@0 | 39 | function runTests() |
michael@0 | 40 | { |
michael@0 | 41 | var form = document.getElementById("form"); |
michael@0 | 42 | form.addEventListener("keypress", function (aEvent) { |
michael@0 | 43 | ok(false, "keypress event shouldn't be fired when the preceding keydown event caused closing the dropdown of the select element"); |
michael@0 | 44 | }, true); |
michael@0 | 45 | form.addEventListener("submit", function (aEvent) { |
michael@0 | 46 | ok(false, "submit shouldn't be performed by the Enter key press on the select element"); |
michael@0 | 47 | aEvent.preventDefault(); |
michael@0 | 48 | }, true); |
michael@0 | 49 | var select = document.getElementById("select"); |
michael@0 | 50 | select.addEventListener("change", function (aEvent) { |
michael@0 | 51 | var input = document.getElementById("input-text"); |
michael@0 | 52 | input.focus(); |
michael@0 | 53 | input.select(); |
michael@0 | 54 | }, false); |
michael@0 | 55 | |
michael@0 | 56 | select.focus(); |
michael@0 | 57 | |
michael@0 | 58 | select.addEventListener("popupshowing", function (aEvent) { |
michael@0 | 59 | setTimeout(function () { |
michael@0 | 60 | synthesizeKey("VK_DOWN", { }); |
michael@0 | 61 | select.addEventListener("popuphiding", function (aEvent) { |
michael@0 | 62 | setTimeout(function () { |
michael@0 | 63 | // Enter key should cause closing the dropdown of the select element |
michael@0 | 64 | // and keypress event shouldn't be fired on the input element because |
michael@0 | 65 | // which shouldn't cause sumbmitting the form contents. |
michael@0 | 66 | ok(true, "Test passes if there is no error"); |
michael@0 | 67 | SimpleTest.finish(); |
michael@0 | 68 | }, 100); |
michael@0 | 69 | }, false); |
michael@0 | 70 | // Close dropdown. |
michael@0 | 71 | synthesizeKey("VK_RETURN", { }); |
michael@0 | 72 | }, 100); |
michael@0 | 73 | }, false); |
michael@0 | 74 | |
michael@0 | 75 | // Open dropdown. |
michael@0 | 76 | synthesizeKey("VK_DOWN", { altKey: true }); |
michael@0 | 77 | } |
michael@0 | 78 | </script> |
michael@0 | 79 | </body> |
michael@0 | 80 | </html> |