Skip to content

Truly independent web browser

6.0 KB
Raw Blame
<!DOCTYPE html>
<script src="../include.js"></script>
<div id="overflow" style="overflow-x: visible; overflow-y: auto"></div>
<div id="position" style="display: inline; position: absolute"></div>
<div id="text-align-parent" style="text-align: left">
    <div id="text-align-child" style="text-align: match-parent"></div>
</div>
<div id="inherited-overflow-parent" style="overflow-x: visible">
    <div id="inherited-overflow-child" style="overflow-x: inherit; overflow-y: visible"></div>
</div>
<div id="inherited-position-parent" style="position: static">
    <div id="inherited-position-child" style="display: inline; position: inherit"></div>
</div>
<input id="adjusted-input" style="line-height: 1px">
<select id="adjusted-select" style="line-height: 1px"></select>
<svg><g id="adjusted-svg" style="position: absolute"></g></svg>
<table id="adjusted-table" align="center"></table>
<input id="file-input" type="file">
<style>
    #file-input::file-selector-button {
        display: inline;
    }
</style>
<script>
    promiseTest(async () => {
        getComputedStyle(overflow).overflowX;
        const overflowAnimation = overflow.animate(
            [{ overflowY: "visible" }, { overflowY: "visible" }],
            { duration: 1000, fill: "forwards" });
        overflowAnimation.pause();
        overflowAnimation.currentTime = 500;
        await overflowAnimation.ready;

        const overflowStyle = getComputedStyle(overflow);
        println(`overflow-x: ${overflowStyle.overflowX}`);
        println(`overflow-y: ${overflowStyle.overflowY}`);

        const positionAnimation = position.animate(
            [{ position: "static" }, { position: "static" }],
            { duration: 1000, fill: "forwards" });
        positionAnimation.pause();
        positionAnimation.currentTime = 500;
        await positionAnimation.ready;

        const positionStyle = getComputedStyle(position);
        println(`display: ${positionStyle.display}`);
        println(`position: ${positionStyle.position}`);

        const textAlignParent = document.getElementById("text-align-parent");
        const textAlignChild = document.getElementById("text-align-child");
        const textAlignAnimation = textAlignParent.animate(
            [{ textAlign: "right" }, { textAlign: "right" }],
            { duration: 1000, fill: "forwards" });
        textAlignAnimation.pause();
        textAlignAnimation.currentTime = 500;
        await textAlignAnimation.ready;
        await animationFrame();

        println(`parent text-align: ${getComputedStyle(textAlignParent).textAlign}`);
        await animationFrame();
        println(`match-parent text-align: ${getComputedStyle(textAlignChild).textAlign}`);

        const inheritedOverflowParent = document.getElementById("inherited-overflow-parent");
        const inheritedOverflowChild = document.getElementById("inherited-overflow-child");
        const inheritedOverflowAnimation = inheritedOverflowParent.animate(
            [{ overflowX: "scroll" }, { overflowX: "scroll" }],
            { duration: 1000, fill: "forwards" });
        inheritedOverflowAnimation.pause();
        inheritedOverflowAnimation.currentTime = 500;
        await inheritedOverflowAnimation.ready;

        const inheritedOverflowStyle = getComputedStyle(inheritedOverflowChild);
        println(`inherited overflow-x: ${inheritedOverflowStyle.overflowX}`);
        println(`adjusted overflow-y: ${inheritedOverflowStyle.overflowY}`);

        const inheritedPositionParent = document.getElementById("inherited-position-parent");
        const inheritedPositionChild = document.getElementById("inherited-position-child");
        const inheritedPositionAnimation = inheritedPositionParent.animate(
            [{ position: "absolute" }, { position: "absolute" }],
            { duration: 1000, fill: "forwards" });
        inheritedPositionAnimation.pause();
        inheritedPositionAnimation.currentTime = 500;
        await inheritedPositionAnimation.ready;

        const inheritedPositionStyle = getComputedStyle(inheritedPositionChild);
        println(`inherited display: ${inheritedPositionStyle.display}`);
        println(`inherited position: ${inheritedPositionStyle.position}`);

        const adjustedInput = document.getElementById("adjusted-input");
        const inputAnimation = adjustedInput.animate(
            [{ lineHeight: "1px" }, { lineHeight: "1px" }],
            { duration: 1000, fill: "forwards" });
        inputAnimation.pause();
        inputAnimation.currentTime = 500;
        await inputAnimation.ready;
        println(`input line-height: ${getComputedStyle(adjustedInput).lineHeight}`);

        const adjustedSelect = document.getElementById("adjusted-select");
        const selectAnimation = adjustedSelect.animate(
            [{ lineHeight: "1px" }, { lineHeight: "1px" }],
            { duration: 1000, fill: "forwards" });
        selectAnimation.pause();
        selectAnimation.currentTime = 500;
        await selectAnimation.ready;
        println(`select line-height: ${getComputedStyle(adjustedSelect).lineHeight}`);

        const adjustedSvg = document.getElementById("adjusted-svg");
        const svgAnimation = adjustedSvg.animate(
            [{ position: "absolute" }, { position: "absolute" }],
            { duration: 1000, fill: "forwards" });
        svgAnimation.pause();
        svgAnimation.currentTime = 500;
        await svgAnimation.ready;
        println(`svg position: ${getComputedStyle(adjustedSvg).position}`);

        const adjustedTable = document.getElementById("adjusted-table");
        const tableAnimation = adjustedTable.animate(
            [{ opacity: "1" }, { opacity: "1" }],
            { duration: 1000, fill: "forwards" });
        tableAnimation.pause();
        tableAnimation.currentTime = 500;
        await tableAnimation.ready;
        println(`table text-align: ${getComputedStyle(adjustedTable).textAlign}`);

        const fileInput = document.getElementById("file-input");
        println(`file selector display: ${getComputedStyle(fileInput, "::file-selector-button").display}`);
    });
</script>