test_focus_scrollable_input.html (1663B)
1 <!doctype html> 2 <title>Test for bug 1617342</title> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <script src="/tests/SimpleTest/EventUtils.js"></script> 5 <style> 6 input { 7 /* Make them small enough that any value overflows */ 8 height: 10px; 9 width: 10px; 10 box-sizing: border-box; 11 font: 16px/1 monospace; 12 } 13 </style> 14 <input type="text" id="start" value="aaaaaaaaaa"> 15 16 <input type="text" value="aaaaaaaaaa"> 17 <input type="number" value="1111"> 18 <input type="search" value="aaaaaaa"> 19 <input type="url" value="https://fooooooooooo"> 20 21 <input type="text" id="end" value="aaaaaaaaaa"> 22 <script> 23 SimpleTest.waitForExplicitFinish(); 24 SimpleTest.waitForFocus(async function() { 25 // Enable Full Keyboard Access emulation on Mac. 26 if (navigator.platform.indexOf("Mac") === 0) { 27 await SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}); 28 } 29 30 const start = document.getElementById("start"); 31 32 start.focus(); 33 34 const end = document.getElementById("end"); 35 36 is(document.activeElement, start, "Focus moved sanely"); 37 38 let lastActiveElement = start; 39 let stack = [start]; 40 41 do { 42 synthesizeKey("KEY_Tab"); 43 isnot(document.activeElement, lastActiveElement, "Focus should've moved once per tab keypress"); 44 lastActiveElement = document.activeElement; 45 stack.push(lastActiveElement); 46 } while (document.activeElement != end) 47 48 do { 49 let previous = stack.pop(); 50 is(document.activeElement, previous, "Focus should've moved backwards as expected"); 51 synthesizeKey("KEY_Tab", {shiftKey: true}); 52 } while (stack.length); 53 54 SimpleTest.finish(); 55 }); 56 </script>