layout/forms/test/test_bug672810.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/layout/forms/test/test_bug672810.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=672810
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 672810</title>
    1.11 +  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <script type="application/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=672810">Mozilla Bug 672810</a>
    1.17 +<p id="display"></p>
    1.18 +<div id="content">
    1.19 +  <select id="s1" multiple size="10"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select>
    1.20 +  <select id="s2" size="10"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select>
    1.21 +  <select id="s3" size="1"><option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x<option>x</select>
    1.22 +</div>
    1.23 +<pre id="test">
    1.24 +<script type="application/javascript">
    1.25 +
    1.26 +/** Test for Bug 672810 **/
    1.27 +
    1.28 +SimpleTest.waitForExplicitFinish();
    1.29 +
    1.30 +SimpleTest.waitForFocus(function() {
    1.31 +  var sel = document.getElementsByTagName('select');
    1.32 +
    1.33 +  sel[0].addEventListener('focus', function() {
    1.34 +    s = sel[0];
    1.35 +    s.removeEventListener('focus', arguments.callee, false);
    1.36 +    synthesizeKey('VK_DOWN', {});
    1.37 +    is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
    1.38 +    synthesizeKey('VK_DOWN', {ctrlKey: true});
    1.39 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.40 +    ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option");
    1.41 +    synthesizeKey('VK_DOWN', {ctrlKey: true});
    1.42 +    synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
    1.43 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.44 +    ok(!s[1].selected,s.id + ": 2nd option is still unselected");
    1.45 +    ok(s[2].selected,s.id + ": 3rd option is selected");
    1.46 +    ok(s[3].selected,s.id + ": 4th option is selected");
    1.47 +    ok(!s[4].selected,s.id + ": 5th option is unselected");
    1.48 +    synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
    1.49 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.50 +    ok(!s[1].selected,s.id + ": 2nd option is still unselected");
    1.51 +    ok(s[2].selected,s.id + ": 3rd option is still selected");
    1.52 +    ok(s[3].selected,s.id + ": 4th option is still selected");
    1.53 +    ok(s[4].selected,s.id + ": 5th option is selected");
    1.54 +    ok(!s[5].selected,s.id + ": 6th option is unselected");
    1.55 +    synthesizeKey('VK_UP', {ctrlKey: true, shiftKey: true});
    1.56 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.57 +    ok(!s[1].selected,s.id + ": 2nd option is still unselected");
    1.58 +    ok(s[2].selected,s.id + ": 3rd option is still selected");
    1.59 +    ok(s[3].selected,s.id + ": 4th option is still selected");
    1.60 +    ok(s[4].selected,s.id + ": 5th option is still selected");
    1.61 +    ok(!s[5].selected,s.id + ": 6th option is still unselected");
    1.62 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
    1.63 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.64 +    ok(!s[1].selected,s.id + ": 2nd option is still unselected");
    1.65 +    ok(s[2].selected,s.id + ": 3rd option is still selected");
    1.66 +    ok(!s[3].selected,s.id + ": 4th option is unselected");
    1.67 +    ok(s[4].selected,s.id + ": 5th option is still selected");
    1.68 +    ok(!s[5].selected,s.id + ": 6th option is still unselected");
    1.69 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
    1.70 +    is(s.selectedIndex,0, s.id + ": first option is still selected");
    1.71 +    ok(!s[1].selected,s.id + ": 2nd option is still unselected");
    1.72 +    ok(s[2].selected,s.id + ": 3rd option is still selected");
    1.73 +    ok(s[3].selected,s.id + ": 4th option is selected");
    1.74 +    ok(s[4].selected,s.id + ": 5th option is still selected");
    1.75 +    ok(!s[5].selected,s.id + ": 6th option is still unselected");
    1.76 +    setTimeout(function(){sel[1].focus()},0);
    1.77 +  }, false);
    1.78 +  sel[1].addEventListener('focus', function() {
    1.79 +    s = sel[1];
    1.80 +    s.removeEventListener('focus', arguments.callee, false);
    1.81 +    synthesizeKey('VK_DOWN', {});
    1.82 +    is(s.selectedIndex,0, s.id + ": initial DOWN selects first option");
    1.83 +    synthesizeKey('VK_DOWN', {ctrlKey: true});
    1.84 +    is(s.selectedIndex,1, s.id + ": 2nd option is selected");
    1.85 +    ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option");
    1.86 +    synthesizeKey('VK_DOWN', {ctrlKey: true});
    1.87 +    synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
    1.88 +    is(s.selectedIndex,3, s.id + ": 4th option is selected");
    1.89 +    ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option");
    1.90 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
    1.91 +    is(s.selectedIndex,3, s.id + ": 4th option is still selected");
    1.92 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
    1.93 +    is(s.selectedIndex,3, s.id + ": 4th option is still selected");
    1.94 +    setTimeout(function(){sel[2].focus()},0);
    1.95 +  }, false);
    1.96 +  sel[2].addEventListener('focus', function() {
    1.97 +    s = sel[2];
    1.98 +    s.removeEventListener('focus', arguments.callee, false);
    1.99 +    synthesizeKey('VK_DOWN', {});
   1.100 +    is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option");
   1.101 +    synthesizeKey('VK_DOWN', {ctrlKey: true});
   1.102 +    is(s.selectedIndex,2, s.id + ": 3rd option is selected");
   1.103 +    ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option");
   1.104 +    synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true});
   1.105 +    is(s.selectedIndex,3, s.id + ": 4th option is selected");
   1.106 +    ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option");
   1.107 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
   1.108 +    is(s.selectedIndex,3, s.id + ": 4th option is still selected");
   1.109 +    synthesizeKey(' ', {ctrlKey: true, shiftKey: true});
   1.110 +    is(s.selectedIndex,3, s.id + ": 4th option is still selected");
   1.111 +    setTimeout(function(){SimpleTest.finish()},0);
   1.112 +  }, false);
   1.113 +  sel[0].focus();
   1.114 +});
   1.115 +
   1.116 +</script>
   1.117 +</pre>
   1.118 +</body>
   1.119 +</html>

mercurial