Skip to content

Truly independent web browser

2.2 KB
Raw Blame
<!doctype html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    body { margin: 0; }
    canvas { display: block; width: 100px; height: 100px; background: green; }
    #boundary { position: absolute; left: 200px; top: 0; width: 100px; height: 100px; }
</style>
<canvas id="full" width="100" height="100"></canvas>
<div id="boundary"><canvas id="partial" width="100" height="100"></canvas></div>
<script>
displayListTest({
    setup: removeBodyWhitespace,
    steps: [
        {
            name: "unchanged canvas preserves cached paint after full relayout",
            mutate: () => {
                // Reassigning the width requests layout even when the value is unchanged.
                // Without a rendering context, there is no canvas content to reset.
                full.width = full.width;
            },
            check: equal => {
                equal(full.getBoundingClientRect().width, 100, "canvas width");
            },
            expect: {
                layout: `
                    layout FULL
                      @viewport/block RUN (cache=bypass)
                        BlockContainer<HTML>/block RUN (cache=miss)
                          CanvasBox<CANVAS>#full/internal-replaced RUN (cache=bypass)
                        BlockContainer<DIV>#boundary/block REUSE SUBTREE
                `,
                displayList: `
                    @canvas RECORD (empty)
                    @viewport COPY
                `,
            },
        },
        {
            name: "unchanged canvas preserves cached paint after partial relayout",
            mutate: () => {
                partial.width = partial.width;
            },
            check: equal => {
                equal(partial.getBoundingClientRect().width, 100, "canvas width");
            },
            expect: {
                layout: `
                    layout PARTIAL BlockContainer<DIV>#boundary
                      BlockContainer<DIV>#boundary/block RUN (cache=miss)
                        CanvasBox<CANVAS>#partial/internal-replaced RUN (cache=bypass)
                `,
                displayList: `
                    @canvas RECORD (empty)
                    @viewport COPY
                `,
            },
        },
    ],
});
</script>