tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_select_change_event.html (1790B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1265968
      5 -->
      6 <head>
      7  <title>Test for Bug 1265968</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <script src="/tests/SimpleTest/EventUtils.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1265968">Mozilla Bug 1265968</a>
     14 <p id="display"></p>
     15 <div id="content">
     16  <select id="select" onchange="++selectChange;">
     17    <option>one</option>
     18    <option>two</option>
     19    <option>three</option>
     20    <option>four</option>
     21    <option>five</option>
     22  </select>
     23 </div>
     24 <pre id="test">
     25 <script type="application/javascript">
     26  var select = document.getElementById("select");
     27  var selectChange = 0;
     28  var expectedChange = 0;
     29 
     30  select.focus();
     31  for (var i = 1; i < select.length; i++) {
     32    synthesizeKey("KEY_ArrowDown");
     33    is(select.options[i].selected, true, "Option should be selected");
     34    is(selectChange, ++expectedChange, "Down key should fire change event.");
     35  }
     36 
     37  // We are at the end of the list, going down should not fire change event.
     38  synthesizeKey("KEY_ArrowDown");
     39  is(selectChange, expectedChange, "Down key should not fire change event when reaching end of the list.");
     40 
     41  for (var i = select.length - 2; i >= 0; i--) {
     42    synthesizeKey("KEY_ArrowUp");
     43    is(select.options[i].selected, true, "Option should be selected");
     44    is(selectChange, ++expectedChange, "Up key should fire change event.");
     45  }
     46 
     47  // We are at the top of the list, going up should not fire change event.
     48  synthesizeKey("KEY_ArrowUp");
     49  is(selectChange, expectedChange, "Up key should not fire change event when reaching top of the list.");
     50 
     51 </script>
     52 </pre>
     53 </body>
     54 </html>