Skip to content

Truly independent web browser

2.3 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    #parent {
        width: 200px;
        height: 200px;
    }

    .clipped {
        width: 50px;
        height: 50px;
        overflow: hidden;
        transform: translateX(10px);
        background: blue;
    }
</style>
<div id="parent"></div>
<script>
    const clippedBox = id => {
        const box = document.createElement("div");
        box.className = "clipped";
        box.id = id;
        document.getElementById("parent").appendChild(box);
        return box;
    };
    let first;
    let second;
    visualContextTest({
        setup: () => internals.forceIncompatibleVisualContextTreeRebuild(),
        steps: [
            {
                name: "a clipped box allocates its nodes",
                mutate: () => { first = clippedBox("first"); },
                expect: `
                    update DIRTY-PATH
                      div#first.clipped transform ALLOCATED
                      div#first.clipped clip ALLOCATED
                      recording NEEDED
                `,
            },
            {
                name: "removing it releases them",
                mutate: () => first.remove(),
                expect: `
                    update DIRTY-PATH
                      (removed) transform RELEASED (removed box)
                      (removed) clip RELEASED (removed box)
                      epoch NEW
                      recording NEEDED
                `,
            },
            {
                name: "after a recording, the next clipped box takes the released slots",
                mutate: () => {
                    internals.recordDisplayListForTesting();
                    second = clippedBox("second");
                },
                check: equal => {
                    equal(document.elementFromPoint(30, 30).id, "second", "hit");
                    equal(second.getBoundingClientRect().x, 18, "second x");
                },
                expect: `
                    update DIRTY-PATH
                      div#second.clipped transform ALLOCATED (freed slot)
                      div#second.clipped clip ALLOCATED (freed slot)
                      epoch NEW
                      recording NEEDED
                `,
            },
        ],
    });
</script>