1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.svg;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.htmlunit.junit.annotation.HtmlUnitNYI;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24
25
26
27
28
29 @RunWith(BrowserRunner.class)
30 public class SVGTSpanElementTest extends WebDriverTestCase {
31
32
33
34
35 @Test
36 @Alerts("function SVGTSpanElement() { [native code] }")
37 public void simpleScriptable() throws Exception {
38 final String html = DOCTYPE_HTML
39 + "<html><head>\n"
40 + "<script>\n"
41 + LOG_TITLE_FUNCTION
42 + " function test() {\n"
43 + " log(window.SVGTSpanElement);\n"
44 + " }\n"
45 + "</script>\n"
46 + "</head><body onload='test()'>\n"
47 + "</body></html>";
48
49 loadPageVerifyTitle2(html);
50 }
51
52
53
54
55 @Test
56 @Alerts({"[object SVGTSpanElement]", "true"})
57 public void getComputedTextLengthAvailable() throws Exception {
58 final String html = DOCTYPE_HTML
59 + "<html><head>\n"
60 + "<script>\n"
61 + LOG_TITLE_FUNCTION
62 + " function test() {\n"
63 + " if (window.SVGPathElement) {\n"
64 + " var text = document.getElementById('myId');\n"
65 + " log(text);\n"
66 + " log(text.getComputedTextLength() > 0);\n"
67 + " }\n"
68 + " }\n"
69 + "</script>\n"
70 + "</head><body onload='test()'>\n"
71 + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n"
72 + " <text fill='limegreen' font-size='20'>\n"
73 + " <tSpan id='myId'x='50' y='50 55 60 60 60 55 50 45 40 35 30 25'>SVG forever!</tSpan>\n"
74 + " </text>\n"
75 + "</svg>\n"
76 + "</body></html>";
77
78 loadPageVerifyTitle2(html);
79 }
80
81
82
83
84 @Test
85 @Alerts({"[object SVGTSpanElement]", "109.4"})
86 @HtmlUnitNYI(CHROME = {"[object SVGTSpanElement]", "120.0"},
87 EDGE = {"[object SVGTSpanElement]", "120.0"},
88 FF = {"[object SVGTSpanElement]", "120.0"},
89 FF_ESR = {"[object SVGTSpanElement]", "120.0"})
90 public void getComputedTextLength() throws Exception {
91 final String html = DOCTYPE_HTML
92 + "<html><head>\n"
93 + "<script>\n"
94 + LOG_TITLE_FUNCTION
95 + " function test() {\n"
96 + " if (window.SVGTextElement) {\n"
97 + " var text = document.getElementById('myId');\n"
98 + " log(text);\n"
99 + " var length = text.getComputedTextLength();\n"
100 + " log(length.toFixed(1));\n"
101 + " }\n"
102 + " }\n"
103 + "</script>\n"
104 + "</head><body onload='test()'>\n"
105 + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n"
106 + " <text fill='limegreen' font-size='20'>\n"
107 + " <tSpan id='myId'x='50' y='50 55 60 60 60 55 50 45 40 35 30 25'>SVG forever!</tSpan>\n"
108 + " </text>\n"
109 + "</svg>\n"
110 + "</body></html>";
111
112 loadPageVerifyTitle2(html);
113 }
114 }