tor-browser

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

test_bug571352.html (2864B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=571352
      5 -->
      6 <head>
      7  <title>Test for Bug 571352</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=571352">Mozilla Bug 571352</a>
     14 <p id="display"><select multiple style="width:300px/*to avoid any overlay scrollbar messing with our mouse clicks*/"><option>0<option>1<option>2<option>3<option>4<option>5</select></p>
     15 <div id="content" style="display: none">
     16  
     17 </div>
     18 <pre id="test">
     19 <script type="application/javascript">
     20 
     21 /** Test for Bug 571352 */
     22 
     23 SimpleTest.waitForExplicitFinish();
     24 SimpleTest.waitForFocus(function test() {
     25  function focusList() {
     26    $('display').firstChild.focus();
     27  }
     28  function option(index) {
     29    return $('display').firstChild.childNodes[index];
     30  }
     31  function remove(index) {
     32   var sel = $('display').firstChild;
     33   sel.removeChild(sel.childNodes[index]);
     34   document.body.clientHeight;
     35  }
     36  function up() { synthesizeKey("KEY_ArrowUp"); }
     37  function shiftUp() { synthesizeKey("KEY_ArrowUp", {shiftKey:true}); }
     38  function down() { synthesizeKey("KEY_ArrowDown"); }
     39  function shiftDown() { synthesizeKey("KEY_ArrowDown", {shiftKey:true}); }
     40  function mouseEvent(index,event) {
     41    synthesizeMouse(option(index), 5, 5, event);
     42  }
     43 
     44  const click = {};
     45  const shiftClick = {shiftKey:true};
     46  focusList();
     47  mouseEvent(0,click)
     48  is(document.activeElement,$('display').firstChild,"<select> is focused");
     49  ok(option(0).selected,"first option is selected");
     50  mouseEvent(2,shiftClick)
     51  remove(0);
     52  ok(option(0).selected && option(1).selected,"first two options are selected");
     53  mouseEvent(2,shiftClick)
     54  ok(option(0).selected && option(1).selected && option(2).selected,"first three options are selected");
     55  shiftUp();
     56  ok(option(0).selected && option(1).selected,"first two options are selected");
     57  remove(1);
     58  ok(option(0).selected,"first option is selected");
     59  shiftDown();
     60  ok(option(0).selected && option(1).selected,"first two options are selected");
     61  down();
     62  ok(option(2).selected,"third option is selected");
     63  shiftDown();
     64  ok(option(2).selected && option(3).selected,"third & fourth option are selected");
     65  remove(2);
     66  shiftUp();
     67  ok(option(1).selected && option(2).selected,"2nd & third option are selected");
     68  remove(0);
     69  mouseEvent(0,shiftClick)
     70  ok(option(0).selected && option(1).selected,"all remaining 2 options are selected");
     71  shiftDown();
     72  remove(1);
     73  ok(!option(0).selected,"first option is unselected");
     74  remove(0);  // select is now empty
     75  ok($('display').firstChild.firstChild==null,"all options were removed");
     76 
     77  SimpleTest.finish();
     78 });
     79 
     80 
     81 
     82 
     83 </script>
     84 </pre>
     85 </body>
     86 </html>