1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.javascript.host.html;
16
17 import org.htmlunit.WebDriverTestCase;
18 import org.htmlunit.junit.annotation.Alerts;
19 import org.junit.jupiter.api.Test;
20 import org.w3c.dom.html.HTMLBaseFontElement;
21
22
23
24
25
26
27
28 public class HTMLBaseFontElementTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts({"[object HTMLElement]", "undefined", "undefined", "undefined"})
35 public void defaults() throws Exception {
36 final String html = DOCTYPE_HTML
37 + "<html>\n"
38 + " <head>\n"
39 + " <basefont id='base' />\n"
40 + " <script>\n"
41 + LOG_TITLE_FUNCTION
42 + " function test() {\n"
43 + " var base = document.getElementById('base');\n"
44 + " log(base);\n"
45 + " log(base.face);\n"
46 + " log(base.size);\n"
47 + " log(base.color);\n"
48 + " }\n"
49 + " </script>\n"
50 + " </head>\n"
51 + " <body onload='test()'>foo</body>\n"
52 + "</html>";
53
54 loadPageVerifyTitle2(html);
55 }
56
57
58
59
60 @Test
61 @Alerts({"undefined", "42"})
62 public void size() throws Exception {
63 final String html = DOCTYPE_HTML
64 + "<html>\n"
65 + " <head>\n"
66 + " <basefont id='base' color='red' face='swiss' size='4' />\n"
67 + " <script>\n"
68 + LOG_TITLE_FUNCTION
69 + " function test() {\n"
70 + " var base = document.getElementById('base');\n"
71 + " log(base.size);\n"
72 + " try {\n"
73 + " base.size = 42;\n"
74 + " log(base.size);\n"
75 + " } catch(e) {\n"
76 + " logEx(e);\n"
77 + " }\n"
78 + " }\n"
79 + " </script>\n"
80 + " </head>\n"
81 + " <body onload='test()'>foo</body>\n"
82 + "</html>";
83
84 loadPageVerifyTitle2(html);
85 }
86
87
88
89
90 @Test
91 @Alerts({"undefined", "helvetica"})
92 public void face() throws Exception {
93 final String html = DOCTYPE_HTML
94 + "<html>\n"
95 + " <head>\n"
96 + " <basefont id='base' color='red' face='swiss' size='5' />\n"
97 + " <script>\n"
98 + LOG_TITLE_FUNCTION
99 + " function test() {\n"
100 + " var base = document.getElementById('base');\n"
101 + " log(base.face);\n"
102 + " try {\n"
103 + " base.face = 'helvetica';\n"
104 + " log(base.face);\n"
105 + " } catch(e) {\n"
106 + " logEx(e);\n"
107 + " }\n"
108 + " }\n"
109 + " </script>\n"
110 + " </head>\n"
111 + " <body onload='test()'>foo</body>\n"
112 + "</html>";
113
114 loadPageVerifyTitle2(html);
115 }
116
117
118
119
120 @Test
121 @Alerts({"undefined", "blue"})
122 public void color() throws Exception {
123 final String html = DOCTYPE_HTML
124 + "<html>\n"
125 + " <head>\n"
126 + " <basefont id='base' color='red' face='swiss' size='4' />\n"
127 + " <script>\n"
128 + LOG_TITLE_FUNCTION
129 + " function test() {\n"
130 + " var base = document.getElementById('base');\n"
131 + " log(base.color);\n"
132 + " try {\n"
133 + " base.color = 'blue';\n"
134 + " log(base.color);\n"
135 + " } catch(e) {\n"
136 + " logEx(e);\n"
137 + " }\n"
138 + " }\n"
139 + " </script>\n"
140 + " </head>\n"
141 + " <body onload='test()'>foo</body>\n"
142 + "</html>";
143
144 loadPageVerifyTitle2(html);
145 }
146
147
148
149
150 @Test
151 @Alerts({"[object HTMLElement]", "ReferenceError"})
152 public void type() throws Exception {
153 final String html = DOCTYPE_HTML
154 + "<html><head>\n"
155 + "<script>\n"
156 + LOG_TITLE_FUNCTION
157 + " function test() {\n"
158 + " var elem = document.getElementById('b1');\n"
159 + " try {\n"
160 + " log(elem);\n"
161 + " log(HTMLBaseFontElement);\n"
162 + " } catch(e) { logEx(e); }\n"
163 + " }\n"
164 + "</script>\n"
165 + "</head>\n"
166 + "<body onload='test()'>\n"
167 + " <basefont id='b1' color='red' face='swiss' size='4' />\n"
168 + "</body></html>";
169
170 loadPageVerifyTitle2(html);
171 }
172 }