| <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×10-pixel rectangle under zooming by a factor of <i>k</i>/100 for 100 ≤ <i>k</i> ≤ 200. |
| </p> |
| <pre id="console"></pre> |
| <div id="container"> |
| <div id="target" style="width: 1px; height: 10px;"></div> |
| <div id="subpixel-test" style="width: 4.5px; 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; |
| |
| var rect = document.getElementById('subpixel-test').getBoundingClientRect(); |
| var hasSubpixelSupport = rect.right - rect.left == 4.5; |
| |
| for (zoom = 100; zoom <= 200; zoom += 1) { |
| containerStyle.setProperty("zoom", zoom / 100); |
| if (Math.round(target.offsetWidth) != 1 || Math.round(target.offsetHeight) != 10) { |
| if (hasSubpixelSupport && (Math.round(target.offsetWidth) == 1 || Math.round(target.offsetWidth) == 2) && (Math.round(target.offsetHeight) == 10 || Math.round(target.offsetHeight) == 11)) |
| continue; // With subpixel layout and pixel snapping we extend the box with one pixel at certain zoom levels. |
| failed = true; |
| log("FAIL at " + zoom + "% magnification: 1 mapped to " + target.offsetWidth + " and 10 mapped to " + target.offsetHeight + "."); |
| } |
| } |
| |
| if (!failed) |
| log("PASS"); |
| </script> |