Skip to content

Truly independent web browser

5.7 KB
Raw Blame
<!doctype html>
<html id="html">
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    @keyframes fade { from { opacity: 1; } to { opacity: 0.5; } }
    body { margin: 0; }
    #box { width: 100px; height: 100px; background: red; transform: scale(0); }
</style>
<body id="body">
<div id="box"></div>
<script>
// A box with a singular transform paints nothing on its own. While a compositor animation targets
// it, its content is retained for playback and the box records; a selection pass that keeps the
// animation on the compositor pushes nothing, and removing the animation makes the box eligible
// for skipping again.
displayListTest({
    setup: async () => {
        removeBodyWhitespace();
        box.style.animation = "fade 100s linear";
        for (const animation of document.getAnimations()) animation.currentTime = 0;
        for (let i = 0; i < 4; ++i) await new Promise(requestAnimationFrame);
    },
    steps: [
        {
            name: "quiet while the animation runs on the compositor",
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "a selection pass after the animation started",
            mutate: () => { internals.updateCompositorAnimations(); },
            expect: `
                @canvas RECORD (empty)
                @viewport ASSEMBLE
                  @viewport/preamble COPY
                  @viewport/scroll-metadata COPY
                  @viewport/background COPY
                  @viewport/border COPY
                  BlockContainer<HTML>#html/descendants(background-and-borders) ASSEMBLE
                  @viewport/foreground COPY
                  BlockContainer<HTML>#html/descendants(foreground) ASSEMBLE
                  BlockContainer<HTML>#html ASSEMBLE
                    BlockContainer<HTML>#html/preamble COPY
                    BlockContainer<HTML>#html/scroll-metadata COPY
                    BlockContainer<HTML>#html/background COPY
                    BlockContainer<HTML>#html/border COPY
                    BlockContainer<BODY>#body/descendants(background-and-borders) ASSEMBLE
                      BlockContainer<BODY>#body/scroll-metadata COPY
                      BlockContainer<BODY>#body/background COPY
                      BlockContainer<BODY>#body/border COPY
                      BlockContainer<DIV>#box/descendants(background-and-borders) REPLAN
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#box/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#box REPLAN
                      BlockContainer<DIV>#box/preamble RECORD (empty)
                      BlockContainer<DIV>#box/scroll-metadata RECORD (empty)
                      BlockContainer<DIV>#box/background RECORD
                      BlockContainer<DIV>#box/border SKIP
                      BlockContainer<DIV>#box/foreground RECORD (empty)
                      BlockContainer<DIV>#box/outline SKIP
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        },
        {
            name: "a selection pass that keeps the animation on the compositor",
            mutate: () => { internals.updateCompositorAnimations(); },
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "remove the animation",
            mutate: () => { box.style.animation = "none"; box.getBoundingClientRect(); internals.updateCompositorAnimations(); },
            expect: `
                @canvas RECORD (empty)
                @viewport ASSEMBLE
                  @viewport/preamble COPY
                  @viewport/scroll-metadata COPY
                  @viewport/background COPY
                  @viewport/border COPY
                  BlockContainer<HTML>#html/descendants(background-and-borders) ASSEMBLE
                  @viewport/foreground COPY
                  BlockContainer<HTML>#html/descendants(foreground) ASSEMBLE
                  BlockContainer<HTML>#html ASSEMBLE
                    BlockContainer<HTML>#html/preamble COPY
                    BlockContainer<HTML>#html/scroll-metadata COPY
                    BlockContainer<HTML>#html/background COPY
                    BlockContainer<HTML>#html/border COPY
                    BlockContainer<BODY>#body/descendants(background-and-borders) ASSEMBLE
                      BlockContainer<BODY>#body/scroll-metadata COPY
                      BlockContainer<BODY>#body/background COPY
                      BlockContainer<BODY>#body/border COPY
                      BlockContainer<DIV>#box/descendants(background-and-borders) REPLAN
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#box/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#box SKIP
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        },
        {
            name: "quiet after the animation",
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        }
    ]
});
</script>