Skip to content

Truly independent web browser

2.0 KB
Raw Blame
<!DOCTYPE html>
<script src="include.js"></script>
<script src="work-test.js"></script>
<iframe id="frame" width="300" height="200" srcdoc="
    <style>html, body { margin: 0 }</style>
    <div id='cached' style='width: 100px; height: 40px; overflow: hidden'>
        <div style='width: 80px; height: 20px; overflow: hidden'></div>
    </div>
    <div id='dependent' style='width: 50vw; height: 10px; overflow: hidden'></div>
"></iframe>
<script>
    promiseTest(async () => {
        if (document.readyState !== "complete")
            await new Promise(resolve => window.addEventListener("load", resolve, { once: true }));
        __outputElement.style.display = "none";
        const contentDocument = frame.contentDocument;
        const contentInternals = frame.contentWindow.internals;
        contentInternals.updateLayoutForTesting();
        let result = "PASS: viewport resize reuses the independent subtree (work + checks)";
        try {
            runLayoutTestStep({
                name: "viewport resize reuses the independent subtree",
                mutate: () => {
                    frame.width = 200;
                    internals.updateLayoutForTesting();
                },
                expect: `
                    layout FULL
                      @viewport/block RUN (cache=bypass)
                        BlockContainer<HTML>/block RUN (cache=miss)
                          BlockContainer<DIV>#cached/block RUN (cache=miss)
                            BlockContainer<DIV>/block REUSE SUBTREE
                          BlockContainer<DIV>#dependent/block RUN (cache=miss)
                `,
                check: equal => {
                    equal(contentDocument.getElementById("cached").offsetWidth, 100, "cached width");
                    equal(contentDocument.getElementById("dependent").offsetWidth, 100, "dependent width");
                },
            }, contentInternals);
        } catch (error) {
            result = `FAIL: ${error}`;
        }
        __outputElement.style.display = "";
        println(result);
    });
</script>