Skip to content

Truly independent web browser

1.4 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<div style="display: flex">
    <div id="item1" style="z-index: 1">one</div>
    <div id="item2" style="z-index: 2">two</div>
</div>
<script>
    test(() => {
        const settle = () => document.elementFromPoint(0, 0);
        const report = () => internals.stackingContextStructureVerificationReport();
        const contexts = () => internals.dumpStackingContextTree().split("\n")
            .filter(line => line.includes("SC for"))
            .map(line => { const m = line.match(/#([A-Za-z0-9_-]+)/); return m ? m[1] : "(anon)"; })
            .join(" ");
        const lines = [];
        const check = (name) => {
            settle();
            const r = report();
            lines.push(`${name}: contexts=[${contexts()}] report-ok=${r === ""}`);
            if (r !== "")
                lines.push(r);
        };

        check("baseline");
        const work = layoutWork(() => {
            document.getElementById("item1").style.zIndex = "3";
            check("first item to z 3");
            document.getElementById("item1").style.zIndex = "1";
            check("first item back to z 1");
        });
        lines.push(`layout during the z-index changes: ${work.passes().join(" | ") || "(no layout)"}`);

        for (const line of lines)
            println(line);
    });
</script>