Skip to content

Truly independent web browser

1.5 KB
Raw Blame
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
    @property --local { syntax: "<length>"; inherits: false; initial-value: 0px; }
    #container { --text-color: green; --local: 10px; }
    #container > div { transition: opacity 1s linear; color: var(--text-color); }
</style>
<div id="container"></div>
<script>
    test(() => {
        for (let index = 0; index < 16; ++index) {
            const child = container.appendChild(document.createElement("div"));
            child.style.marginLeft = `${index}px`;
        }
        internals.updateStyle();
        const sheet = new CSSStyleSheet();
        sheet.replaceSync("#container, #container > div { transition: none !important; }");

        function mutate(label, mutation) {
            mutation();
            internals.updateStyle();
            println(`${label} transition: ${getComputedStyle(container.firstElementChild).transitionDuration}`);
            println(`${label} color: ${getComputedStyle(container.firstElementChild).color}`);
        }

        mutate("disable", () => document.adoptedStyleSheets = [sheet]);
        mutate("restore", () => document.adoptedStyleSheets = []);
        const target = container.firstElementChild;
        target.style.opacity = "0";
        internals.updateStyle();
        const animation = target.getAnimations()[0];
        animation.pause();
        animation.currentTime = 500;
        println(`restored transition interpolates: ${getComputedStyle(target).opacity}`);
    });
</script>