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.BrowserRunner;
19 import org.htmlunit.junit.annotation.Alerts;
20 import org.junit.Test;
21 import org.junit.runner.RunWith;
22
23
24
25
26
27
28
29 @RunWith(BrowserRunner.class)
30 public class HTMLHRElementTest extends WebDriverTestCase {
31
32
33
34
35 @Test
36 @Alerts({"left", "right", "center", "wrong", ""})
37 public void getAlign() throws Exception {
38 final String html = DOCTYPE_HTML
39 + "<html><body>\n"
40 + " <hr id='h1' align='left' />\n"
41 + " <hr id='h2' align='right' />\n"
42 + " <hr id='h3' align='center' />\n"
43 + " <hr id='h4' align='wrong' />\n"
44 + " <hr id='h5' />\n"
45
46 + "<script>\n"
47 + LOG_TITLE_FUNCTION
48 + " for (var i = 1; i <= 5; i++) {\n"
49 + " log(document.getElementById('h' + i).align);\n"
50 + " }\n"
51 + "</script>\n"
52 + "</body></html>";
53
54 loadPageVerifyTitle2(html);
55 }
56
57
58
59
60 @Test
61 @Alerts({"CenTer", "8", "foo", "left", "right", "center"})
62 public void setAlign() throws Exception {
63 final String html = DOCTYPE_HTML
64 + "<html><body>\n"
65 + " <hr id='h1' align='left' />\n"
66
67 + "<script>\n"
68 + LOG_TITLE_FUNCTION
69 + " function setAlign(elem, value) {\n"
70 + " try {\n"
71 + " elem.align = value;\n"
72 + " } catch(e) { logEx(e); }\n"
73 + " log(elem.align);\n"
74 + " }\n"
75
76 + " var elem = document.getElementById('h1');\n"
77 + " setAlign(elem, 'CenTer');\n"
78
79 + " setAlign(elem, '8');\n"
80 + " setAlign(elem, 'foo');\n"
81
82 + " setAlign(elem, 'left');\n"
83 + " setAlign(elem, 'right');\n"
84 + " setAlign(elem, 'center');\n"
85 + "</script>\n"
86 + "</body></html>";
87 loadPageVerifyTitle2(html);
88 }
89 }