autofocus-dialog.html (1252B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/interaction.html#the-autofocus-attribute"> 4 <link rel='author' href='mailto:masonf@chromium.org'> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="resources/utils.js"></script> 8 9 <body> 10 <script> 11 promise_test(async t => { 12 let w = window.open('/common/blank.html'); 13 await waitForLoad(w); 14 t.add_cleanup(() => { w.close(); }); 15 w.document.body.innerHTML = '<dialog><div tabindex=0 autofocus></dialog><input autofocus>'; 16 await waitUntilStableAutofocusState(w); 17 assert_equals(w.document.activeElement.tagName, 'INPUT'); 18 }, '<dialog> can contain autofocus, without stopping page autofocus content from working'); 19 20 promise_test(async t => { 21 let w = window.open('/common/blank.html'); 22 await waitForLoad(w); 23 t.add_cleanup(() => { w.close(); }); 24 w.document.body.innerHTML = '<dialog><div tabindex=0 autofocus></dialog><input autofocus>'; 25 await waitUntilStableAutofocusState(w); 26 w.document.querySelector('dialog').show(); 27 assert_equals(w.document.activeElement.tagName, 'DIV'); 28 }, '<dialog>-contained autofocus element gets focused when the dialog is shown'); 29 </script>