@@ -47,16 +47,16 @@ public class HTMLFormElement2Test extends SimpleWebTestCase {
4747 */
4848 @ Test
4949 public void formSubmit () throws Exception {
50- final String html
51- = "<html><head><title>first</title></head><body>\n "
50+ final String html = DOCTYPE_HTML
51+ + "<html><head><title>first</title></head><body>\n "
5252 + "<p>hello world</p>\n "
5353 + "<form name='form1' method='get' action='" + URL_SECOND + "'>\n "
5454 + " <input type='button' name='button1' />\n "
5555 + " <input type='button' name='button2' />\n "
5656 + "</form>\n "
5757 + "</body></html>" ;
58- final String secondContent
59- = "<html><head><title>second</title></head><body>\n "
58+ final String secondContent = DOCTYPE_HTML
59+ + "<html><head><title>second</title></head><body>\n "
6060 + "<p>hello world</p>\n "
6161 + "</body></html>" ;
6262
@@ -74,8 +74,8 @@ public void formSubmit() throws Exception {
7474 @ Test
7575 @ Alerts ("javaScript" )
7676 public void formSubmitWithJavascript () throws Exception {
77- final String html
78- = "<html><head><title>first</title></head><body>\n "
77+ final String html = DOCTYPE_HTML
78+ + "<html><head><title>first</title></head><body>\n "
7979 + "<p>hello world</p>\n "
8080 + "<form name='form1' method='get' action='javascript:alert(\" javaScript\" )'>\n "
8181 + " <input type='button' name='button1' />\n "
@@ -99,8 +99,8 @@ public void formSubmitWithJavascript() throws Exception {
9999 @ Test
100100 @ Alerts ("javaScript" )
101101 public void formSubmitWithJavascriptLeadingWhitespace () throws Exception {
102- final String html
103- = "<html><head><title>first</title></head><body>\n "
102+ final String html = DOCTYPE_HTML
103+ + "<html><head><title>first</title></head><body>\n "
104104 + "<p>hello world</p>\n "
105105 + "<form name='form1' method='get' action=' javascript:alert(\" javaScript\" )'>\n "
106106 + " <input type='button' name='button1' />\n "
@@ -124,8 +124,8 @@ public void formSubmitWithJavascriptLeadingWhitespace() throws Exception {
124124 @ Test
125125 @ Alerts ("javaScript" )
126126 public void formSubmitWithJavascriptMixedCase () throws Exception {
127- final String html
128- = "<html><head><title>first</title></head><body>\n "
127+ final String html = DOCTYPE_HTML
128+ + "<html><head><title>first</title></head><body>\n "
129129 + "<p>hello world</p>\n "
130130 + "<form name='form1' method='get' action='javaSCript:alert(\" javaScript\" )'>\n "
131131 + " <input type='button' name='button1' />\n "
@@ -148,8 +148,8 @@ public void formSubmitWithJavascriptMixedCase() throws Exception {
148148 */
149149 @ Test
150150 public void onSubmitChangesAction () throws Exception {
151- final String html
152- = "<html><body>\n "
151+ final String html = DOCTYPE_HTML
152+ + "<html><body>\n "
153153 + "<form name='form1' action='" + URL_SECOND + "' onsubmit='this.action=\" " + URL_THIRD + "\" ' "
154154 + "method='post'>\n "
155155 + " <input type='submit' id='button1' />\n "
@@ -169,15 +169,15 @@ public void onSubmitChangesAction() throws Exception {
169169 */
170170 @ Test
171171 public void formSubmit_target () throws Exception {
172- final String html
173- = "<html><head><title>first</title></head><body>\n "
172+ final String html = DOCTYPE_HTML
173+ + "<html><head><title>first</title></head><body>\n "
174174 + "<p>hello world</p>\n "
175175 + "<form name='form1' method='get' action='" + URL_SECOND + "' target='MyNewWindow'>\n "
176176 + " <input type='button' name='button1' />\n "
177177 + "</form>\n "
178178 + "</body></html>" ;
179- final String secondContent
180- = "<html><head><title>second</title></head><body>\n "
179+ final String secondContent = DOCTYPE_HTML
180+ + "<html><head><title>second</title></head><body>\n "
181181 + "<p>hello world</p>\n "
182182 + "</body></html>" ;
183183
@@ -197,15 +197,15 @@ public void formSubmit_target() throws Exception {
197197 */
198198 @ Test
199199 public void formSubmitDoesntCallOnSubmit () throws Exception {
200- final String html
201- = "<html><head><title>first</title></head><body>\n "
200+ final String html = DOCTYPE_HTML
201+ + "<html><head><title>first</title></head><body>\n "
202202 + "<form name='form1' method='get' action='" + URL_SECOND + "' onsubmit=\" this.action = 'foo.html'\" >\n "
203203 + " <input type='submit' />\n "
204204 + "</form>\n "
205205 + "<a href='javascript:document.form1.submit()' id='link1'>Click me</a>\n "
206206 + "</body></html>" ;
207- final String secondContent
208- = "<html><head><title>second</title></head><body>\n "
207+ final String secondContent = DOCTYPE_HTML
208+ + "<html><head><title>second</title></head><body>\n "
209209 + "<p>hello world</p>\n "
210210 + "</body></html>" ;
211211
@@ -222,16 +222,16 @@ public void formSubmitDoesntCallOnSubmit() throws Exception {
222222 */
223223 @ Test
224224 public void formSubmit_MultipleButtons () throws Exception {
225- final String html
226- = "<html><head><title>first</title></head><body>\n "
225+ final String html = DOCTYPE_HTML
226+ + "<html><head><title>first</title></head><body>\n "
227227 + "<p>hello world</p>\n "
228228 + "<form name='form1' method='get' action='" + URL_SECOND + "'>\n "
229229 + " <button type='submit' name='button1' id='button1'/>\n "
230230 + " <button type='submit' name='button2' />\n "
231231 + "</form>\n "
232232 + "</body></html>" ;
233- final String secondContent
234- = "<html><head><title>second</title></head><body>\n "
233+ final String secondContent = DOCTYPE_HTML
234+ + "<html><head><title>second</title></head><body>\n "
235235 + "<p>hello world</p>\n "
236236 + "</body></html>" ;
237237
@@ -252,8 +252,8 @@ public void formSubmit_MultipleButtons() throws Exception {
252252 @ Test
253253 @ Alerts ("hi!" )
254254 public void lostFunction () throws Exception {
255- final String content
256- = "<html><head><title>foo</title><script>\n "
255+ final String content = DOCTYPE_HTML
256+ + "<html><head><title>foo</title><script>\n "
257257 + " function onSubmit() { alert('hi!'); return false; }\n "
258258 + "</script></head><body>\n "
259259 + "<form onsubmit='return onSubmit();'>\n "
@@ -274,8 +274,8 @@ public void lostFunction() throws Exception {
274274 @ Test
275275 @ Alerts ("hi!" )
276276 public void assignedOnsubmit () throws Exception {
277- final String content
278- = "<html><head><title>foo</title><script>\n "
277+ final String content = DOCTYPE_HTML
278+ + "<html><head><title>foo</title><script>\n "
279279 + " function onSubmit() { alert('hi!'); return false; }\n "
280280 + " function init() { document.myForm.onsubmit = onSubmit; }\n "
281281 + " window.onload = init;\n "
@@ -299,8 +299,8 @@ public void assignedOnsubmit() throws Exception {
299299 @ Test
300300 @ Alerts ("true" )
301301 public void thisInJavascriptAction () throws Exception {
302- final String content
303- = "<html>\n "
302+ final String content = DOCTYPE_HTML
303+ + "<html>\n "
304304 + "<body>\n "
305305 + "<form action='javascript:alert(this == window)'>\n "
306306 + "<input type='submit' id='theButton'>\n "
@@ -321,7 +321,8 @@ public void thisInJavascriptAction() throws Exception {
321321 @ Test
322322 @ Alerts ("onchange" )
323323 public void fileInput_fireOnChange () throws Exception {
324- final String html = "<html><body>\n "
324+ final String html = DOCTYPE_HTML
325+ + "<html><body>\n "
325326 + "<form>\n "
326327 + " <input type='file' name='myFile' id='myFile' onchange='alert(\" onchange\" )'/>\n "
327328 + "</form>\n "
0 commit comments