9 Test for crbug.com/
405468: zoom should not affect getComputedTextLength().
<br>
10 <svg width=
"400" height=
"300">
11 <text y=
"30" class=
"testLowDPI" font-size=
"16px">1 regular
16px abcd
</text>
12 <text y=
"60" class=
"testLowDPI" font-size=
"16px" text-rendering=
"geometricPrecision">1 geometric precision
16px abcd
</text>
13 <text y=
"90" class=
"testLowDPI" font-size=
"12px">1 regular
12px abcd
</text>
15 <text y=
"130" class=
"testHighDPI" font-size=
"16px">2 regular
16px abcd
</text>
16 <text y=
"160" class=
"testHighDPI" font-size=
"16px" text-rendering=
"geometricPrecision">2 geometric precision
16px abcd
</text>
17 <text y=
"190" class=
"testHighDPI" font-size=
"12px">2 regular
12px abcd
</text>
20 if (window
.testRunner
) {
21 testRunner
.waitUntilDone();
22 testRunner
.dumpAsText();
23 testRunner
.setBackingScaleFactor(1, function() {
24 runTest('testLowDPI');
25 testRunner
.setBackingScaleFactor(2, function() {
26 runTest('testHighDPI');
27 testRunner
.notifyDone();
32 function runTest(className
) {
33 var textElements
= document
.getElementsByClassName(className
);
34 for (var t
= 0; t
< textElements
.length
; t
++) {
35 var text
= textElements
[t
];
36 var longerLength
= text
.getComputedTextLength();
37 // Remove one character from the text so that it is now shorter.
38 text
.textContent
= text
.textContent
.substring(0, text
.textContent
.length
- 1);
39 var shorterLength
= text
.getComputedTextLength();
41 if (longerLength
> shorterLength
)
42 text
.textContent
= "PASS";
44 text
.textContent
= "FAIL, " + longerLength
+ " should be greater than " + shorterLength
;