| <!DOCTYPE html> |
| <html> |
| <head> |
| <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>Element.focus() shouldn't work in cross-origin iframe without user interaction.</h1> |
| <iframe id="child" width="200" height="100"></iframe> |
| |
| <script> |
| let parent_loaded = false; |
| let child_loaded = false; |
| |
| async_test(function(t) { |
| function pingChildIfBothFramesLoaded() { |
| if (parent_loaded && child_loaded) |
| frames[0].postMessage("attempt_to_focus", "*"); |
| } |
| |
| window.addEventListener("load", t.step_func(event => { |
| parent_loaded = true; |
| pingChildIfBothFramesLoaded(); |
| })); |
| |
| window.addEventListener("message", t.step_func(event => { |
| if (event.data == "child_loaded") { |
| child_loaded = true; |
| pingChildIfBothFramesLoaded(); |
| } else if (event.data == "child_is_focused") { |
| assert_unreached("The iframe shouldn't get focus"); |
| } else if (event.data == "child_is_not_focused") { |
| t.done(); |
| } |
| })); |
| document.getElementById("child").src = |
| get_host_info().HTTP_REMOTE_ORIGIN + "/WebKit/html/interaction/focus/resources/child-focus-element.html"; |
| }, "Element.focus() shouldn't work in cross-origin iframe without user interaction"); |
| </script> |
| </body> |
| </html> |