2 This tests text with characters that have multiple glyphs.
4 <div id=
"target" style=
"font-size: 48px;"><span>[
</span>คำผ<span>]
</span></div>
5 <div id=
"reference" style=
"font-size: 48px;"><span>[
</span>คำ<span>]
</span></div>
6 <p id=
"result">Test did not run
</p>
9 testRunner
.dumpAsText();
11 var target
= document
.getElementById("target");
13 var textNodeTarget
= target
.firstChild
.nextSibling
;
14 var range
= document
.createRange();
15 range
.setStart(textNodeTarget
, 0);
16 range
.setEnd(textNodeTarget
, 2);
17 var targetWidth
= range
.getClientRects()[0].width
;
19 var reference
= document
.getElementById("reference");
20 var textNodeReference
= reference
.firstChild
.nextSibling
;
21 range
.setStart(textNodeReference
, 0)
22 range
.setEnd(textNodeReference
, 2);
24 var referenceWidth
= range
.getClientRects()[0].width
;
26 document
.getElementById("result").innerText
= Math
.abs(targetWidth
- referenceWidth
) <= 1 ? "PASS" : "FAIL: width was " + targetWidth
+ " instead of " + referenceWidth
;