Skip to content

Truly independent web browser

1.3 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<script src="../work-test.js"></script>
<style>
    body { margin: 0; }
    #wrapper { margin-left: 0; }
    #clip { overflow: hidden; width: 50px; height: 50px; }
    #inner { width: 200px; height: 20px; }
</style>
<div id="wrapper"><div id="clip"><div id="inner"></div></div></div>
<script>
    const hit = x => document.elementFromPoint(x, 10);
    visualContextTest({
        steps: [
            {
                name: "before the move",
                check: equal => {
                    equal(hit(25).id, "inner", "inside the clip");
                    equal(hit(125).id, "wrapper", "beside the clip");
                },
                expect: ``,
            },
            {
                name: "the wrapper moves",
                mutate: () => { wrapper.style.marginLeft = "100px"; },
                check: equal => {
                    equal(hit(25).tagName, "BODY", "old position after the move");
                    equal(hit(125).id, "inner", "inside the moved clip");
                    equal(hit(175).id, "wrapper", "beyond the moved clip");
                },
                expect: `
                    update DIRTY-PATH
                      div#clip clip UPDATED
                      div#clip scroll UPDATED
                `,
            },
        ],
    });
</script>