Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / svg / custom / zoomed-baseline-shift.html
blob38b293c309257cab10256426d0cda26397a3fc01
1 <!doctype html>
2 <title>Test that baseline-shift is unaffected by zoom level</title>
3 <script src="../../resources/ahem.js"></script>
4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <svg width="250" height="140" viewBox="0 0 250 140"
7 xmlns="http://www.w3.org/2000/svg" version="1.1">
8 <style>
9 text {
10 font-family: ahem;
11 font-size: 20px;
13 </style>
14 <text x="15" y="40">before<tspan>inter</tspan>after</text>
15 <script>
16 var baselineShiftValues = ["10px", "-50%"]; // Shift half a step up or down
17 var zoomLevels = [1, 4, 16];
19 var html = document.documentElement;
20 baselineShiftValues.forEach(function (baselineShiftValue) {
21 document.querySelector('tspan').setAttribute('baseline-shift', baselineShiftValue);
22 zoomLevels.forEach(function (zoom) {
23 html.style.zoom = zoom;
24 var baselineShiftDelta = (document.querySelector('text').getStartPositionOfChar(0).y -
25 document.querySelector('tspan').getStartPositionOfChar(0).y);
26 test(function () {
27 assert_equals(Math.abs(baselineShiftDelta), 10, "Baseline half a font-size up or down");
28 }, "Text bounds height at zoom " + zoom + " with baseline-shift=" + baselineShiftValue);
29 });
30 });
31 html.style.zoom = 1;
32 // Clean up to avoid being classified as a text test; avoids an -expected.txt file.
33 document.querySelector('text').remove();
34 </script>
35 </svg>