Skip to content

Truly independent web browser

1.9 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script>
    // A page grants one rendering opportunity per update, however many local roots it has, and it has a second one
    // once it hosts a grandchild same origin with the top document under an isolated iframe. Consuming the
    // opportunity once per local root left none for the update, which then rendered no document of the page: its
    // animation frame callbacks stopped running and it painted nothing.
    // This page is served over HTTP so that the grandchild can be same origin with it.
    promiseTest(async () => {
        const httpServer = httpTestServer();

        const animationFrameFires = async () => {
            let fired = false;
            requestAnimationFrame(() => (fired = true));
            return waitForCondition(() => fired);
        };

        const addFrame = async url => {
            const iframe = document.createElement("iframe");
            iframe.src = url;
            await new Promise(resolve => {
                iframe.addEventListener("load", resolve);
                document.body.appendChild(iframe);
            });
        };

        println(`animation frame with no iframe: ${await animationFrameFires()}`);

        const grandchildUrl = await httpServer.createEcho("GET", "/oop-rendering-grandchild", {
            status: 200, headers: { "Content-Type": "text/html" }, body: `<!DOCTYPE html>grandchild`,
        });

        const childUrl = new URL(await httpServer.createEcho("GET", "/oop-rendering-child", {
            status: 200, headers: { "Content-Type": "text/html" }, body: `<!DOCTYPE html><iframe src="${grandchildUrl}"></iframe>`,
        }));
        childUrl.hostname = uniqueLocalhostHostname("oop-rendering");

        await addFrame(childUrl);
        println(`animation frame with a hosted grandchild: ${await animationFrameFires()}`);
        println(internals.dumpSiteIsolationProcessTree().trimEnd());
    });
</script>