test_bug903715.html 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <script type="application/javascript" 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. function runTests()
  40. {
  41. var form = document.getElementById("form");
  42. form.addEventListener("keypress", function (aEvent) {
  43. ok(false, "keypress event shouldn't be fired when the preceding keydown event caused closing the dropdown of the select element");
  44. }, true);
  45. form.addEventListener("submit", function (aEvent) {
  46. ok(false, "submit shouldn't be performed by the Enter key press on the select element");
  47. aEvent.preventDefault();
  48. }, true);
  49. var select = document.getElementById("select");
  50. select.addEventListener("change", function (aEvent) {
  51. var input = document.getElementById("input-text");
  52. input.focus();
  53. input.select();
  54. }, false);
  55. select.focus();
  56. select.addEventListener("popupshowing", function (aEvent) {
  57. setTimeout(function () {
  58. synthesizeKey("VK_DOWN", { });
  59. select.addEventListener("popuphiding", function (aEvent) {
  60. setTimeout(function () {
  61. // Enter key should cause closing the dropdown of the select element
  62. // and keypress event shouldn't be fired on the input element because
  63. // which shouldn't cause sumbmitting the form contents.
  64. ok(true, "Test passes if there is no error");
  65. SimpleTest.finish();
  66. }, 100);
  67. }, false);
  68. // Close dropdown.
  69. synthesizeKey("VK_RETURN", { });
  70. }, 100);
  71. }, false);
  72. // Open dropdown.
  73. synthesizeKey("VK_DOWN", { altKey: true });
  74. }
  75. </script>
  76. </body>
  77. </html>