test_select_collapsed_page_keys.html (1291B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test for page up/down in collapsed select (bug 1488828)</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <script src="/tests/SimpleTest/EventUtils.js"></script> 8 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 9 <script> 10 SimpleTest.waitForExplicitFinish(); 11 12 function test() { 13 let select = document.getElementById("select"); 14 select.focus(); 15 is(select.selectedIndex, 0, "Option 0 initially selected"); 16 synthesizeKey("KEY_PageDown", {}); 17 ok(select.selectedIndex >= 2, "PageDown skips more than 1 option"); 18 ok(select.selectedIndex < 49, "PageDown does not move to the last option"); 19 synthesizeKey("KEY_PageUp", {}); 20 is(select.selectedIndex, 0, "PageUp skips more than 1 option"); 21 SimpleTest.finish(); 22 } 23 </script> 24 </head> 25 <body onload="test()"> 26 <div> 27 <select id="select" size="1"> 28 <option selected>0</option> 29 </select> 30 <script> 31 // Add more options so we have 50 in total. 32 let select = document.getElementById("select"); 33 for (let i = 1; i <= 49; ++i) { 34 let option = document.createElement("option"); 35 option.textContent = i; 36 select.appendChild(option); 37 } 38 </script> 39 </div> 40 <pre id="test"> 41 </pre> 42 </body> 43 </html>