Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / select-popup-pagekeys.html
blob6828ab1c202eb96d7ede3415ba6eee8c0d396cd3
1 <html>
2 <head>
3 <title>SELECT pop-up page keys test</title>
4 <script>
5 function log(s)
7 document.getElementById('console').appendChild(document.createTextNode(s + "\n"));
10 function sendKey(element, key) {
11 if (window.testRunner) {
12 key = key.substr(0,1).toLowerCase() + key.substr(1); // lowercase 1st letter for eventSender
13 eventSender.keyDown(key);
14 } else {
15 var event = document.createEvent("KeyboardEvents");
16 event.initKeyboardEvent("keydown", true, true, document.defaultView, key, 0,
17 false, false, false, false, false);
18 element.dispatchEvent(event);
22 function sendKeyAndExpectIndex(selectId, key, initialIndex, expectedIndex) {
23 var select = document.getElementById(selectId);
24 clearSelection(select);
25 select.focus();
26 select.selectedIndex = initialIndex;
27 if (select.selectedIndex != initialIndex) {
28 log("FAIL: can't set selectedIndex to " + initialIndex + ' (is '
29 + select.selectedIndex + ')');
30 return false;
32 sendKey(select, key);
33 if (select.selectedIndex != expectedIndex) {
34 log('FAIL: selectedIndex should be ' + expectedIndex + ' (is ' +
35 select.selectedIndex + ') after a ' + key +
36 ' from index ' + initialIndex);
37 return false;
39 return true;
42 function clearSelection(select) {
43 for (i = 0; i < select.options.length; i++)
44 select.options[i].selected = false;
47 function testPageDownNoDisabledElements() {
48 var passed = true;
50 passed = sendKeyAndExpectIndex('ss', "PageDown", 0, 3) && passed;
51 passed = sendKeyAndExpectIndex('ss', "PageDown", 1, 4) && passed;
52 passed = sendKeyAndExpectIndex('ss', "PageDown", 2, 5) && passed;
53 passed = sendKeyAndExpectIndex('ss', "PageDown", 3, 6) && passed;
54 passed = sendKeyAndExpectIndex('ss', "PageDown", 4, 6) && passed;
55 passed = sendKeyAndExpectIndex('ss', "PageDown", 5, 6) && passed;
56 passed = sendKeyAndExpectIndex('ss', "PageDown", 6, 6) && passed;
58 if (passed)
59 log('PASS: testPageDownNoDisabledElements passed');
60 return passed;
63 function testPageUpNoDisabledElements() {
64 var passed = true;
66 passed = sendKeyAndExpectIndex('ss', "PageUp", 6, 3) && passed;
67 passed = sendKeyAndExpectIndex('ss', "PageUp", 5, 2) && passed;
68 passed = sendKeyAndExpectIndex('ss', "PageUp", 4, 1) && passed;
69 passed = sendKeyAndExpectIndex('ss', "PageUp", 3, 0) && passed;
70 passed = sendKeyAndExpectIndex('ss', "PageUp", 2, 0) && passed;
71 passed = sendKeyAndExpectIndex('ss', "PageUp", 1, 0) && passed;
72 passed = sendKeyAndExpectIndex('ss', "PageUp", 0, 0) && passed;
74 if (passed)
75 log('PASS: testPageUpNoDisabledElements passed');
76 return passed;
79 function testHomeNoDisabledElements() {
80 var passed = true;
82 passed = sendKeyAndExpectIndex('ss', "Home", 6, 0) && passed;
83 passed = sendKeyAndExpectIndex('ss', "Home", 5, 0) && passed;
84 passed = sendKeyAndExpectIndex('ss', "Home", 4, 0) && passed;
85 passed = sendKeyAndExpectIndex('ss', "Home", 3, 0) && passed;
86 passed = sendKeyAndExpectIndex('ss', "Home", 2, 0) && passed;
87 passed = sendKeyAndExpectIndex('ss', "Home", 1, 0) && passed;
88 passed = sendKeyAndExpectIndex('ss', "Home", 0, 0) && passed;
90 if (passed)
91 log('PASS: testHomeNoDisabledElements passed');
92 return passed;
95 function testEndNoDisabledElements() {
96 var passed = true;
98 passed = sendKeyAndExpectIndex('ss', "End", 6, 6) && passed;
99 passed = sendKeyAndExpectIndex('ss', "End", 5, 6) && passed;
100 passed = sendKeyAndExpectIndex('ss', "End", 4, 6) && passed;
101 passed = sendKeyAndExpectIndex('ss', "End", 3, 6) && passed;
102 passed = sendKeyAndExpectIndex('ss', "End", 2, 6) && passed;
103 passed = sendKeyAndExpectIndex('ss', "End", 1, 6) && passed;
104 passed = sendKeyAndExpectIndex('ss', "End", 0, 6) && passed;
106 if (passed)
107 log('PASS: testEndNoDisabledElements passed');
108 return passed;
111 function testPageDownWithDisabledElements() {
112 var passed = true;
114 passed = sendKeyAndExpectIndex('ssd', "PageDown", 1, 4) && passed;
115 passed = sendKeyAndExpectIndex('ssd', "PageDown", 2, 5) && passed;
116 passed = sendKeyAndExpectIndex('ssd', "PageDown", 4, 6) && passed;
117 passed = sendKeyAndExpectIndex('ssd', "PageDown", 5, 6) && passed;
118 passed = sendKeyAndExpectIndex('ssd', "PageDown", 6, 6) && passed;
120 if (passed)
121 log('PASS: testPageDownWithDisabledElements passed');
122 return passed;
125 function testPageUpWithDisabledElements() {
126 var passed = true;
128 passed = sendKeyAndExpectIndex('ssd', "PageUp", 6, 2) && passed;
129 passed = sendKeyAndExpectIndex('ssd', "PageUp", 5, 2) && passed;
130 passed = sendKeyAndExpectIndex('ssd', "PageUp", 4, 1) && passed;
131 passed = sendKeyAndExpectIndex('ssd', "PageUp", 2, 1) && passed;
132 passed = sendKeyAndExpectIndex('ssd', "PageUp", 1, 1) && passed;
134 if (passed)
135 log('PASS: testPageUpWithDisabledElements passed');
136 return passed;
139 function testHomeWithDisabledElements() {
140 var passed = true;
142 passed = sendKeyAndExpectIndex('ssd', "Home", 7, 1) && passed;
143 passed = sendKeyAndExpectIndex('ssd', "Home", 6, 1) && passed;
144 passed = sendKeyAndExpectIndex('ssd', "Home", 5, 1) && passed;
145 passed = sendKeyAndExpectIndex('ssd', "Home", 4, 1) && passed;
146 passed = sendKeyAndExpectIndex('ssd', "Home", 3, 1) && passed;
147 passed = sendKeyAndExpectIndex('ssd', "Home", 2, 1) && passed;
148 passed = sendKeyAndExpectIndex('ssd', "Home", 1, 1) && passed;
149 passed = sendKeyAndExpectIndex('ssd', "Home", 0, 1) && passed;
151 if (passed)
152 log('PASS: testHomeWithDisabledElements passed');
153 return passed;
156 function testEndWithDisabledElements() {
157 var passed = true;
159 passed = sendKeyAndExpectIndex('ssd', "End", 7, 6) && passed;
160 passed = sendKeyAndExpectIndex('ssd', "End", 6, 6) && passed;
161 passed = sendKeyAndExpectIndex('ssd', "End", 5, 6) && passed;
162 passed = sendKeyAndExpectIndex('ssd', "End", 4, 6) && passed;
163 passed = sendKeyAndExpectIndex('ssd', "End", 3, 6) && passed;
164 passed = sendKeyAndExpectIndex('ssd', "End", 2, 6) && passed;
165 passed = sendKeyAndExpectIndex('ssd', "End", 1, 6) && passed;
166 passed = sendKeyAndExpectIndex('ssd', "End", 0, 6) && passed;
168 if (passed)
169 log('PASS: testEndWithDisabledElements passed');
170 return passed;
173 function test()
175 try{
176 if (window.testRunner)
177 testRunner.dumpAsText();
178 var passed = true;
179 passed = testPageDownNoDisabledElements() && passed;
180 passed = testPageUpNoDisabledElements() && passed;
181 passed = testHomeNoDisabledElements() && passed;
182 passed = testEndNoDisabledElements() && passed;
184 passed = testPageDownWithDisabledElements() && passed;
185 passed = testPageUpWithDisabledElements() && passed;
186 passed = testHomeWithDisabledElements() && passed;
187 passed = testEndWithDisabledElements() && passed;
189 if (passed)
190 log('\nPASS: ALL TESTS SUCCEEDED');
191 else
192 log('\nFAIL: SOME TESTS FAILED (SEE ABOVE)');
193 log('');
194 } catch (exception) {
195 log('\nFAIL: Threw exception: ' + exception);
198 </script>
199 </head>
200 <body onload="test()">
201 <p>This test verifies that the Home/End/PageUp/PageDown keys work correctly
202 for pop-up &lt;select&gt; elements that have focus but are not currently popped-up.</p>
203 <p>Output below is a series of PASS or FAIL lines showing expected and actual selection indexes,
204 followed by a single PASS or FAIL for the status of the entire test.<p>
205 <p>NOTE: This test will fail on Mac OS, on which these keys are NOT supposed to change
206 the selection of a focused pop-up.</p>
207 <hr>
208 <form>
209 <select name="singleselect" id="ss">
210 <option value="0">0 </option>
211 <option value="1">1 </option>
212 <option value="2">2 </option>
213 <option value="3">3 </option>
214 <option value="4">4 </option>
215 <option value="5">5 </option>
216 <option value="6">6 </option>
217 </select>
218 <select name="singleselectwithdisabled" id="ssd">
219 <option value="0" disabled="true">0 </option>
220 <option value="1">1 </option>
221 <option value="2">2 </option>
222 <option value="3" disabled="true">3 </option>
223 <option value="4">4 </option>
224 <option value="5">5 </option>
225 <option value="6">6 </option>
226 <option value="7" disabled = "true">7 </option>
227 </select>
228 </form>
229 <pre id="console"></pre>
230 </body>
231 </html>