nested-focus-within-iframe-focus-event.html (986B)
1 <!doctype html> 2 <head> 3 <meta charset=utf-8> 4 <meta name="viewport" content="width=device-width,initial-scale=1"> 5 <title>Test calling dialog focusing steps in navigable's focus handler</title> 6 <script src=/resources/testharness.js></script> 7 <script src=/resources/testharnessreport.js></script> 8 </head> 9 <body> 10 <iframe id="iframe" srcdoc="<dialog>Hello</dialog>"></iframe> 11 </body> 12 <script> 13 // https://github.com/whatwg/html/pull/11182 14 window.onload = function() { 15 async_test((t) => { 16 iframe.addEventListener("focus", function() { 17 const dialog = iframe.contentDocument.body.querySelector("dialog"); 18 dialog.showModal(); 19 // If `lock-for-focus` is implemented, showModal() can't 20 // trigger the dialog-focusing-steps, hence the activeElement 21 // shouldn't be the dialog. 22 assert_equals(iframe.contentDocument.activeElement, dialog); 23 t.done(); 24 }) 25 26 iframe.focus(); 27 }, "dialog.focus() in navigable's focus handler"); 28 } 29 </script>