Skip to content

Truly independent web browser

1.4 KB
Raw Blame
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/green-100x100-ref.html">
<style>
    body {
        margin: 0;
    }
    img {
        display: block;
    }
</style>
<img id="target" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 1 1'%3E%3Crect width='1' height='1' fill='red'/%3E%3C/svg%3E">
<script>
    const target = document.getElementById("target");
    const finish = () => {
        requestAnimationFrame(() => {
            requestAnimationFrame(() => {
                if (window.internals)
                    internals.signalTestIsDone("PASS");
                else
                    document.documentElement.classList.remove("reftest-wait");
            });
        });
    };
    const switchSourceAfterPaint = () => {
        requestAnimationFrame(() => {
            requestAnimationFrame(() => {
                // Intrinsic sizing requests relayout, but the new image has identical dimensions.
                target.addEventListener("load", finish);
                target.src = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 1 1'%3E%3Crect width='1' height='1' fill='green'/%3E%3C/svg%3E";
            });
        });
    };
    if (target.complete)
        switchSourceAfterPaint();
    else
        target.addEventListener("load", switchSourceAfterPaint, { once: true });
</script>
</html>