layout/forms/test/test_bug571352.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/forms/test/test_bug571352.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,86 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=571352
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 571352</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.14 +</head>
    1.15 +<body>
    1.16 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=571352">Mozilla Bug 571352</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content" style="display: none">
    1.19 +  
    1.20 +</div>
    1.21 +<pre id="test">
    1.22 +<script type="application/javascript">
    1.23 +
    1.24 +/** Test for Bug 571352 **/
    1.25 +
    1.26 +SimpleTest.waitForExplicitFinish();
    1.27 +SimpleTest.waitForFocus(function test() {
    1.28 +  function createList() {
    1.29 +    $('display').innerHTML = '<select multiple><option>0<option>1<option>2<option>3<option>4<option>5</select>';
    1.30 +    $('display').firstChild.focus();
    1.31 +  }
    1.32 +  function option(index) {
    1.33 +    return $('display').firstChild.childNodes[index];
    1.34 +  }
    1.35 +  function remove(index) {
    1.36 +   var sel = $('display').firstChild;
    1.37 +   sel.removeChild(sel.childNodes[index]);
    1.38 +  }
    1.39 +  function up() {   synthesizeKey("VK_UP", {});  }
    1.40 +  function shiftUp() {   synthesizeKey("VK_UP", {shiftKey:true});  }
    1.41 +  function down() {   synthesizeKey("VK_DOWN", {});  }
    1.42 +  function shiftDown() {   synthesizeKey("VK_DOWN", {shiftKey:true});  }
    1.43 +  function mouseEvent(index,event) {
    1.44 +    synthesizeMouse(option(index), 5, 5, event);
    1.45 +  }
    1.46 +
    1.47 +  const click = {};
    1.48 +  const shiftClick = {shiftKey:true};
    1.49 +  const CtrlClick = {CtrlKey:true};
    1.50 +  createList();
    1.51 +  mouseEvent(0,click)
    1.52 +  is(document.activeElement,$('display').firstChild,"<select> is focused");
    1.53 +  mouseEvent(2,shiftClick)
    1.54 +  remove(0);
    1.55 +  ok(option(0).selected && option(1).selected,"first two options are selected");
    1.56 +  mouseEvent(2,shiftClick)
    1.57 +  ok(option(0).selected && option(1).selected && option(2).selected,"first three options are selected");
    1.58 +  shiftUp();
    1.59 +  ok(option(0).selected && option(1).selected,"first two options are selected");
    1.60 +  remove(1);
    1.61 +  ok(option(0).selected,"first option is selected");
    1.62 +  shiftDown();
    1.63 +  ok(option(0).selected && option(1).selected,"first two options are selected");
    1.64 +  down();
    1.65 +  ok(option(2).selected,"third option is selected");
    1.66 +  shiftDown();
    1.67 +  ok(option(2).selected && option(3).selected,"third & fourth option are selected");
    1.68 +  remove(2);
    1.69 +  shiftUp();
    1.70 +  ok(option(1).selected && option(2).selected,"2nd & third option are selected");
    1.71 +  remove(0);
    1.72 +  mouseEvent(0,shiftClick)
    1.73 +  ok(option(0).selected && option(1).selected,"all remaining 2 options are selected");
    1.74 +  shiftDown();
    1.75 +  remove(1);
    1.76 +  ok(!option(0).selected,"first option is unselected");
    1.77 +  remove(0);  // select is now empty
    1.78 +  ok($('display').firstChild.firstChild==null,"all options were removed");
    1.79 +
    1.80 +  SimpleTest.finish();
    1.81 +});
    1.82 +
    1.83 +
    1.84 +
    1.85 +
    1.86 +</script>
    1.87 +</pre>
    1.88 +</body>
    1.89 +</html>

mercurial