chromium/third_party/blink/web_tests/fast/css/zoom-in-length-round-trip.html

<p>
    Test that fixed integral lengths round-trip correctly through zooming.
</p>
<p>
    The test queries <tt>offsetWidth</tt> and <tt>offsetHeight</tt> of a 1&times;10-pixel rectangle under zooming by a factor of <i>k</i>/100 for 100 &le; <i>k</i> &le; 200.
</p>
<pre id="console"></pre>
<div id="container">
    <div id="target" style="width: 1px; height: 10px;"></div>
</div>
<script>
    function log(message)
    {
        var console = document.getElementById("console");
        console.appendChild(document.createTextNode(message + "\n"));
    }

    if (window.testRunner)
        testRunner.dumpAsText();

    var target = document.getElementById("target");
    var containerStyle = document.getElementById("container").style;
    var zoom;
    var failed = false;
    
    for (zoom = 100; zoom <= 200; zoom += 1) {
        containerStyle.setProperty("zoom", zoom / 100);
        if (Math.abs(target.offsetWidth - 1) > 0.5 || Math.abs(target.offsetHeight - 10) > 0.5) {
            failed = true;
            log("FAIL at " + zoom + "% magnification: 1 mapped to " + target.offsetWidth + " and 10 mapped to " + target.offsetHeight + ".");
        }
    }

    if (!failed)
        log("PASS");
</script>