Truly independent web browser
Tests: Add a test for how deep frames can nest
Andreas Kling3cf54753dc0b
diff --git a/Tests/LibWeb/Text/data/nested-iframe-with-distinct-url.html b/Tests/LibWeb/Text/data/nested-iframe-with-distinct-url.htmlnew file mode 100644index 00000000000..4e33597f3ec--- /dev/null+++ b/Tests/LibWeb/Text/data/nested-iframe-with-distinct-url.html@@ -0,0 +1,21 @@+<!DOCTYPE html>+<script>+ // Nests a copy of itself under a new URL, so no ancestor URL ever matches.+ const depth = Number(new URLSearchParams(location.search).get("depth") ?? 1);+ const nextURL = `nested-iframe-with-distinct-url.html?depth=${depth + 1}`;+ const iframe = document.createElement("iframe");+ if (depth < 30)+ iframe.src = nextURL;+ document.documentElement.appendChild(iframe);++ window.onmessage = () => {+ // A frame that did not load keeps its initial about:blank document.+ if (iframe.contentDocument?.URL !== "about:blank") {+ iframe.contentWindow.postMessage("probe", "*");+ return;+ }+ const blankIframe = document.createElement("iframe");+ blankIframe.onload = () => top.postMessage({ depth }, "*");+ document.documentElement.appendChild(blankIframe);+ };+</script>diff --git a/Tests/LibWeb/Text/expected/HTML/iframe-nesting-depth-limit.txt b/Tests/LibWeb/Text/expected/HTML/iframe-nesting-depth-limit.txtnew file mode 100644index 00000000000..ba34c589ff0--- /dev/null+++ b/Tests/LibWeb/Text/expected/HTML/iframe-nesting-depth-limit.txt@@ -0,0 +1 @@+Deepest nested document: 30diff --git a/Tests/LibWeb/Text/input/HTML/iframe-nesting-depth-limit.html b/Tests/LibWeb/Text/input/HTML/iframe-nesting-depth-limit.htmlnew file mode 100644index 00000000000..ea08cde46cb--- /dev/null+++ b/Tests/LibWeb/Text/input/HTML/iframe-nesting-depth-limit.html@@ -0,0 +1,12 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<iframe id="frame" src="../../data/nested-iframe-with-distinct-url.html"></iframe>+<script>+ asyncTest(done => {+ window.onmessage = event => {+ println(`Deepest nested document: ${event.data.depth}`);+ done();+ };+ window.addEventListener("load", () => frame.contentWindow.postMessage("probe", "*"));+ });+</script>