Skip to content

Truly independent web browser

1.1 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
    .anchor:has(.witness) .item { color: rgb(0, 128, 0); }
</style>
<div id="container"></div>
<script>
    test(() => {
        // Every item asks whether its ancestor anchors a witness. The answer is the anchor's, so a pass walks the
        // anchor's subtree for it once on each thread that styles items under it, not once for every item.
        const container = document.getElementById("container");
        const anchor = document.createElement("div");
        anchor.className = "anchor";
        const witness = document.createElement("div");
        witness.className = "witness";
        anchor.append(witness);
        const itemCount = 400;
        for (let i = 0; i < itemCount; ++i) {
            const item = document.createElement("span");
            item.className = "item";
            item.id = `item${i}`;
            item.setAttribute("data-index", i);
            anchor.append(item);
        }
        internals.updateStyle();
        container.append(anchor);
        println(`last item: ${getComputedStyle(document.getElementById(`item${itemCount - 1}`)).color}`);
    });
</script>