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