Skip to content

Truly independent web browser

1.2 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script>
    // A process holding local file content may read local files, so script in a sandboxed iframe must not run there,
    // whatever URL the iframe has. The iframes share a process of their own, and an iframe that keeps its origin with
    // allow-same-origin stays with the page.
    promiseTest(async () => {
        const loadIframe = async (setup, sandbox) => {
            const iframe = document.createElement("iframe");
            iframe.sandbox = sandbox;
            setup(iframe);
            const loaded = new Promise(resolve => iframe.addEventListener("load", resolve, { once: true }));
            document.body.appendChild(iframe);
            await loaded;
        };

        const fileUrl = "../../../data/iframe-test-content-1.html";
        await loadIframe(iframe => (iframe.src = fileUrl), "allow-scripts");
        await loadIframe(iframe => (iframe.srcdoc = "<p>srcdoc</p>"), "allow-scripts");
        await loadIframe(iframe => (iframe.src = "data:text/html,<p>data</p>"), "allow-scripts");
        await loadIframe(iframe => (iframe.src = fileUrl), "allow-same-origin");

        println(internals.dumpSiteIsolationProcessTree().trimEnd());
    });
</script>