Skip to content

Commit fd39abb

Browse files
committed
on the way to use html5 doctype for all our tests
1 parent 83f6d98 commit fd39abb

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

src/test/java/org/htmlunit/html/HtmlRbTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class HtmlRbTest extends WebDriverTestCase {
3636
FF = {"", "ruby-base", "ruby-base"},
3737
FF_ESR = {"", "ruby-base", "ruby-base"})
3838
public void defaultStyle() throws Exception {
39-
final String html = "<html><head>\n"
39+
final String html = DOCTYPE_HTML
40+
+ "<html><head>\n"
4041
+ "<script>\n"
4142
+ LOG_TITLE_FUNCTION
4243
+ " function test() {\n"

src/test/java/org/htmlunit/html/HtmlResetInputTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class HtmlResetInputTest extends SimpleWebTestCase {
3636
*/
3737
@Test
3838
public void reset() throws Exception {
39-
final String htmlContent
40-
= "<html><head><title>foo</title></head><body>\n"
39+
final String htmlContent = DOCTYPE_HTML
40+
+ "<html><head><title>foo</title></head><body>\n"
4141
+ "<form id='form1'>\n"
4242
+ "<input type='text' name='textfield1' id='textfield1' value='foo'/>\n"
4343
+ "<input type='password' name='password1' id='password1' value='foo'/>\n"
@@ -108,8 +108,8 @@ public void reset() throws Exception {
108108
*/
109109
@Test
110110
public void resetClick_onClick() throws Exception {
111-
final String htmlContent
112-
= "<html><head><title>foo</title></head><body>\n"
111+
final String htmlContent = DOCTYPE_HTML
112+
+ "<html><head><title>foo</title></head><body>\n"
113113
+ "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n"
114114
+ " <button type='reset' name='button' id='button' "
115115
+ "onClick='alert(\"foo\")'>Push me</button>\n"
@@ -131,8 +131,8 @@ public void resetClick_onClick() throws Exception {
131131
*/
132132
@Test
133133
public void outsideForm() throws Exception {
134-
final String html =
135-
"<html><head></head>\n"
134+
final String html = DOCTYPE_HTML
135+
+ "<html><head></head>\n"
136136
+ "<body>\n"
137137
+ "<input id='myInput' type='reset' onclick='alert(1)'>\n"
138138
+ "</body></html>";

src/test/java/org/htmlunit/html/HtmlScriptTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void badExternalScriptReference() throws Exception {
9090
*/
9191
@Test
9292
public void asNormalizedText() throws Exception {
93-
final String html = "<html><body><script id='s'>var foo = 132;</script></body></html>";
93+
final String html = DOCTYPE_HTML + "<html><body><script id='s'>var foo = 132;</script></body></html>";
9494
final HtmlPage page = loadPage(html);
9595
final HtmlScript script = page.getHtmlElementById("s");
9696
assertEquals("", script.asNormalizedText());
@@ -102,8 +102,8 @@ public void asNormalizedText() throws Exception {
102102
@Test
103103
@Alerts("hello")
104104
public void asXml() throws Exception {
105-
final String html
106-
= "<html><head><title>foo</title></head><body>\n"
105+
final String html = DOCTYPE_HTML
106+
+ "<html><head><title>foo</title></head><body>\n"
107107
+ "<script id='script1'>\n"
108108
+ " alert('hello');\n"
109109
+ "</script></body></html>";
@@ -123,7 +123,7 @@ public void asXml_scriptNestedInCData() throws Exception {
123123
final String script = "//<![CDATA[\n"
124124
+ "var foo = 132;\n"
125125
+ "//]]>";
126-
final String html = "<html><body><script id='s'>" + script + "</script></body></html>";
126+
final String html = DOCTYPE_HTML + "<html><body><script id='s'>" + script + "</script></body></html>";
127127
final HtmlPage page = loadPage(html);
128128
final HtmlScript scriptElement = page.getHtmlElementById("s");
129129
assertEquals("<script id=\"s\">\r\n" + script + "\r\n</script>\r\n",
@@ -137,7 +137,7 @@ public void asXml_scriptNestedInCData() throws Exception {
137137
@Test
138138
@Alerts("loaded")
139139
public void scriptCloneDoesNotReloadScript() throws Exception {
140-
final String html = "<html><body><script src='" + URL_SECOND + "'></script></body></html>";
140+
final String html = DOCTYPE_HTML + "<html><body><script src='" + URL_SECOND + "'></script></body></html>";
141141
final String js = "alert('loaded')";
142142

143143
final WebClient client = getWebClient();
@@ -179,8 +179,8 @@ public void addEventListener_error_clientDoesNotThrow() throws Exception {
179179

180180
private void addEventListener_error(final boolean throwOnFailingStatusCode) throws Exception {
181181
final URL fourOhFour = new URL(URL_FIRST, "/404");
182-
final String html
183-
= "<html><head>\n"
182+
final String html = DOCTYPE_HTML
183+
+ "<html><head>\n"
184184
+ "<script>\n"
185185
+ " function test() {\n"
186186
+ " var s1 = document.createElement('script');\n"
@@ -238,7 +238,7 @@ private void addEventListener_error(final boolean throwOnFailingStatusCode) thro
238238
*/
239239
@Test
240240
public void isDisplayed() throws Exception {
241-
final String html = "<html><head><title>Page A</title></head><body><script>var x = 1;</script></body></html>";
241+
final String html = DOCTYPE_HTML + "<html><head><title>Page A</title></head><body><script>var x = 1;</script></body></html>";
242242
final HtmlPage page = loadPageWithAlerts(html);
243243
final HtmlScript script = page.getFirstByXPath("//script");
244244
assertFalse(script.isDisplayed());
@@ -252,16 +252,16 @@ public void isDisplayed() throws Exception {
252252
@Test
253253
@Alerts({"First script executes", "Second page loading"})
254254
public void changingLocationSkipsFurtherScriptsOnPage() throws Exception {
255-
final String html
256-
= "<html><head></head>\n"
255+
final String html = DOCTYPE_HTML
256+
+ "<html><head></head>\n"
257257
+ "<body onload='alert(\"body onload executing but should be skipped\")'>\n"
258258
+ "<script>alert('First script executes')</script>\n"
259259
+ "<script>window.location.href='" + URL_SECOND + "'</script>\n"
260260
+ "<script>alert('Third script executing but should be skipped')</script>\n"
261261
+ "</body></html>";
262262

263-
final String secondPage
264-
= "<html><head></head><body>\n"
263+
final String secondPage = DOCTYPE_HTML
264+
+ "<html><head></head><body>\n"
265265
+ "<script>alert('Second page loading')</script>\n"
266266
+ "</body></html>";
267267

0 commit comments

Comments
 (0)