| <!doctype html> |
| <html> |
| <head> |
| <meta charset=utf-8> |
| <meta name="assert" content="`autofocus` should work in the same origin iframe even if there is a cross-origin iframe between the parent and the same origin iframe"> |
| <title>autofocus in the same origin grand child iframe</title> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| <script src="/resources/testdriver.js"></script> |
| <script src="/resources/testdriver-vendor.js"></script> |
| <script src="/common/get-host-info.sub.js"></script> |
| </head> |
| <body> |
| <h1>Autofocus should work in the same origin grand child iframe.</h1> |
| <iframe id="child" width="200" height="100"></iframe> |
| <script> |
| let parent_loaded = false; |
| let grand_child_loaded = false; |
| |
| async_test(function(t) { |
| function pingChildIfBothFramesLoaded() { |
| if (parent_loaded && grand_child_loaded) |
| frames[0].postMessage("report_focus_state", "*"); |
| } |
| |
| window.addEventListener("load", t.step_func(event => { |
| parent_loaded = true; |
| pingChildIfBothFramesLoaded(); |
| })); |
| |
| window.addEventListener("message", t.step_func(event => { |
| if (event.data == "ready") { |
| grand_child_loaded = true; |
| pingChildIfBothFramesLoaded(); |
| } else if (event.data == "grand_child_is_focused") { |
| t.done(); |
| } else if (event.data == "grand_child_is_not_focused") { |
| assert_unreached("The iframe shouldn't get focus"); |
| } |
| })); |
| document.getElementById("child").src = |
| get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html"; |
| }, "Autofocus should work in the same origin grand child iframe"); |
| </script> |
| </body> |
| </html> |