Bug 1931418 - Test that navigation isn't blocked due to recursive iframes. r=jjaschke

Differential Revision: https://phabricator.services.mozilla.com/D229586
This commit is contained in:
Andreas Farre 2024-11-20 12:11:46 +00:00
parent b9d8dbcb9e
commit b0a345167c
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<iframe id="static"></iframe>
<script>
const name = "frame_recursive_target";
const url = location.href;
const iframe = document.querySelector("iframe");
let isCrossOrigin = false;
try {
window.parent.location.hostname;
} catch (_) {
isCrossOrigin = true;
}
addEventListener("load", async () => {
await new Promise(resolve => {
iframe.addEventListener("load", resolve);
if (!isCrossOrigin) {
iframe.name = name;
}
iframe.src = url;
});
if (isCrossOrigin) {
const innerWin = iframe.contentWindow.document.querySelector("iframe");
await new Promise(resolve => {
innerWin.addEventListener("load", resolve);
window.open(url, name);
});
}
});
</script>

View File

@ -87,6 +87,7 @@ support-files = [
"frame_6_out_of_6.html",
"frame_recursive.html",
"frame_recursive_dynamic.html",
"frame_recursive_target.html",
"object_recursive_load.html",
"file_nested_srcdoc.html",
]

View File

@ -107,6 +107,16 @@
"about:blank"
],
},
{ // navigating shouldn't be blocked by recursion check
frameId: "navigationIsNotRecursive",
expectedLocations: [
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
"http://example.com/tests/docshell/test/navigation/frame_recursive_target.html",
"http://example.com/tests/docshell/test/navigation/frame_recursive_target.html",
"http://example.com/tests/docshell/test/navigation/frame_recursive_target.html",
"about:blank"
],
},
];
async function checkRecursiveLoad(level) {
@ -172,6 +182,7 @@
<object width="400" height="300" id="recursiveObject" data="http://sub2.xn--lt-uia.mochi.test:8888/tests/docshell/test/navigation/object_recursive_load.html"></object>
<iframe id="nestedSrcdoc" srcdoc="Srcdoc that will embed an iframe &lt;iframe id=&quot;static&quot; src=&quot;http://example.com/tests/docshell/test/navigation/file_nested_srcdoc.html&quot;&gt;&lt;/iframe&gt;"></iframe>
<iframe style="height: 100vh; width:25%;" id="dynamicrecursive" src="http://example.com/tests/docshell/test/navigation/frame_recursive_dynamic.html"></iframe>
<iframe style="height: 100vh; width:25%;" id="navigationIsNotRecursive" src="http://example.com/tests/docshell/test/navigation/frame_recursive_target.html"></iframe>
</div>
</body>
</html>