Skip to content

Truly independent web browser

1.3 KB
Raw Blame
<!DOCTYPE html>
<meta charset="utf-8">
<script src="../include.js"></script>
<script>
    const cssURL = text => `data:text/css,${encodeURIComponent(text)}`;
    const leafURL = cssURL('.Γ©πŸ˜€ { color: rgb(1, 2, 3); --text: "Γ©πŸ˜€" }');
    const middleURL = cssURL(`@import url("${leafURL}");`);
    const importedStyle = document.createElement("style");
    importedStyle.textContent = `@import url("${middleURL}");`;
    document.head.append(importedStyle);

    asyncTest(done => {
        window.addEventListener("load", () => {
            const middle = importedStyle.sheet.cssRules[0].styleSheet;
            const importRule = middle.cssRules[0];
            const leaf = importRule.styleSheet;
            const target = document.querySelector(".Γ©πŸ˜€");
            println(`nested sheet ready: ${leaf !== null}`);
            println(`owner rule preserved: ${leaf.ownerRule === importRule}`);
            println(`color at load: ${getComputedStyle(target).color}`);
            println(`UTF-16 value: ${leaf.cssRules[0].style.getPropertyValue("--text")}`);
            leaf.cssRules[0].style.color = "rgb(4, 5, 6)";
            println(`CSSOM mutation: ${getComputedStyle(target).color}`);
            done();
        }, { once: true });
    });
</script>
<div class="Γ©πŸ˜€">target</div>