Bug 1943761 - Add class alignment to the mozsearch analysis file. r=asuth
[gecko.git] / dom / svg / test / test_text_2.html
blob380de92dde89d69915dd8c78ca4b4c1b8ee3f727
1 <!DOCTYPE html>
2 <html xmlns="http://www.w3.org/1999/xhtml">
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=655877
5 -->
6 <head>
7 <meta charset=UTF-8>
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" />
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=655877">Mozilla Bug 655877</a>
14 <p id="display"></p>
15 <div id="content">
16 <svg width="400" height="200">
17 <text x="100" y="100" style="font: 16px sans-serif">abc אבג 123 דהו defg</text>
18 </svg>
19 </div>
21 <pre id="test">
22 <script class="testbody" type="application/javascript">
23 SimpleTest.waitForExplicitFinish();
25 function close(x, y, message) {
26 if (Math.abs(x - y) < 1e-4) {
27 ok(true, message);
28 } else {
29 // Use is() so that the difference is actually printed in the error message
30 is(x, y, message);
34 function runTest() {
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
45 sum = 0;
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");
56 SimpleTest.finish();
59 window.addEventListener("load", runTest);
60 </script>
61 </pre>
62 </body>
63 </html>