Skip to content

Truly independent web browser

8.0 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: relative; width: 100px; height: 100px; }
    #target { width: 100px; height: 100px; }
</style>
<body id="body">
<div id="a"></div>
<div id="b"><div id="target"></div></div>
<script>
const passive = () => {};
const blocking = () => {};
displayListTest({
    setup: removeBodyWhitespace,
    steps: [
        {
            name: "quiet without listeners",
            check: equal => { equal(internals.recordedDisplayListBlocksWheelEventAt(50, 150), false, "blocking wheel region"); },
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "add passive listener",
            mutate: () => { target.addEventListener("wheel", passive, { passive: true }); },
            check: equal => { equal(internals.recordedDisplayListBlocksWheelEventAt(50, 150), false, "blocking wheel region"); },
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "add blocking listener",
            mutate: () => { target.addEventListener("wheel", blocking, { passive: false }); },
            check: equal => { equal(internals.recordedDisplayListBlocksWheelEventAt(50, 150), true, "blocking wheel region"); },
            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>#a/descendants(background-and-borders) COPY
                      BlockContainer<DIV>#b/descendants(background-and-borders) ASSEMBLE
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#a/descendants(foreground) COPY
                      BlockContainer<DIV>#b/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#a COPY
                    BlockContainer<DIV>#b ASSEMBLE
                      BlockContainer<DIV>#b/scroll-metadata COPY
                      BlockContainer<DIV>#b/background COPY
                      BlockContainer<DIV>#b/border COPY
                      BlockContainer<DIV>#target/descendants(background-and-borders) ASSEMBLE
                        BlockContainer<DIV>#target/scroll-metadata RECORD
                        BlockContainer<DIV>#target/background SKIP
                        BlockContainer<DIV>#target/border SKIP
                      BlockContainer<DIV>#target/descendants(floats) ASSEMBLE
                      BlockContainer<DIV>#target/descendants(inline-background-and-borders) ASSEMBLE
                      BlockContainer<DIV>#b/foreground COPY
                      BlockContainer<DIV>#target/descendants(foreground) ASSEMBLE
                        BlockContainer<DIV>#target/foreground RECORD (empty)
                        BlockContainer<DIV>#target/outline SKIP
                        BlockContainer<DIV>#target/overlay SKIP
                      BlockContainer<DIV>#b/outline COPY
                      BlockContainer<DIV>#b/overlay COPY
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        },
        {
            name: "quiet with blocking listener",
            check: equal => { equal(internals.recordedDisplayListBlocksWheelEventAt(50, 150), true, "blocking wheel region"); },
            expect: `
                @canvas RECORD (empty)
                @viewport COPY
            `
        },
        {
            name: "remove blocking listener",
            mutate: () => { target.removeEventListener("wheel", blocking); },
            check: equal => { equal(internals.recordedDisplayListBlocksWheelEventAt(50, 150), false, "blocking wheel region"); },
            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>#a/descendants(background-and-borders) COPY
                      BlockContainer<DIV>#b/descendants(background-and-borders) ASSEMBLE
                    BlockContainer<HTML>#html/foreground COPY
                    BlockContainer<BODY>#body/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/foreground COPY
                      BlockContainer<DIV>#a/descendants(foreground) COPY
                      BlockContainer<DIV>#b/descendants(foreground) ASSEMBLE
                      BlockContainer<BODY>#body/outline COPY
                      BlockContainer<BODY>#body/overlay COPY
                    BlockContainer<DIV>#a COPY
                    BlockContainer<DIV>#b ASSEMBLE
                      BlockContainer<DIV>#b/scroll-metadata COPY
                      BlockContainer<DIV>#b/background COPY
                      BlockContainer<DIV>#b/border COPY
                      BlockContainer<DIV>#target/descendants(background-and-borders) ASSEMBLE
                        BlockContainer<DIV>#target/scroll-metadata RECORD (empty)
                        BlockContainer<DIV>#target/background SKIP
                        BlockContainer<DIV>#target/border SKIP
                      BlockContainer<DIV>#target/descendants(floats) ASSEMBLE
                      BlockContainer<DIV>#target/descendants(inline-background-and-borders) ASSEMBLE
                      BlockContainer<DIV>#b/foreground COPY
                      BlockContainer<DIV>#target/descendants(foreground) ASSEMBLE
                        BlockContainer<DIV>#target/foreground RECORD (empty)
                        BlockContainer<DIV>#target/outline SKIP
                        BlockContainer<DIV>#target/overlay SKIP
                      BlockContainer<DIV>#b/outline COPY
                      BlockContainer<DIV>#b/overlay COPY
                    BlockContainer<HTML>#html/outline COPY
                  @viewport/outline COPY
            `
        }
    ]
});
</script>