Index: LayoutTests/svg/custom/zoomed-alignment-baseline.html |
diff --git a/LayoutTests/svg/custom/zoomed-alignment-baseline.html b/LayoutTests/svg/custom/zoomed-alignment-baseline.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cb3c4277d22ff96eeea312b4e1274ba48f0ac974 |
--- /dev/null |
+++ b/LayoutTests/svg/custom/zoomed-alignment-baseline.html |
@@ -0,0 +1,48 @@ |
+<!doctype html> |
+<title>Test that alignment-baseline is unaffected by zoom level</title> |
+<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", "before-edge", "text-before-edge", "middle", |
+ "central", "after-edge", "text-after-edge", |
+ "ideograpic", "alphabetic", "hanging", "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; |
+ </script> |
+</svg> |
+<p>This test requires the Ahem font</p> |