Truly independent web browser
Tests/LibWeb: Show where sandboxed iframes of one site are hosted
Andreas Kling67ba0de3ed09
diff --git a/Tests/LibWeb/Text/expected/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.txt b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.txtnew file mode 100644index 00000000000..0f1c2bae72f--- /dev/null+++ b/Tests/LibWeb/Text/expected/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.txt@@ -0,0 +1,6 @@+WebContent#0+ iframe#0: remote WebContent#1+ iframe#1: remote WebContent#2+ iframe#2: remote WebContent#3+ iframe#3: remote WebContent#4+ iframe#4: remote WebContent#5diff --git a/Tests/LibWeb/Text/input/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.html b/Tests/LibWeb/Text/input/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.htmlnew file mode 100644index 00000000000..e271a3e31ad--- /dev/null+++ b/Tests/LibWeb/Text/input/SiteIsolation/iframe/sandboxed-iframes-of-a-site-share-a-process.html@@ -0,0 +1,54 @@+<!DOCTYPE html>+<script src="../../include.js"></script>+<script>+ // Sandboxed documents loaded over HTTP(S) share one process per site of their URLs, whichever way a redirect took+ // them there. That process hosts only sandboxed documents, so it is not the process of the site's other documents.+ promiseTest(async () => {+ const httpServer = httpTestServer();++ const childUrl = new URL(+ await httpServer.createEcho("GET", "/sandboxed-child", {+ status: 200,+ headers: { "Content-Type": "text/html" },+ body: "<!DOCTYPE html>child",+ })+ );++ const site = uniqueLocalhostHostname("sandboxed-site");+ const urlOnHost = (url, hostname) => {+ const result = new URL(url);+ result.hostname = hostname;+ return result;+ };++ const sameSiteRedirect = new URL(+ await httpServer.createEcho("GET", "/sandboxed-same-site-redirect", {+ status: 302,+ headers: { Location: childUrl.pathname },+ })+ );+ const crossSiteRedirect = new URL(+ await httpServer.createEcho("GET", "/sandboxed-cross-site-redirect", {+ status: 302,+ headers: { Location: urlOnHost(childUrl, `c.${site}`).href },+ })+ );++ const loadIframe = async (url, sandbox) => {+ const iframe = document.createElement("iframe");+ if (sandbox !== null) iframe.sandbox = sandbox;+ iframe.src = url;+ const loaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));+ document.body.appendChild(iframe);+ await loaded;+ };++ await loadIframe(urlOnHost(childUrl, `a.${site}`), "");+ await loadIframe(urlOnHost(sameSiteRedirect, `b.${site}`), "");+ await loadIframe(urlOnHost(crossSiteRedirect, uniqueLocalhostHostname("redirecting-site")), "");+ await loadIframe(urlOnHost(childUrl, uniqueLocalhostHostname("other-sandboxed-site")), "");+ await loadIframe(urlOnHost(childUrl, `a.${site}`), null);++ println(internals.dumpSiteIsolationProcessTree().trimEnd());+ });+</script>