dialog-autofocus-just-once.html (888B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="/html/interaction/focus/the-autofocus-attribute/resources/utils.js"></script> 5 <body> 6 <dialog> 7 <input> 8 <input autofocus> 9 </dialog> 10 <script> 11 // https://github.com/whatwg/html/issues/4788 12 promise_test(async () => { 13 const dialog = document.querySelector('dialog'); 14 dialog.show(); 15 assert_equals(document.activeElement, dialog.querySelector('[autofocus]'), 16 'dialog.show() should set focus on a descendant element with an ' + 17 'autofocus attribute.'); 18 document.activeElement.blur(); 19 await waitUntilStableAutofocusState(); 20 assert_equals(document.activeElement, document.body, 21 'Non-dialog autofocus processing should be skipped.'); 22 }, 'An autofocus element in a dialog element should not try to get focus twice.'); 23 </script> 24 </body>