test_focus_scrollable_fieldset.html (1629B)
1 <!doctype html> 2 <title>Test for bug 1351248</title> 3 <script src="/tests/SimpleTest/SimpleTest.js"></script> 4 <script src="/tests/SimpleTest/EventUtils.js"></script> 5 <style> 6 fieldset { 7 overflow: auto; 8 height: 1em; 9 width: 1em; 10 } 11 </style> 12 <input type="text" id="start"> 13 14 <fieldset> 15 <input type="text"> 16 <input type="text"> 17 <input type="text"> 18 <input type="text"> 19 <input type="text"> 20 <input type="text"> 21 </fieldset> 22 23 <input type="text" id="end"> 24 <script> 25 SimpleTest.waitForExplicitFinish(); 26 SimpleTest.waitForFocus(async function() { 27 // Enable Full Keyboard Access emulation on Mac. 28 if (navigator.platform.indexOf("Mac") === 0) { 29 await SpecialPowers.pushPrefEnv({"set": [["accessibility.tabfocus", 7]]}); 30 } 31 32 const start = document.getElementById("start"); 33 34 start.focus(); 35 36 const end = document.getElementById("end"); 37 38 is(document.activeElement, start, "Focus moved sanely"); 39 40 let lastActiveElement = start; 41 let stack = [start]; 42 43 do { 44 synthesizeKey("KEY_Tab"); 45 isnot(document.activeElement, lastActiveElement, "Focus should've moved once per tab keypress"); 46 lastActiveElement = document.activeElement; 47 stack.push(lastActiveElement); 48 } while (document.activeElement != end) 49 50 is(stack.length, document.querySelectorAll("input").length + 1, "Fieldset should be focusable"); 51 52 do { 53 let previous = stack.pop(); 54 is(document.activeElement, previous, "Focus should've moved backwards as expected"); 55 synthesizeKey("KEY_Tab", {shiftKey: true}); 56 } while (stack.length); 57 58 SimpleTest.finish(); 59 }); 60 </script>