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.htmlunit.junit.annotation.HtmlUnitNYI;
20 import org.junit.jupiter.api.Test;
21
22
23
24
25
26
27
28 public class HTMLEmbedElementTest extends WebDriverTestCase {
29
30
31
32
33 @Test
34 @Alerts(DEFAULT = {"left", "right", "bottom", "middle", "top",
35 "absbottom", "absmiddle", "baseline", "texttop", "wrong", ""},
36 FF = {"left", "right", "bottom", "middle", "top",
37 "absbottom", "absmiddle", "bottom", "texttop", "wrong", ""},
38 FF_ESR = {"left", "right", "bottom", "middle", "top",
39 "absbottom", "absmiddle", "bottom", "texttop", "wrong", ""})
40 @HtmlUnitNYI(FF = {"left", "right", "bottom", "middle", "top",
41 "absbottom", "absmiddle", "baseline", "texttop", "wrong", ""},
42 FF_ESR = {"left", "right", "bottom", "middle", "top",
43 "absbottom", "absmiddle", "baseline", "texttop", "wrong", ""})
44 public void getAlign() throws Exception {
45 final String html = DOCTYPE_HTML
46 + "<html><body>\n"
47 + " <embed id='e1' align='left' ></embed>\n"
48 + " <embed id='e2' align='right' ></embed>\n"
49 + " <embed id='e3' align='bottom' ></embed>\n"
50 + " <embed id='e4' align='middle' ></embed>\n"
51 + " <embed id='e5' align='top' ></embed>\n"
52 + " <embed id='e6' align='absbottom' ></embed>\n"
53 + " <embed id='e7' align='absmiddle' ></embed>\n"
54 + " <embed id='e8' align='baseline' ></embed>\n"
55 + " <embed id='e9' align='texttop' ></embed>\n"
56 + " <embed id='e10' align='wrong' ></embed>\n"
57 + " <embed id='e11' ></embed>\n"
58
59 + "<script>\n"
60 + LOG_TITLE_FUNCTION
61 + " for (var i = 1; i <= 11; i++) {\n"
62 + " log(document.getElementById('e' + i).align);\n"
63 + " }\n"
64 + "</script>\n"
65 + "</body></html>";
66
67 loadPageVerifyTitle2(html);
68 }
69
70
71
72
73 @Test
74 @Alerts(DEFAULT = {"CenTer", "8", "foo", "left", "right", "bottom", "middle", "top",
75 "absbottom", "absmiddle", "baseline", "texttop"},
76 FF = {"CenTer", "8", "foo", "left", "right", "bottom", "middle", "top",
77 "absbottom", "absmiddle", "bottom", "texttop"},
78 FF_ESR = {"CenTer", "8", "foo", "left", "right", "bottom", "middle", "top",
79 "absbottom", "absmiddle", "bottom", "texttop"})
80 @HtmlUnitNYI(FF = {"CenTer", "8", "foo", "left", "right", "bottom", "middle", "top",
81 "absbottom", "absmiddle", "baseline", "texttop"},
82 FF_ESR = {"CenTer", "8", "foo", "left", "right", "bottom", "middle", "top",
83 "absbottom", "absmiddle", "baseline", "texttop"})
84 public void setAlign() throws Exception {
85 final String html = DOCTYPE_HTML
86 + "<html><body>\n"
87 + " <embed id='e1' align='left' ></embed>\n"
88
89 + "<script>\n"
90 + LOG_TITLE_FUNCTION
91 + " function setAlign(elem, value) {\n"
92 + " try {\n"
93 + " elem.align = value;\n"
94 + " } catch(e) { logEx(e); }\n"
95 + " log(elem.align);\n"
96 + " }\n"
97
98 + " var elem = document.getElementById('e1');\n"
99 + " setAlign(elem, 'CenTer');\n"
100
101 + " setAlign(elem, '8');\n"
102 + " setAlign(elem, 'foo');\n"
103
104 + " setAlign(elem, 'left');\n"
105 + " setAlign(elem, 'right');\n"
106 + " setAlign(elem, 'bottom');\n"
107 + " setAlign(elem, 'middle');\n"
108 + " setAlign(elem, 'top');\n"
109 + " setAlign(elem, 'absbottom');\n"
110 + " setAlign(elem, 'absmiddle');\n"
111 + " setAlign(elem, 'baseline');\n"
112 + " setAlign(elem, 'texttop');\n"
113 + "</script>\n"
114 + "</body></html>";
115
116 loadPageVerifyTitle2(html);
117 }
118
119
120
121
122 @Test
123 @Alerts({"10px", "20em", "80%", "40", "wrong", ""})
124 public void getHeight() throws Exception {
125 final String html = DOCTYPE_HTML
126 + "<html><body>\n"
127 + " <embed id='e1' height='10px' ></embed>\n"
128 + " <embed id='e2' height='20em' ></embed>\n"
129 + " <embed id='e3' height='80%' ></embed>\n"
130 + " <embed id='e4' height='40' ></embed>\n"
131 + " <embed id='e5' height='wrong' ></embed>\n"
132 + " <embed id='e6' ></embed>\n"
133
134 + "<script>\n"
135 + LOG_TITLE_FUNCTION
136 + " for (var i = 1; i <= 6; i++) {\n"
137 + " log(document.getElementById('e' + i).height);\n"
138 + " }\n"
139 + "</script>\n"
140 + "</body></html>";
141
142 loadPageVerifyTitle2(html);
143 }
144
145
146
147
148 @Test
149 @Alerts({"20px", "8", "foo"})
150 public void setHeight() throws Exception {
151 final String html = DOCTYPE_HTML
152 + "<html><body>\n"
153 + " <embed id='e1' height='10px' ></embed>\n"
154
155 + "<script>\n"
156 + LOG_TITLE_FUNCTION
157 + " function setHeight(elem, value) {\n"
158 + " try {\n"
159 + " elem.height = value;\n"
160 + " } catch(e) { logEx(e); }\n"
161 + " log(elem.height);\n"
162 + " }\n"
163
164 + " var elem = document.getElementById('e1');\n"
165 + " setHeight(elem, '20px');\n"
166
167 + " setHeight(elem, '8');\n"
168 + " setHeight(elem, 'foo');\n"
169
170 + "</script>\n"
171 + "</body></html>";
172
173 loadPageVerifyTitle2(html);
174 }
175
176
177
178
179 @Test
180 @Alerts({"10px", "20em", "80%", "40", "wrong", ""})
181 public void getWidth() throws Exception {
182 final String html = DOCTYPE_HTML
183 + "<html><body>\n"
184 + " <embed id='e1' width='10px' ></embed>\n"
185 + " <embed id='e2' width='20em' ></embed>\n"
186 + " <embed id='e3' width='80%' ></embed>\n"
187 + " <embed id='e4' width='40' ></embed>\n"
188 + " <embed id='e5' width='wrong' ></embed>\n"
189 + " <embed id='e6' ></embed>\n"
190
191 + "<script>\n"
192 + LOG_TITLE_FUNCTION
193 + " for (var i = 1; i <= 6; i++) {\n"
194 + " log(document.getElementById('e' + i).width);\n"
195 + " }\n"
196 + "</script>\n"
197 + "</body></html>";
198
199 loadPageVerifyTitle2(html);
200 }
201
202
203
204
205 @Test
206 @Alerts({"20px", "8", "foo"})
207 public void setWidth() throws Exception {
208 final String html = DOCTYPE_HTML
209 + "<html><body>\n"
210 + " <embed id='e1' width='10px' ></embed>\n"
211
212 + "<script>\n"
213 + LOG_TITLE_FUNCTION
214 + " function setWidth(elem, value) {\n"
215 + " try {\n"
216 + " elem.width = value;\n"
217 + " } catch(e) { logEx(e); }\n"
218 + " log(elem.width);\n"
219 + " }\n"
220
221 + " var elem = document.getElementById('e1');\n"
222 + " setWidth(elem, '20px');\n"
223
224 + " setWidth(elem, '8');\n"
225 + " setWidth(elem, 'foo');\n"
226
227 + "</script>\n"
228 + "</body></html>";
229
230 loadPageVerifyTitle2(html);
231 }
232 }