Skip to content

Truly independent web browser

5.6 KB
Raw Blame
<!doctype html>
<html id="html">
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    body { margin: 0; }
    #a, #b { position: absolute; left: 0; top: 0; width: 100px; height: 100px; }
    #a { background: red; z-index: 0; }
    #b { background: blue; z-index: 1; }
</style>
<body id="body">
<div id="a"></div>
<div id="b"></div>
<script>
displayListTest({
    setup: removeBodyWhitespace,
    steps: [
        {
            name: "quiet before reordering",
            check: equal => { equal(document.elementFromPoint(50, 50).id, "b", "hit target"); },
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "move B behind A",
            mutate: () => { b.style.zIndex = "-1"; },
            check: equal => { equal(document.elementFromPoint(50, 50).id, "a", "hit target"); },
            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) REPLAN
                  @viewport/foreground COPY
                  BlockContainer<HTML>#html/descendants(foreground) REPLAN
                  BlockContainer<HTML>#html REPLAN
                    BlockContainer<HTML>#html/preamble COPY
                    BlockContainer<HTML>#html/scroll-metadata COPY
                    BlockContainer<HTML>#html/background COPY
                    BlockContainer<HTML>#html/border COPY
                    BlockContainer<DIV>#b REPLAN
                      BlockContainer<DIV>#b/preamble RECORD (empty)
                      BlockContainer<DIV>#b/scroll-metadata RECORD (empty)
                      BlockContainer<DIV>#b/background RECORD
                      BlockContainer<DIV>#b/border SKIP
                      BlockContainer<DIV>#b/foreground RECORD (empty)
                      BlockContainer<DIV>#b/outline SKIP
                    BlockContainer<BODY>#body/descendants(background-and-borders) REPLAN
                      BlockContainer<BODY>#body/scroll-metadata COPY
                      BlockContainer<BODY>#body/background COPY
                      BlockContainer<BODY>#body/border COPY
                      BlockContainer<DIV>#a/descendants(background-and-borders) COPY
                      BlockContainer<DIV>#b/descendants(background-and-borders) REPLAN
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#a/descendants(foreground) COPY
                      BlockContainer<DIV>#b/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#a COPY
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        },
        {
            name: "move B in front of A",
            mutate: () => { b.style.zIndex = "1"; },
            check: equal => { equal(document.elementFromPoint(50, 50).id, "b", "hit target"); },
            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) REPLAN
                  @viewport/foreground COPY
                  BlockContainer<HTML>#html/descendants(foreground) REPLAN
                  BlockContainer<HTML>#html REPLAN
                    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) REPLAN
                      BlockContainer<BODY>#body/scroll-metadata COPY
                      BlockContainer<BODY>#body/background COPY
                      BlockContainer<BODY>#body/border COPY
                      BlockContainer<DIV>#a/descendants(background-and-borders) COPY
                      BlockContainer<DIV>#b/descendants(background-and-borders) REPLAN
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#a/descendants(foreground) COPY
                      BlockContainer<DIV>#b/descendants(foreground) REPLAN
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#a COPY
                    BlockContainer<DIV>#b REPLAN
                      BlockContainer<DIV>#b/preamble RECORD (empty)
                      BlockContainer<DIV>#b/scroll-metadata RECORD (empty)
                      BlockContainer<DIV>#b/background RECORD
                      BlockContainer<DIV>#b/border SKIP
                      BlockContainer<DIV>#b/foreground RECORD (empty)
                      BlockContainer<DIV>#b/outline SKIP
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        }
    ]
});
</script>