summaryrefslogtreecommitdiffstats
path: root/layout/forms/test/test_bug563642.html
blob: 9c5171d7067659fb3d6b13257e76988f4e958f12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=563642
-->
<head>
  <title>Test for Bug 563642</title>
  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=563642">Mozilla Bug 563642</a>
<p id="display">
<select id="test1" multiple="multiple" size="1">
	<option>Item 1</option>
	<option>Item 2</option>
	<option>Item 3</option>
	<option>Item 4</option>
	<option>Item 5</option>
</select>
<select id="test2" multiple="multiple" size="1">
	<option>Item 1</option>
	<option disabled>Item 2</option>
	<option>Item 3</option>
	<option disabled>Item 4</option>
	<option>Item 5</option>
</select>
<select id="test3" multiple="multiple"></select>
<select id="test4" multiple="multiple" size="1"></select>
</p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script type="application/javascript">

/** Test for Bug 563642 **/

function pageUpDownTest(id,index) {
  var elm = document.getElementById(id);
  elm.focus();
  elm.selectedIndex = 0;
  sendKey("page_down");
  sendKey("page_down");
  sendKey("page_down");
  sendKey("page_up");
  sendKey("page_down");
  is(elm.selectedIndex, index, "pageUpDownTest: selectedIndex for " + id + " is " + index);
}

function upDownTest(id,index) {
  var elm = document.getElementById(id);
  elm.focus();
  elm.selectedIndex = 0;
  sendKey("down");
  sendKey("down");
  sendKey("down");
  sendKey("up");
  sendKey("down");
  is(elm.selectedIndex, index, "upDownTest: selectedIndex for " + id + " is " + index);
}

function runTest() {
  pageUpDownTest("test1",3);
  pageUpDownTest("test2",4);
  pageUpDownTest("test3",-1);
  pageUpDownTest("test4",-1);
  upDownTest("test1",3);
  upDownTest("test2",4);
  upDownTest("test3",-1);
  upDownTest("test4",-1);

  SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
// Turn off Spatial Navigation because it hijacks down and up key events.
SimpleTest.waitForFocus(function() {
  SpecialPowers.pushPrefEnv({"set":[["snav.enabled", false]]}, runTest);
})

</script>
</pre>
</body>
</html>