blob: 1497a7d6586676596c7e4880d33fb79df02ce507 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<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">
<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>
<script src="resources/utils.js"></script>
</head>
<body>
<iframe id="child" width="200" height="100"></iframe>
<script>
let parent_loaded = false;
let grand_child_loaded = false;
async_test(function(t) {
async function pingChildIfBothFramesLoaded() {
if (parent_loaded && grand_child_loaded) {
await waitUntilStableAutofocusState();
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") {
assert_unreached("The grandchild iframe shouldn't get focus");
} else if (event.data == "grand_child_is_not_focused") {
t.done();
}
}));
document.getElementById("child").src =
get_host_info().HTTP_NOTSAMESITE_ORIGIN + "/html/interaction/focus/the-autofocus-attribute/resources/child-iframe.html";
}, "Autofocus should not work in the same origin grand child iframe");
</script>
</body>
</html>
|