2 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 https://bugzilla.mozilla.org/show_bug.cgi?id=655877
8 <title>Test for Bug
655877</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=655877">Mozilla Bug
655877</a>
16 <svg width=
"400" height=
"200">
17 <text x=
"100" y=
"100" style=
"font: 16px sans-serif">abc אבג
123 דהו defg
</text>
22 <script class=
"testbody" type=
"application/javascript">
23 SimpleTest.waitForExplicitFinish();
25 function close(x, y, message) {
26 if (Math.abs(x - y) <
1e-4) {
29 // Use is() so that the difference is actually printed in the error message
35 var text = document.querySelector(
"text");
37 // there are only
20 addressable characters
38 is(text.getNumberOfChars(),
20,
"getNumberOfChars");
40 var sum, total = text.getComputedTextLength();
42 close(text.getSubStringLength(
0,
20), total,
"getSubStringLength all");
44 // add the advance of each glyph
46 for (var i =
0; i <
20; i++) {
47 sum += text.getSubStringLength(i,
1);
49 close(sum, total,
"sum getSubStringLength 1");
51 // split the text up into three chunks and add them together
52 close(text.getSubStringLength(
0,
6) +
53 text.getSubStringLength(
6,
8) +
54 text.getSubStringLength(
14,
6), total,
"sum getSubStringLength 2");
59 window.addEventListener(
"load", runTest);