Skip to content

Truly independent web browser

1.8 KB
Raw Blame
<!DOCTYPE html>
<html class="reftest-wait">
<link rel="match" href="../expected/svg-text-decoration-animated-ref.html" />
<style>
    @font-face {
        font-family: Ahem;
        src: url("../data/fonts/Ahem.ttf");
    }
    body {
        margin: 0;
    }
    svg {
        display: block;
        font: 60px Ahem;
    }
    @keyframes thicken {
        to {
            text-decoration-thickness: 20px;
            text-underline-offset: 30px;
        }
    }
    #animated.started {
        animation: thicken 60ms linear forwards;
    }
    #transitioned {
        transition: text-decoration-thickness 60ms linear;
    }
</style>
<svg width="600" height="200">
    <text id="animated" x="20" y="100" fill="blue" style="text-decoration: underline">&#xC9;</text>
    <text id="transitioned" x="220" y="100" fill="blue" style="text-decoration: underline; text-decoration-thickness: 2px">&#xC9;</text>
</svg>
<script>
    const finish = () => requestAnimationFrame(() => requestAnimationFrame(() => {
        if (window.internals)
            internals.signalTestIsDone("PASS");
        else
            document.documentElement.classList.remove("reftest-wait");
    }));
    document.fonts.load("60px Ahem").then(() => {
        const animated = document.getElementById("animated");
        const transitioned = document.getElementById("transitioned");
        const ended = new Promise(resolve => animated.addEventListener("animationend", resolve));
        animated.classList.add("started");
        requestAnimationFrame(() => requestAnimationFrame(() => {
            const transitionEnded = new Promise(resolve => transitioned.addEventListener("transitionend", resolve));
            transitioned.style.textDecorationThickness = "20px";
            Promise.all([ended, transitionEnded]).then(finish);
        }));
    });
</script>
</html>