layout/forms/test/test_bug903715.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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.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);
    56   select.focus();
    58   select.addEventListener("popupshowing", function (aEvent) {
    59     setTimeout(function () {
    60       synthesizeKey("VK_DOWN", { });
    61       select.addEventListener("popuphiding", function (aEvent) {
    62         setTimeout(function () {
    63           // Enter key should cause closing the dropdown of the select element
    64           // and keypress event shouldn't be fired on the input element because
    65           // which shouldn't cause sumbmitting the form contents.
    66           ok(true, "Test passes if there is no error");
    67           SimpleTest.finish();
    68         }, 100);
    69       }, false);
    70       // Close dropdown.
    71       synthesizeKey("VK_RETURN", { });
    72     }, 100);
    73   }, false);
    75   // Open dropdown.
    76   synthesizeKey("VK_DOWN", { altKey: true });
    77 }
    78 </script>
    79 </body>
    80 </html>

mercurial