Skip to content

Commit b5ae0de

Browse files
committed
on the way to use html5 doctype for all our tests
1 parent 7415df0 commit b5ae0de

26 files changed

+950
-781
lines changed

src/test/java/org/htmlunit/javascript/host/NavigatorTest.java

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
package org.htmlunit.javascript.host;
1616

1717
import org.htmlunit.WebDriverTestCase;
18-
import org.htmlunit.html.HtmlPageTest;
1918
import org.htmlunit.junit.BrowserRunner;
2019
import org.htmlunit.junit.annotation.Alerts;
2120
import org.junit.Test;
@@ -92,7 +91,8 @@ public void browserLanguage() throws Exception {
9291
CHROME = {"string", "20030107"},
9392
EDGE = {"string", "20030107"})
9493
public void productSub() throws Exception {
95-
final String html = "<html><head>\n"
94+
final String html = DOCTYPE_HTML
95+
+ "<html><head>\n"
9696
+ "<script>\n"
9797
+ LOG_TITLE_FUNCTION
9898
+ " log(typeof(navigator.productSub));\n"
@@ -175,7 +175,8 @@ public void userLanguage() throws Exception {
175175
"Microsoft Edge PDF Viewer", "Portable Document Format", "internal-pdf-viewer", "undefined",
176176
"WebKit built-in PDF", "Portable Document Format", "internal-pdf-viewer", "undefined"})
177177
public void plugins() throws Exception {
178-
final String html = "<html>\n"
178+
final String html = DOCTYPE_HTML
179+
+ "<html>\n"
179180
+ "<head>\n"
180181
+ " <script>\n"
181182
+ LOG_TITLE_FUNCTION
@@ -205,7 +206,8 @@ public void plugins() throws Exception {
205206
@Test
206207
@Alerts("Shockwave Flash not available")
207208
public void pluginsShockwaveFlash() throws Exception {
208-
final String html = "<html>\n"
209+
final String html = DOCTYPE_HTML
210+
+ "<html>\n"
209211
+ "<head>\n"
210212
+ " <script>\n"
211213
+ LOG_TITLE_FUNCTION
@@ -242,8 +244,8 @@ public void pluginsShockwaveFlash() throws Exception {
242244
"application/pdf", "Portable Document Format", "pdf", "[object Plugin]", "true",
243245
"text/pdf", "Portable Document Format", "pdf", "[object Plugin]", "true"})
244246
public void mimeTypes() throws Exception {
245-
final String html
246-
= "<html><head>\n"
247+
final String html = DOCTYPE_HTML
248+
+ "<html><head>\n"
247249
+ " <script>\n"
248250
+ LOG_TITLE_FUNCTION
249251
+ " function doTest() {\n"
@@ -273,7 +275,8 @@ public void mimeTypes() throws Exception {
273275
CHROME = "TypeError",
274276
EDGE = "TypeError")
275277
public void taintEnabled() throws Exception {
276-
final String html = "<html>\n"
278+
final String html = DOCTYPE_HTML
279+
+ "<html>\n"
277280
+ "<head>\n"
278281
+ " <script>\n"
279282
+ LOG_TITLE_FUNCTION
@@ -298,7 +301,8 @@ public void taintEnabled() throws Exception {
298301
* @throws Exception on test failure
299302
*/
300303
void attribute(final String name, final String value, final String... ignore) throws Exception {
301-
final String html = "<html>\n"
304+
final String html = DOCTYPE_HTML
305+
+ "<html>\n"
302306
+ "<head>\n"
303307
+ " <script>\n"
304308
+ LOG_TITLE_FUNCTION
@@ -322,8 +326,8 @@ void attribute(final String name, final String value, final String... ignore) th
322326
@Test
323327
@Alerts("en-US")
324328
public void language() throws Exception {
325-
final String html
326-
= "<html><head>\n"
329+
final String html = DOCTYPE_HTML
330+
+ "<html><head>\n"
327331
+ " <script>\n"
328332
+ LOG_TITLE_FUNCTION
329333
+ " </script>\n"
@@ -341,8 +345,8 @@ public void language() throws Exception {
341345
@Test
342346
@Alerts("en-US,en")
343347
public void languages() throws Exception {
344-
final String html
345-
= "<html><head>\n"
348+
final String html = DOCTYPE_HTML
349+
+ "<html><head>\n"
346350
+ " <script>\n"
347351
+ LOG_TITLE_FUNCTION
348352
+ " </script>\n"
@@ -359,8 +363,8 @@ public void languages() throws Exception {
359363
@Test
360364
@Alerts({"number", "number"})
361365
public void mozilla() throws Exception {
362-
final String html
363-
= "<html><head>\n"
366+
final String html = DOCTYPE_HTML
367+
+ "<html><head>\n"
364368
+ "<script>\n"
365369
+ LOG_TITLE_FUNCTION
366370
+ "function test() {\n"
@@ -380,8 +384,8 @@ public void mozilla() throws Exception {
380384
@Test
381385
@Alerts("Gecko")
382386
public void product() throws Exception {
383-
final String html
384-
= "<html><head>\n"
387+
final String html = DOCTYPE_HTML
388+
+ "<html><head>\n"
385389
+ "<script>\n"
386390
+ LOG_TITLE_FUNCTION
387391
+ "function test() {\n"
@@ -400,8 +404,8 @@ public void product() throws Exception {
400404
@Test
401405
@Alerts("[object Geolocation]")
402406
public void geolocation() throws Exception {
403-
final String html
404-
= "<html><head>\n"
407+
final String html = DOCTYPE_HTML
408+
+ "<html><head>\n"
405409
+ "<script>\n"
406410
+ LOG_TITLE_FUNCTION
407411
+ "function test() {\n"
@@ -422,8 +426,8 @@ public void geolocation() throws Exception {
422426
FF = "20181001000000",
423427
FF_ESR = "20181001000000")
424428
public void buildID() throws Exception {
425-
final String html
426-
= "<html><head>\n"
429+
final String html = DOCTYPE_HTML
430+
+ "<html><head>\n"
427431
+ "<script>\n"
428432
+ LOG_TITLE_FUNCTION
429433
+ "function test() {\n"
@@ -444,8 +448,8 @@ public void buildID() throws Exception {
444448
FF = {"", ""},
445449
FF_ESR = {"", ""})
446450
public void vendor() throws Exception {
447-
final String html
448-
= "<html><head>\n"
451+
final String html = DOCTYPE_HTML
452+
+ "<html><head>\n"
449453
+ "<script>\n"
450454
+ LOG_TITLE_FUNCTION
451455
+ "function test() {\n"
@@ -467,8 +471,8 @@ public void vendor() throws Exception {
467471
FF = "true",
468472
FF_ESR = "true")
469473
public void oscpu() throws Exception {
470-
final String html
471-
= "<html><head>\n"
474+
final String html = DOCTYPE_HTML
475+
+ "<html><head>\n"
472476
+ "<script>\n"
473477
+ LOG_TITLE_FUNCTION
474478
+ "function test() {\n"
@@ -489,7 +493,7 @@ public void oscpu() throws Exception {
489493
CHROME = {"[object NetworkInformation]", "undefined", "undefined"},
490494
EDGE = {"[object NetworkInformation]", "undefined", "undefined"})
491495
public void connection() throws Exception {
492-
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
496+
final String html = DOCTYPE_HTML
493497
+ "<html><head>\n"
494498
+ "<script>\n"
495499
+ LOG_TITLE_FUNCTION
@@ -513,7 +517,7 @@ public void connection() throws Exception {
513517
CHROME = {"null", "undefined", "undefined"},
514518
EDGE = {"null", "undefined", "undefined"})
515519
public void doNotTrack() throws Exception {
516-
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
520+
final String html = DOCTYPE_HTML
517521
+ "<html><head>\n"
518522
+ "<script>\n"
519523
+ LOG_TITLE_FUNCTION
@@ -535,7 +539,7 @@ public void doNotTrack() throws Exception {
535539
@Test
536540
@Alerts({"[object MediaDevices]", "true"})
537541
public void mediaDevices() throws Exception {
538-
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
542+
final String html = DOCTYPE_HTML
539543
+ "<html><head>\n"
540544
+ "<script>\n"
541545
+ LOG_TITLE_FUNCTION
@@ -556,7 +560,7 @@ public void mediaDevices() throws Exception {
556560
@Test
557561
@Alerts("true")
558562
public void pdfViewerEnabled() throws Exception {
559-
final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
563+
final String html = DOCTYPE_HTML
560564
+ "<html><head>\n"
561565
+ "<script>\n"
562566
+ LOG_TITLE_FUNCTION

src/test/java/org/htmlunit/javascript/host/NetscapeTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public class NetscapeTest extends WebDriverTestCase {
3939
FF = {"[object Object]", "undefined", "[object Object]", "undefined"},
4040
FF_ESR = {"[object Object]", "undefined", "[object Object]", "undefined"})
4141
public void netscape() throws Exception {
42-
final String html = "<html><body>\n"
42+
final String html = DOCTYPE_HTML
43+
+ "<html><body>\n"
4344
+ "<script>\n"
4445
+ LOG_TITLE_FUNCTION
4546
+ "try {\n"
@@ -64,7 +65,8 @@ public void netscape() throws Exception {
6465
@HtmlUnitNYI(FF = {"undefined", "true", "true"},
6566
FF_ESR = {"undefined", "true", "true"})
6667
public void netscapeDescriptor() throws Exception {
67-
final String html = "<html><body>\n"
68+
final String html = DOCTYPE_HTML
69+
+ "<html><body>\n"
6870
+ "<script>\n"
6971
+ LOG_TITLE_FUNCTION
7072
+ "try {\n"

src/test/java/org/htmlunit/javascript/host/NotificationTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public class NotificationTest extends WebDriverTestCase {
3636
@Test
3737
@Alerts({"function", "true"})
3838
public void prototype() throws Exception {
39-
final String html = "<html><body><script>\n"
39+
final String html = DOCTYPE_HTML
40+
+ "<html><body><script>\n"
4041
+ LOG_TITLE_FUNCTION
4142
+ "try {\n"
4243
+ " log(typeof window.Notification);\n"
@@ -53,7 +54,8 @@ public void prototype() throws Exception {
5354
@Test
5455
@Alerts("default")
5556
public void permission() throws Exception {
56-
final String html = "<html><body><script>\n"
57+
final String html = DOCTYPE_HTML
58+
+ "<html><body><script>\n"
5759
+ LOG_TITLE_FUNCTION
5860
+ "try {\n"
5961
+ " log(Notification.permission);\n"
@@ -69,7 +71,8 @@ public void permission() throws Exception {
6971
@Test
7072
@Alerts({})
7173
public void minimalUsage() throws Exception {
72-
final String html = "<html><body><script>\n"
74+
final String html = DOCTYPE_HTML
75+
+ "<html><body><script>\n"
7376
+ LOG_TITLE_FUNCTION
7477
+ "try {\n"
7578
+ " new Notification('Hello here');\n"
@@ -85,7 +88,8 @@ public void minimalUsage() throws Exception {
8588
@Test
8689
@Alerts("function")
8790
public void requestPermission() throws Exception {
88-
final String html = "<html><body><script>\n"
91+
final String html = DOCTYPE_HTML
92+
+ "<html><body><script>\n"
8993
+ LOG_TITLE_FUNCTION
9094
+ "try {\n"
9195
+ " log(typeof Notification.requestPermission);\n"

src/test/java/org/htmlunit/javascript/host/PluginTest.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public class PluginTest extends WebDriverTestCase {
3939
"Microsoft Edge PDF Viewer", "Portable Document Format", "internal-pdf-viewer", "undefined",
4040
"WebKit built-in PDF", "Portable Document Format", "internal-pdf-viewer", "undefined"})
4141
public void plugins() throws Exception {
42-
final String html = "<html>\n"
42+
final String html = DOCTYPE_HTML
43+
+ "<html>\n"
4344
+ "<head>\n"
4445
+ " <script>\n"
4546
+ LOG_TITLE_FUNCTION
@@ -68,7 +69,8 @@ public void plugins() throws Exception {
6869
@Test
6970
@Alerts("Chromium PDF Viewer")
7071
public void index() throws Exception {
71-
final String html = "<html><head><script>\n"
72+
final String html = DOCTYPE_HTML
73+
+ "<html><head><script>\n"
7274
+ LOG_TITLE_FUNCTION
7375
+ "function test() {\n"
7476
+ " log(navigator.plugins[2].name);\n"
@@ -85,7 +87,8 @@ public void index() throws Exception {
8587
@Test
8688
@Alerts("Microsoft Edge PDF Viewer")
8789
public void item() throws Exception {
88-
final String html = "<html><head><script>\n"
90+
final String html = DOCTYPE_HTML
91+
+ "<html><head><script>\n"
8992
+ LOG_TITLE_FUNCTION
9093
+ "function test() {\n"
9194
+ " log(navigator.plugins.item(3).name);\n"
@@ -102,7 +105,8 @@ public void item() throws Exception {
102105
@Test
103106
@Alerts("Chromium PDF Viewer")
104107
public void namedItem() throws Exception {
105-
final String html = "<html><head><script>\n"
108+
final String html = DOCTYPE_HTML
109+
+ "<html><head><script>\n"
106110
+ LOG_TITLE_FUNCTION
107111
+ "function test() {\n"
108112
+ " log(navigator.plugins.namedItem('Chromium PDF Viewer').name);\n"
@@ -119,7 +123,8 @@ public void namedItem() throws Exception {
119123
@Test
120124
@Alerts({"true", "false"})
121125
public void in() throws Exception {
122-
final String html = "<html><head><script>\n"
126+
final String html = DOCTYPE_HTML
127+
+ "<html><head><script>\n"
123128
+ LOG_TITLE_FUNCTION
124129
+ "function test() {\n"
125130
+ " log('PDF Viewer' in navigator.plugins);\n"
@@ -137,7 +142,8 @@ public void in() throws Exception {
137142
@Test
138143
@Alerts({"2", "[object MimeType]", "application/pdf", "[object MimeType]", "text/pdf", "undefined"})
139144
public void pluginIndex() throws Exception {
140-
final String html = "<html><head><script>\n"
145+
final String html = DOCTYPE_HTML
146+
+ "<html><head><script>\n"
141147
+ LOG_TITLE_FUNCTION
142148
+ "function test() {\n"
143149
+ " let pl = navigator.plugins.item(4);\n"
@@ -163,7 +169,8 @@ public void pluginIndex() throws Exception {
163169
@Test
164170
@Alerts({"2", "[object MimeType]", "application/pdf", "[object MimeType]", "text/pdf", "null"})
165171
public void pluginItem() throws Exception {
166-
final String html = "<html><head><script>\n"
172+
final String html = DOCTYPE_HTML
173+
+ "<html><head><script>\n"
167174
+ LOG_TITLE_FUNCTION
168175
+ "function test() {\n"
169176
+ " let pl = navigator.plugins.item(4);\n"
@@ -189,7 +196,8 @@ public void pluginItem() throws Exception {
189196
@Test
190197
@Alerts({"[object MimeType]", "application/pdf", "[object MimeType]", "application/pdf", "null"})
191198
public void pluginNamedItem() throws Exception {
192-
final String html = "<html><head><script>\n"
199+
final String html = DOCTYPE_HTML
200+
+ "<html><head><script>\n"
193201
+ LOG_TITLE_FUNCTION
194202
+ "function test() {\n"
195203
+ " let pl = navigator.plugins.item(4);\n"
@@ -215,7 +223,8 @@ public void pluginNamedItem() throws Exception {
215223
@Alerts({"5", "PDF Viewer", "Chrome PDF Viewer", "Chromium PDF Viewer",
216224
"Microsoft Edge PDF Viewer", "WebKit built-in PDF"})
217225
public void iterator() throws Exception {
218-
final String html = "<html><head><script>\n"
226+
final String html = DOCTYPE_HTML
227+
+ "<html><head><script>\n"
219228
+ LOG_TITLE_FUNCTION
220229
+ "function test() {\n"
221230
+ " var plugs = navigator.plugins;\n"
@@ -238,7 +247,8 @@ public void iterator() throws Exception {
238247
@Test
239248
@Alerts({"2", "application/pdf", "text/pdf"})
240249
public void pluginIterator() throws Exception {
241-
final String html = "<html><head><script>\n"
250+
final String html = DOCTYPE_HTML
251+
+ "<html><head><script>\n"
242252
+ LOG_TITLE_FUNCTION
243253
+ "function test() {\n"
244254
+ " let pl = navigator.plugins.item(4);\n"

src/test/java/org/htmlunit/javascript/host/Popup2Test.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public class Popup2Test extends WebDriverTestCase {
3838
@Test
3939
@Alerts("TypeError")
4040
public void popup() throws Exception {
41-
final String html = "<html><head></title><body>\n"
41+
final String html = DOCTYPE_HTML
42+
+ "<html><head></title><body>\n"
4243
+ "<script>\n"
4344
+ LOG_TITLE_FUNCTION
4445
+ " try {\n"
@@ -62,7 +63,8 @@ public void popup() throws Exception {
6263
@Test
6364
@Alerts("TypeError")
6465
public void popupBodyStyle() throws Exception {
65-
final String html = "<html><head><body>\n"
66+
final String html = DOCTYPE_HTML
67+
+ "<html><head><body>\n"
6668
+ "<script language='javascript'>\n"
6769
+ LOG_TITLE_FUNCTION
6870
+ " try {\n"

src/test/java/org/htmlunit/javascript/host/PopupTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public class PopupTest extends SimpleWebTestCase {
4242
@Test
4343
@Alerts("Pop-up window is Open")
4444
public void popupWindowBecomesCurrent() throws Exception {
45-
final String content = "<html><head><title>First</title><body>\n"
45+
final String content = DOCTYPE_HTML
46+
+ "<html><head><title>First</title><body>\n"
4647
+ "<span id='button' onClick='openPopup()'>Push me</span>\n"
4748
+ "<script>\n"
4849
+ " function openPopup() {\n "

0 commit comments

Comments
 (0)