blob: 38b293c309257cab10256426d0cda26397a3fc01 [file] [log] [blame]
<!doctype html>
<title>Test that baseline-shift is unaffected by zoom level</title>
<script src="../../resources/ahem.js"></script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<svg width="250" height="140" viewBox="0 0 250 140"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<style>
text {
font-family: ahem;
font-size: 20px;
}
</style>
<text x="15" y="40">before<tspan>inter</tspan>after</text>
<script>
var baselineShiftValues = ["10px", "-50%"]; // Shift half a step up or down
var zoomLevels = [1, 4, 16];
var html = document.documentElement;
baselineShiftValues.forEach(function (baselineShiftValue) {
document.querySelector('tspan').setAttribute('baseline-shift', baselineShiftValue);
zoomLevels.forEach(function (zoom) {
html.style.zoom = zoom;
var baselineShiftDelta = (document.querySelector('text').getStartPositionOfChar(0).y -
document.querySelector('tspan').getStartPositionOfChar(0).y);
test(function () {
assert_equals(Math.abs(baselineShiftDelta), 10, "Baseline half a font-size up or down");
}, "Text bounds height at zoom " + zoom + " with baseline-shift=" + baselineShiftValue);
});
});
html.style.zoom = 1;
// Clean up to avoid being classified as a text test; avoids an -expected.txt file.
document.querySelector('text').remove();
</script>
</svg>