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
86
87
88
89
90
91
92
93
94
95
96
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=961363
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 961363</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 961363 **/
SimpleTest.waitForExplicitFinish();
function test() {
SimpleTest.waitForFocus(function() {
var one = [{k:"DOWN",s:[false,true,true,false]}, {k:"UP",s:[false,false,true,false]},
{k:"RIGHT",s:[false,false,false,false]}, {k:"LEFT",s:[false,true,false,false]},
{k:"PAGE_DOWN",s:[false,true,false,true]}, {k:"PAGE_UP",s:[false,false,false,true]},
{k:"END",s:[false,false,false,false]}, {k:"HOME",s:[true,false,false,false]} ];
var two_1 = [{k:"DOWN",s:[false,false,true,false]}, {k:"UP",s:[false,true,false,false]},
{k:"RIGHT",s:[false,false,true,false]}, {k:"LEFT",s:[false,true,false,false]},
{k:"END",s:[false,false,false,true]}, {k:"HOME",s:[true,false,false,false]} ];
var two_2 = [{k:"PAGE_DOWN",s:[true,false,false,false]}, {k:"PAGE_UP",s:[true,false,false,false]}];
var three_1 = [{k:"DOWN",s:[false,false,true,false]}, {k:"UP",s:[false,true,false,false]},
{k:"RIGHT",s:[false,false,true,false]}, {k:"LEFT",s:[false,true,false,false]},
{k:"END",s:[false,false,false,true]}, {k:"HOME",s:[true,false,false,false]} ];
var three_2 = [{k:"PAGE_DOWN",s:[true,false,false,false]}, {k:"PAGE_UP",s:[true,false,false,false]} ];
function select_test(id, tests, ctrl_change) {
var element = document.getElementById(id);
element.focus();
var previousValue = element.value;
tests.forEach(function(data) {
var key = data.k;
synthesizeKey("VK_"+key, { shiftKey:false, metaKey:false, ctrlKey:true });
(ctrl_change ? isnot : is)(element.value, previousValue, "value should " +
(ctrl_change?"":"not ") + "have changed while testing CTRL+key " + key + " (id: " + id + ")");
previousValue = element.value;
synthesizeKey(" ", { shiftKey:false, metaKey:false, ctrlKey:true });
var sel = Array.prototype.slice.call(element.options).map(function(o){return o.selected})
is(""+sel, ""+data.s, "selected options match after CTRL+SPACE (after testing CTRL+key " + key + ") for (id: " + id + ")");
previousValue = element.value;
});
};
select_test("one", one, false);
select_test("two", two_1, true);
select_test("two", two_2, false);
if (navigator.platform.indexOf("Mac") == -1) {
select_test("three", three_1, true);
select_test("three", three_2, false);
} else {
todo(false, "Make these tests work on OSX");
}
SimpleTest.finish();
});
}
</script>
</head>
<body onload="test();">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=961363">Mozilla Bug 961363</a>
<div>
<ul>
<li>
<select id="one" multiple size="3">
<option>0</option>
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>
</li>
<li>
<select id="two" size="3">
<option>0</option>
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>
</li>
<li>
<select id="three" size="1">
<option>0</option>
<option selected>1</option>
<option>2</option>
<option>3</option>
</select>
</li>
</ul>
</div>
<pre id="test">
</pre>
</body>
</html>
|