<!doctype html>
<title>Test that alignment-baseline 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 alignmentBaselineValues = ["baseline", "central", "after-edge", "text-after-edge",
"ideograpic", "alphabetic", "mathematical"];
var expectedDeltas = {
"baseline" : 0,
"before-edge": -16,
"text-before-edge": -16,
"middle": -8,
"central": -6,
"after-edge": 4,
"text-after-edge": 4,
"ideograpic": 0,
"alphabetic": 0,
"hanging": -13,
"mathematical": -8
};
var zoomLevels = [1, 4, 16];
var html = document.documentElement;
alignmentBaselineValues.forEach(function (alignmentBaselineValue) {
document.querySelector('tspan').setAttribute('alignment-baseline', alignmentBaselineValue);
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_approx_equals(baselineShiftDelta, expectedDeltas[alignmentBaselineValue], 1);
}, "Text bounds height at zoom " + zoom + " with alignment-baseline=" + alignmentBaselineValue);
});
});
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>