Skip to content

Truly independent web browser

1.2 KB
Raw Blame
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/selection-with-image-moves-away-after-paint-ref.html">
<style>
    img {
        width: 50px;
        height: 50px;
        vertical-align: middle;
    }
</style>
<p>before image <img src="../data/smiley.png"> after image</p>
<p id="other">The selection ends up here</p>
<script>
    function afterNextFrame(callback) {
        requestAnimationFrame(() => requestAnimationFrame(callback));
    }

    window.addEventListener("load", () => {
        const selection = getSelection();
        // The image paints selected first, then the selection is removed and later placed where it does not cover it.
        selection.selectAllChildren(document.body);
        afterNextFrame(() => {
            selection.removeAllRanges();
            afterNextFrame(() => {
                selection.selectAllChildren(document.getElementById("other"));
                afterNextFrame(() => {
                    if (window.internals)
                        internals.signalTestIsDone("PASS");
                    else
                        document.documentElement.classList.remove("reftest-wait");
                });
            });
        });
    });
</script>
</html>