2 This tests text selection in complex scripts where glyph reordering occurs.
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 textNode
= target
.firstChild
.nextSibling
;
14 var range
= document
.createRange();
15 range
.setStart(textNode
, 0);
16 range
.setEnd(textNode
, 2);
17 var width
= range
.getClientRects()[0].width
;
19 range
.setStart(target
, 0);
20 range
.setEnd(target
, 3);
21 var totalWidth
= range
.getBoundingClientRect().width
;
23 var reference
= document
.getElementById("reference");
24 range
.setStart(reference
, 0)
25 range
.setEnd(reference
, 3);
26 var referenceWidth
= totalWidth
- range
.getBoundingClientRect().width
;
28 document
.getElementById("result").innerText
= Math
.abs(width
- referenceWidth
) < 0.5 ? "PASS" : "FAIL: width was " + width
+ " instead of " + referenceWidth
;