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
21
22
23
24
25
26 public class HTMLParamElementTest extends WebDriverTestCase {
27
28
29
30
31 @Test
32 @Alerts({"myValue", "", "", ""})
33 public void value() throws Exception {
34 final String html = DOCTYPE_HTML
35 + "<html><head>\n"
36 + "<script>\n"
37 + LOG_TITLE_FUNCTION
38 + " function test() {\n"
39 + " for(var i = 1; i < 5; i++) {\n"
40 + " var param = document.getElementById('tester' + i);\n"
41 + " log(param.value);\n"
42 + " }\n"
43 + " }\n"
44 + "</script>\n"
45 + "</head>\n"
46 + "<body onload='test()'>\n"
47 + " <object>\n"
48 + " <param id='tester1' name='testParam' value='myValue'/>\n"
49 + " <param id='tester2' name='testParam' value=''/>\n"
50 + " <param id='tester3' name='testParam' />\n"
51 + " <param id='tester4' />\n"
52 + " </object>\n"
53 + "</body></html>";
54
55 loadPageVerifyTitle2(html);
56 }
57
58
59
60
61 @Test
62 @Alerts({"testParam", "", "", ""})
63 public void name() throws Exception {
64 final String html = DOCTYPE_HTML
65 + "<html><head>\n"
66 + "<script>\n"
67 + LOG_TITLE_FUNCTION
68 + " function test() {\n"
69 + " for(var i = 1; i < 5; i++) {\n"
70 + " var param = document.getElementById('tester' + i);\n"
71 + " log(param.name);\n"
72 + " }\n"
73 + " }\n"
74 + "</script>\n"
75 + "</head>\n"
76 + "<body onload='test()'>\n"
77 + " <object>\n"
78 + " <param id='tester1' name='testParam' value='myValue'/>\n"
79 + " <param id='tester2' name='' value='myValue'/>\n"
80 + " <param id='tester3' value='myValue'/>\n"
81 + " <param id='tester4' />\n"
82 + " </object>\n"
83 + "</body></html>";
84
85 loadPageVerifyTitle2(html);
86 }
87
88
89
90
91 @Test
92 @Alerts({"ttt", "", "", "", "ttt", "", "", "", "ttt", "ttt", "ttt"})
93 public void type() throws Exception {
94 final String html = DOCTYPE_HTML
95 + "<html><head>\n"
96 + "<script>\n"
97 + LOG_TITLE_FUNCTION
98 + " function test() {\n"
99 + " for(var i = 1; i < 12; i++) {\n"
100 + " var param = document.getElementById('tester' + i);\n"
101 + " log(param.type);\n"
102 + " }\n"
103 + " }\n"
104 + "</script>\n"
105 + "</head>\n"
106 + "<body onload='test()'>\n"
107 + " <object>\n"
108 + " <param id='tester1' type='ttt' value='myValue'/>\n"
109 + " <param id='tester2' type='' value='myValue'/>\n"
110 + " <param id='tester3' value='myValue'/>\n"
111 + " <param id='tester4' />\n"
112
113 + " <param id='tester5' type='ttt' value='myValue' valueType='ref'/>\n"
114 + " <param id='tester6' type='' value='myValue' valueType='ref'/>\n"
115 + " <param id='tester7' value='myValue' valueType='ref'/>\n"
116 + " <param id='tester8' valueType='ref'/>\n"
117
118 + " <param id='tester9' type='ttt' value='myValue' valueType='data'/>\n"
119 + " <param id='tester10' type='ttt' value='myValue' valueType='object'/>\n"
120 + " <param id='tester11' type='ttt' value='myValue' valueType='foo'/>\n"
121 + " </object>\n"
122 + "</body></html>";
123
124 loadPageVerifyTitle2(html);
125 }
126
127
128
129
130 @Test
131 @Alerts({"ref", "object", "data", "foo"})
132 public void valueType() throws Exception {
133 final String html = DOCTYPE_HTML
134 + "<html><head>\n"
135 + "<script>\n"
136 + LOG_TITLE_FUNCTION
137 + " function test() {\n"
138 + " for(var i = 1; i < 5; i++) {\n"
139 + " var param = document.getElementById('tester' + i);\n"
140 + " log(param.valueType);\n"
141 + " }\n"
142 + " }\n"
143 + "</script>\n"
144 + "</head>\n"
145 + "<body onload='test()'>\n"
146 + " <object>\n"
147 + " <param id='tester1' valuetype='ref' value='myValue'/>\n"
148 + " <param id='tester2' valuetype='object' value='myValue'/>\n"
149 + " <param id='tester3' valuetype='data' value='myValue'/>\n"
150 + " <param id='tester4' valuetype='foo' value='myValue'/>\n"
151 + " </object>\n"
152 + "</body></html>";
153
154 loadPageVerifyTitle2(html);
155 }
156 }