same-origin-autofocus.html (1837B)
1 <!doctype html> 2 <html> 3 <head> 4 <meta charset=utf-8> 5 <meta name="assert" content="`autofocus` should not work in the same origin iframe if there is a cross-origin iframe between the parent and the same origin iframe"> 6 <title>autofocus in the same origin grand child iframe</title> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 <script src="/resources/testdriver.js"></script> 10 <script src="/resources/testdriver-vendor.js"></script> 11 <script src="/common/get-host-info.sub.js"></script> 12 <script src="resources/utils.js"></script> 13 </head> 14 <body> 15 <iframe id="child" width="200" height="100"></iframe> 16 <script> 17 let parent_loaded = false; 18 let grand_child_loaded = false; 19 20 async_test(function(t) { 21 async function pingChildIfBothFramesLoaded() { 22 if (parent_loaded && grand_child_loaded) { 23 await waitUntilStableAutofocusState(); 24 frames[0].postMessage("report_focus_state", "*"); 25 } 26 } 27 28 window.addEventListener("load", t.step_func(event => { 29 parent_loaded = true; 30 pingChildIfBothFramesLoaded(); 31 })); 32 33 window.addEventListener("message", t.step_func(event => { 34 if (event.data == "ready") { 35 grand_child_loaded = true; 36 pingChildIfBothFramesLoaded(); 37 } else if (event.data == "grand_child_is_focused") { 38 assert_unreached("The grandchild iframe shouldn't get focus"); 39 } else if (event.data == "grand_child_is_not_focused") { 40 t.done(); 41 } 42 })); 43 document.getElementById("child").src = 44 get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html"; 45 }, "Autofocus should not work in the same origin grand child iframe"); 46 </script> 47 </body> 48 </html>