Skip to content

Commit 253fa61

Browse files
committed
on the way to use html5 doctype for all our tests
1 parent cf0d700 commit 253fa61

30 files changed

+93
-69
lines changed

src/test/java/org/htmlunit/WebTestCase.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
*/
6868
public abstract class WebTestCase {
6969

70+
/** The html5 doctype. */
71+
public static final String DOCTYPE_HTML = "<!DOCTYPE html>\n";
72+
7073
/**
7174
* Make the test method name available to the tests.
7275
*/

src/test/java/org/htmlunit/attachment/AttachmentTest.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public class AttachmentTest extends SimpleWebTestCase {
5353
*/
5454
@Test
5555
public void basic() throws Exception {
56-
final String content1 = "<html><body>\n"
56+
final String content1 = DOCTYPE_HTML
57+
+ "<html><body>\n"
5758
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
5859
+ "<input type='submit' value='ok'>\n"
5960
+ "</form>\n"
@@ -99,7 +100,8 @@ public void basic() throws Exception {
99100
*/
100101
@Test
101102
public void contentDispositionCaseInsensitive() throws Exception {
102-
final String content1 = "<html><body>\n"
103+
final String content1 = DOCTYPE_HTML
104+
+ "<html><body>\n"
103105
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
104106
+ "<input type='submit' value='ok'>\n"
105107
+ "</form>\n"
@@ -133,7 +135,7 @@ public void contentDispositionCaseInsensitive() throws Exception {
133135
*/
134136
@Test
135137
public void filename() throws Exception {
136-
final String content = "<html>But is it really?</html>";
138+
final String content = DOCTYPE_HTML + "<html>But is it really?</html>";
137139

138140
final WebClient client = getWebClient();
139141
final MockWebConnection conn = new MockWebConnection();
@@ -191,7 +193,8 @@ public void filenameFromAnchor() throws Exception {
191193
final List<Attachment> attachments = new ArrayList<>();
192194
client.setAttachmentHandler(new CollectingAttachmentHandler(attachments));
193195

194-
final String content = "<html>\n"
196+
final String content = DOCTYPE_HTML
197+
+ "<html>\n"
195198
+ "<head>\n"
196199
+ "<script>\n"
197200
+ "var blob = new Blob(['foo'], {type: 'text/plain'}),\n"
@@ -222,7 +225,8 @@ public void filenameFromFile() throws Exception {
222225
final List<Attachment> attachments = new ArrayList<>();
223226
client.setAttachmentHandler(new CollectingAttachmentHandler(attachments));
224227

225-
final String content = "<html>\n"
228+
final String content = DOCTYPE_HTML
229+
+ "<html>\n"
226230
+ "<head>\n"
227231
+ "<script>\n"
228232
+ "var blob = new File(['bar'], 'bar.txt', {type: 'text/plain'}),\n"
@@ -255,7 +259,8 @@ public void filenameFromFilePrioritizeAnchorDownloadOverFileName() throws Except
255259
final List<Attachment> attachments = new ArrayList<>();
256260
client.setAttachmentHandler(new CollectingAttachmentHandler(attachments));
257261

258-
final String content = "<html>\n"
262+
final String content = DOCTYPE_HTML
263+
+ "<html>\n"
259264
+ "<head>\n"
260265
+ "<script>\n"
261266
+ "var blob = new File(['bar'], 'bar.txt', {type: 'text/plain'}),\n"
@@ -282,7 +287,8 @@ public void filenameFromFilePrioritizeAnchorDownloadOverFileName() throws Except
282287
*/
283288
@Test
284289
public void jsChangeLocationAfterReceptionOfAttachment() throws Exception {
285-
final String html = "<html><body>\n"
290+
final String html = DOCTYPE_HTML
291+
+ "<html><body>\n"
286292
+ "<form action='action'>\n"
287293
+ "<input type='submit' onclick='window.location=\"foo\"; return false'>\n"
288294
+ "</form>\n"
@@ -315,7 +321,8 @@ public void jsChangeLocationAfterReceptionOfAttachment() throws Exception {
315321
*/
316322
@Test
317323
public void handleResponseFromHandler() throws Exception {
318-
final String content1 = "<html><body>\n"
324+
final String content1 = DOCTYPE_HTML
325+
+ "<html><body>\n"
319326
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
320327
+ "<input type='submit' value='ok'>\n"
321328
+ "</form>\n"
@@ -375,7 +382,8 @@ public void handleAttachment(final Page page, final String attachmentFilename) {
375382
*/
376383
@Test
377384
public void handleResponseFromHandlerWithFileName() throws Exception {
378-
final String content1 = "<html><body>\n"
385+
final String content1 = DOCTYPE_HTML
386+
+ "<html><body>\n"
379387
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
380388
+ "<input type='submit' value='ok'>\n"
381389
+ "</form>\n"
@@ -435,7 +443,8 @@ public void handleAttachment(final Page page, final String attachmentFilename) {
435443
*/
436444
@Test
437445
public void handleResponseOnlyApplicationOctetstream() throws Exception {
438-
final String content1 = "<html><body>\n"
446+
final String content1 = DOCTYPE_HTML
447+
+ "<html><body>\n"
439448
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
440449
+ "<input type='submit' value='ok'>\n"
441450
+ "</form>\n"

src/test/java/org/htmlunit/attachment/DownloadingAttachmentHandlerTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public class DownloadingAttachmentHandlerTest extends SimpleWebTestCase {
4747
*/
4848
@Test
4949
public void basic() throws Exception {
50-
final String content1 = "<html><body>\n"
50+
final String content1 = DOCTYPE_HTML
51+
+ "<html><body>\n"
5152
+ "<form method='POST' name='form' action='" + URL_SECOND + "'>\n"
5253
+ "<input type='submit' value='ok'>\n"
5354
+ "</form>\n"
@@ -102,7 +103,8 @@ public void basic() throws Exception {
102103
*/
103104
@Test
104105
public void basicFileNameFromUrl() throws Exception {
105-
final String content1 = "<html><body>\n"
106+
final String content1 = DOCTYPE_HTML
107+
+ "<html><body>\n"
106108
+ "<form method='POST' name='form' action='" + URL_SECOND + "test.txt'>\n"
107109
+ "<input type='submit' value='ok'>\n"
108110
+ "</form>\n"
@@ -157,7 +159,8 @@ public void basicFileNameFromUrl() throws Exception {
157159
*/
158160
@Test
159161
public void basicFileNameFromHeader() throws Exception {
160-
final String content1 = "<html><body>\n"
162+
final String content1 = DOCTYPE_HTML
163+
+ "<html><body>\n"
161164
+ "<form method='POST' name='form' action='" + URL_SECOND + "test.txt'>\n"
162165
+ "<input type='submit' value='ok'>\n"
163166
+ "</form>\n"

src/test/java/org/htmlunit/css/StyleAttributesIterable2Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public void inComputed() throws Exception {
5353
}
5454

5555
private void styleVsComputed(final String property) throws Exception {
56-
final String html =
57-
"<html><head>\n"
56+
final String html = DOCTYPE_HTML
57+
+ "<html><head>\n"
5858
+ "<script>\n"
5959
+ LOG_TITLE_FUNCTION
6060
+ " function test() {\n"

src/test/java/org/htmlunit/css/StyleAttributesIterableTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ private void test(final String propertyName) throws Exception {
8888
ServerRestartCount_ = 0;
8989
}
9090

91-
final String html =
92-
"<html><head><script>\n"
91+
final String html = DOCTYPE_HTML
92+
+ "<html><head><script>\n"
9393
+ LOG_TITLE_FUNCTION
9494
+ " function test() {\n"
9595
+ " var e = document.getElementById('myDiv');\n"

src/test/java/org/htmlunit/encoding/CssStyleSheetEncodingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ private void charset(
157157
// use always a different url to avoid caching effects
158158
final URL cssUrl = new URL(URL_SECOND, "" + System.currentTimeMillis() + ".js");
159159

160-
final String html
161-
= "<html><head>\n"
160+
final String html = DOCTYPE_HTML
161+
+ "<html><head>\n"
162162
+ " <link rel='stylesheet' href='" + cssUrl + "'/>\n"
163163
+ "<script>\n"
164164
+ LOG_TITLE_FUNCTION

src/test/java/org/htmlunit/encoding/HtmlPageEncodingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ private void charset(
165165
meta = "<meta charset='" + charsetMeta.getCharset().name().toLowerCase() + "' />\n";
166166
}
167167

168-
final String html
169-
= "<html><head>\n"
168+
final String html = DOCTYPE_HTML
169+
+ "<html><head>\n"
170170
+ meta
171171
+ " <title>a ä أهلاً мир 房间</title>\n"
172172
+ "</head>\n"

src/test/java/org/htmlunit/encoding/ScriptEncodingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ private void charset(
172172
// use always a different url to avoid caching effects
173173
final URL scriptUrl = new URL(URL_SECOND, "" + System.currentTimeMillis() + ".js");
174174

175-
String html
176-
= "<html><head>\n"
175+
String html = DOCTYPE_HTML
176+
+ "<html><head>\n"
177177
+ " <script>var logMsg = ''; function log(msg) { logMsg += msg + '\\xA7\\xA7'; }</script>\n"
178178
+ " <script type='text/javascript'>window.onerror=function(msg) { log(msg); }</script>"
179179
+ " <script src='" + scriptUrl + "'";

src/test/java/org/htmlunit/encoding/XMLHttpRequestResponseAsTextEncodingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ private void responseText(
135135
xmlEnc = "encoding=\"utf-8\"";
136136
}
137137

138-
final String html =
139-
"<html>\n"
138+
final String html = DOCTYPE_HTML
139+
+ "<html>\n"
140140
+ " <head>\n"
141141
+ " <script>\n"
142142
+ LOG_TEXTAREA_FUNCTION

src/test/java/org/htmlunit/encoding/XMLHttpRequestResponseAsXMLEncodingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ private void responseText(
135135
xmlEnc = "encoding=\"utf-8\"";
136136
}
137137

138-
final String html =
139-
"<html>\n"
138+
final String html = DOCTYPE_HTML
139+
+ "<html>\n"
140140
+ " <head>\n"
141141
+ " <script>\n"
142142
+ LOG_TEXTAREA_FUNCTION

0 commit comments

Comments
 (0)