Skip to content

Truly independent web browser

1.5 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="frame-in-flight.js"></script>
<style>
    #label::before { content: "x"; }
</style>
<div id="card" style="color: rgb(0, 0, 0)">Card <span id="label">label</span></div>
<script>
    // A tick of a running animation of an inherited property shows it in the box of the generated pseudo-element of
    // a descendant that inherits it.
    asyncTest(async done => {
        const result = await whileLaneAnimates(() => {
            return card.animate([{ color: "rgb(0, 0, 0)" }, { color: "rgb(0, 0, 200)" }], { duration: 10000, easing: "linear" });
        }, (frameTime, animation) => {
            internals.injectClockTick(frameTime + 5000);
            const expectedBlue = Math.round(((frameTime + 5000 - animation.startTime) / 10000) * 200);
            return {
                lane: internals.clockLaneState(document),
                presentedBy: internals.lastFramePresentedBy(document),
                expectedColor: `rgb(0, 0, ${expectedBlue})`,
                labelColor: internals.presentedColor(label),
                labelBeforeColor: internals.presentedColor(label, "::before"),
            };
        });
        println(`lane after the tick: ${result.lane}`);
        println(`last frame presented by: ${result.presentedBy}`);
        println(`descendant shows the tick's color: ${result.labelColor === result.expectedColor}`);
        println(`descendant's ::before shows the tick's color: ${result.labelBeforeColor === result.expectedColor}`);
        done();
    });
</script>