1 <script src=
"../../resources/ahem.js"></script>
2 <div id=
"test" style=
"width: 200px; font-family: Ahem; font-size: 40px; text-rendering: optimizelegibility; text-align: justify;">a
­b c de
</div>
3 <div id=
"reference" style=
"width: 200px; font-family: Ahem; font-size: 40px; text-align: justify;">a
­b c de
</div>
4 <div id=
"result"></div>
7 testRunner
.dumpAsText();
9 function widthOfFirstThreeCharacters(id
)
11 var text
= document
.getElementById(id
).firstChild
;
12 var range
= document
.createRange();
13 range
.setStart(text
, 0);
14 range
.setEnd(text
, 3);
15 return range
.getBoundingClientRect().width
;
18 document
.getElementById("result").innerText
= widthOfFirstThreeCharacters("test") === widthOfFirstThreeCharacters("reference") ? "PASS" : "FAIL";