Skip to content

Truly independent web browser

1.5 KB
Raw Blame
<!doctype html>
<script src="../../include.js"></script>
<style>
    .hidden { display: none; }
    .changed .target { padding-left: 13px; }
</style>
<script>
    test(() => {
        for (const shadow of [false, true]) {
            const outer = document.createElement("div");
            const middle = document.createElement("div");
            const target = document.createElement("span");
            target.className = "target";
            target.textContent = "target";
            middle.append(target);
            outer.append(middle);
            document.body.append(outer);

            if (shadow)
                middle.attachShadow({ mode: "open" }).innerHTML = "<a><slot></slot></a>";
            document.body.offsetWidth;

            // The outer and target have selector reactions, while the intervening nodes only
            // carry inherited reactions through the batch. Hiding the outer clears their styles.
            outer.className = "hidden changed";
            internals.updateStyle();
            println(`${shadow ? "shadow" : "light"} hidden:\n${internals.dumpStyleRecords(outer).trimEnd()}`);

            println(`hidden padding: ${getComputedStyle(target).paddingLeft}`);
            outer.className = "changed";
            document.body.offsetWidth;
            println(`visible padding: ${getComputedStyle(target).paddingLeft}`);
            println(`${shadow ? "shadow" : "light"} visible:\n${internals.dumpStyleRecords(outer).trimEnd()}`);
            outer.remove();
        }
    });
</script>