delegateFocus-is-focusable.html (854B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>focus move tests caused by a call of Selection.addRange()</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="host"></div> 7 <script> 8 let host = document.getElementById("host"); 9 let shadow = host.attachShadow({ mode: "open", delegatesFocus: true }); 10 shadow.innerHTML = `<button>Focusable</button>`; 11 12 test(function() { 13 assert_true(SpecialPowers.Services.focus.elementIsFocusable(host, 0), "host is focusable"); 14 host.focus(); 15 assert_equals(document.activeElement, host, "Host is focused"); 16 assert_equals(shadow.activeElement, shadow.querySelector("button"), "Button is focused"); 17 assert_true(SpecialPowers.Services.focus.elementIsFocusable(host, 0), "host is still focusable"); 18 }, "isElementFocusable with delegateFocus"); 19 </script>