|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=672810 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 672810</title> |
|
8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <script type="application/javascript" 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=672810">Mozilla Bug 672810</a> |
|
14 <p id="display"></p> |
|
15 <div id="content"> |
|
16 <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> |
|
17 <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> |
|
18 <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> |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script type="application/javascript"> |
|
22 |
|
23 /** Test for Bug 672810 **/ |
|
24 |
|
25 SimpleTest.waitForExplicitFinish(); |
|
26 |
|
27 SimpleTest.waitForFocus(function() { |
|
28 var sel = document.getElementsByTagName('select'); |
|
29 |
|
30 sel[0].addEventListener('focus', function() { |
|
31 s = sel[0]; |
|
32 s.removeEventListener('focus', arguments.callee, false); |
|
33 synthesizeKey('VK_DOWN', {}); |
|
34 is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); |
|
35 synthesizeKey('VK_DOWN', {ctrlKey: true}); |
|
36 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
37 ok(!s[1].selected,s.id + ": CTRL+DOWN did not select 2nd option"); |
|
38 synthesizeKey('VK_DOWN', {ctrlKey: true}); |
|
39 synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); |
|
40 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
41 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); |
|
42 ok(s[2].selected,s.id + ": 3rd option is selected"); |
|
43 ok(s[3].selected,s.id + ": 4th option is selected"); |
|
44 ok(!s[4].selected,s.id + ": 5th option is unselected"); |
|
45 synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); |
|
46 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
47 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); |
|
48 ok(s[2].selected,s.id + ": 3rd option is still selected"); |
|
49 ok(s[3].selected,s.id + ": 4th option is still selected"); |
|
50 ok(s[4].selected,s.id + ": 5th option is selected"); |
|
51 ok(!s[5].selected,s.id + ": 6th option is unselected"); |
|
52 synthesizeKey('VK_UP', {ctrlKey: true, shiftKey: true}); |
|
53 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
54 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); |
|
55 ok(s[2].selected,s.id + ": 3rd option is still selected"); |
|
56 ok(s[3].selected,s.id + ": 4th option is still selected"); |
|
57 ok(s[4].selected,s.id + ": 5th option is still selected"); |
|
58 ok(!s[5].selected,s.id + ": 6th option is still unselected"); |
|
59 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
60 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
61 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); |
|
62 ok(s[2].selected,s.id + ": 3rd option is still selected"); |
|
63 ok(!s[3].selected,s.id + ": 4th option is unselected"); |
|
64 ok(s[4].selected,s.id + ": 5th option is still selected"); |
|
65 ok(!s[5].selected,s.id + ": 6th option is still unselected"); |
|
66 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
67 is(s.selectedIndex,0, s.id + ": first option is still selected"); |
|
68 ok(!s[1].selected,s.id + ": 2nd option is still unselected"); |
|
69 ok(s[2].selected,s.id + ": 3rd option is still selected"); |
|
70 ok(s[3].selected,s.id + ": 4th option is selected"); |
|
71 ok(s[4].selected,s.id + ": 5th option is still selected"); |
|
72 ok(!s[5].selected,s.id + ": 6th option is still unselected"); |
|
73 setTimeout(function(){sel[1].focus()},0); |
|
74 }, false); |
|
75 sel[1].addEventListener('focus', function() { |
|
76 s = sel[1]; |
|
77 s.removeEventListener('focus', arguments.callee, false); |
|
78 synthesizeKey('VK_DOWN', {}); |
|
79 is(s.selectedIndex,0, s.id + ": initial DOWN selects first option"); |
|
80 synthesizeKey('VK_DOWN', {ctrlKey: true}); |
|
81 is(s.selectedIndex,1, s.id + ": 2nd option is selected"); |
|
82 ok(!s[0].selected,s.id + ": CTRL+DOWN deselected first option"); |
|
83 synthesizeKey('VK_DOWN', {ctrlKey: true}); |
|
84 synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); |
|
85 is(s.selectedIndex,3, s.id + ": 4th option is selected"); |
|
86 ok(!s[1].selected,s.id + ": CTRL+SHIFT+DOWN deselected 2nd option"); |
|
87 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
88 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); |
|
89 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
90 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); |
|
91 setTimeout(function(){sel[2].focus()},0); |
|
92 }, false); |
|
93 sel[2].addEventListener('focus', function() { |
|
94 s = sel[2]; |
|
95 s.removeEventListener('focus', arguments.callee, false); |
|
96 synthesizeKey('VK_DOWN', {}); |
|
97 is(s.selectedIndex,1, s.id + ": initial DOWN selects 2nd option"); |
|
98 synthesizeKey('VK_DOWN', {ctrlKey: true}); |
|
99 is(s.selectedIndex,2, s.id + ": 3rd option is selected"); |
|
100 ok(!s[1].selected,s.id + ": CTRL+DOWN deselected 2nd option"); |
|
101 synthesizeKey('VK_DOWN', {ctrlKey: true, shiftKey: true}); |
|
102 is(s.selectedIndex,3, s.id + ": 4th option is selected"); |
|
103 ok(!s[2].selected,s.id + ": CTRL+SHIFT+DOWN deselected 3rd option"); |
|
104 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
105 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); |
|
106 synthesizeKey(' ', {ctrlKey: true, shiftKey: true}); |
|
107 is(s.selectedIndex,3, s.id + ": 4th option is still selected"); |
|
108 setTimeout(function(){SimpleTest.finish()},0); |
|
109 }, false); |
|
110 sel[0].focus(); |
|
111 }); |
|
112 |
|
113 </script> |
|
114 </pre> |
|
115 </body> |
|
116 </html> |