Skip to content

Truly independent web browser

1.1 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="host"></div>
<script>
    promiseTest(async () => {
        const host = document.getElementById("host");
        const shadowRoot = host.attachShadow({ mode: "open" });
        const sheet = new CSSStyleSheet();

        sheet.replaceSync(`
            :host {
                animation-name: fade;
                animation-duration: 1s;
                animation-fill-mode: both;
            }
        `);
        shadowRoot.adoptedStyleSheets = [sheet];
        println(`opacity before keyframes: ${getComputedStyle(host).opacity}`);

        sheet.insertRule(`
            @keyframes fade {
                from { opacity: 0.25; }
                to { opacity: 0.25; }
            }
        `, sheet.cssRules.length);
        await animationFrame();
        println(`opacity after keyframes insert: ${getComputedStyle(host).opacity}`);

        sheet.deleteRule(sheet.cssRules.length - 1);
        await animationFrame();
        println(`opacity after keyframes delete: ${getComputedStyle(host).opacity}`);
    });
</script>