Skip to content

Commit 3edd374

Browse files
committed
on the way to use html5 doctype for all our tests
1 parent 066f019 commit 3edd374

18 files changed

+152
-123
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public class BaseFrameElement2Test extends WebDriverTestCase {
3636
@Test
3737
@Alerts("posted called")
3838
public void windowEventListenersContainer() throws Exception {
39-
final String html
40-
= "<html>\n"
39+
final String html = DOCTYPE_HTML
40+
+ "<html>\n"
4141
+ "<head>\n"
4242
+ "<script>\n"
4343
+ " function test() {\n"
@@ -66,8 +66,8 @@ public void windowEventListenersContainer() throws Exception {
6666
*/
6767
@Test
6868
public void doNotLoopEndless() throws Exception {
69-
final String html
70-
= "<html>\n"
69+
final String html = DOCTYPE_HTML
70+
+ "<html>\n"
7171
+ "<head>\n"
7272
+ "</head>\n"
7373
+ "<body>\n"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public class BaseFrameElementTest extends SimpleWebTestCase {
3232
*/
3333
@Test
3434
public void removeIFrameAndAddAgain() throws Exception {
35-
final String html = "<html><head>\n"
35+
final String html = DOCTYPE_HTML
36+
+ "<html><head>\n"
3637
+ "<script>\n"
3738
+ " function test() {\n"
3839
+ " var frag1 = document.createDocumentFragment();\n"

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class ClickableElement2Test extends WebDriverTestCase {
4141
@Test
4242
@Alerts("1")
4343
public void clickOnFocus() throws Exception {
44-
final String html
45-
= "<html><head><script>" + LOG_TITLE_FUNCTION + "</script></head><body>\n"
44+
final String html = DOCTYPE_HTML
45+
+ "<html><head><script>" + LOG_TITLE_FUNCTION + "</script></head><body>\n"
4646
+ "<form>\n"
4747
+ " <input type='button' id='textfield1' onfocus='log(1)'>\n"
4848
+ "</form>\n"
@@ -60,7 +60,8 @@ public void clickOnFocus() throws Exception {
6060
@Test
6161
@Alerts({"click", "click", "dblclick"})
6262
public void dblClick() throws Exception {
63-
final String content = "<html>\n"
63+
final String content = DOCTYPE_HTML
64+
+ "<html>\n"
6465
+ "<head>\n"
6566
+ "<script>\n"
6667
+ LOG_TEXTAREA_FUNCTION

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private void onClickPageTest(final String htmlContent, final int numClicks,
104104
* @throws Exception if the test fails
105105
*/
106106
private void onClickBodyTest(final String htmlBody) throws Exception {
107-
onClickPageTest("<html><head><title>foo</title></head>\n" + htmlBody
107+
onClickPageTest(DOCTYPE_HTML + "<html><head><title>foo</title></head>\n" + htmlBody
108108
+ "</html>");
109109
}
110110

@@ -309,7 +309,8 @@ public void definitionDescription_onClick() throws Exception {
309309
*/
310310
@Test
311311
public void javaScriptError_onClick() throws Exception {
312-
onClickPageTest("<html><head></head><body>\n"
312+
onClickPageTest(DOCTYPE_HTML
313+
+ "<html><head></head><body>\n"
313314
+ "<form method='POST'><input type='button' id='clickId' onclick='y()'></form>\n"
314315
+ "</body></html>",
315316
1, false);
@@ -577,7 +578,8 @@ public void object_onClick() throws Exception {
577578
@BuggyWebDriver(CHROME = "")
578579
// ChromeDriver does not generate a "foo" but it occurs manually
579580
public void option_onClick() throws Exception {
580-
final String htmlContent = "<html><head><title>foo</title></head>\n"
581+
final String htmlContent = DOCTYPE_HTML
582+
+ "<html><head><title>foo</title></head>\n"
581583
+ "<body><form><select size='2'><option id='clickId' onClick='alert(\"foo\")'>\n"
582584
+ "Option</option></select></form></body>\n"
583585
+ "</html>";
@@ -825,7 +827,8 @@ public void tableRow_onClick() throws Exception {
825827
*/
826828
@Test
827829
public void tableRow_onClickSetOnLoad() throws Exception {
828-
onClickPageTest("<html><head>\n"
830+
onClickPageTest(DOCTYPE_HTML
831+
+ "<html><head>\n"
829832
+ "<script language='JavaScript'>\n"
830833
+ "function doFoo() { alert('foo'); }\n"
831834
+ "function doOnload() { document.getElementById('clickId').onclick = doFoo;}\n"
@@ -840,7 +843,8 @@ public void tableRow_onClickSetOnLoad() throws Exception {
840843
*/
841844
@Test
842845
public void checkbox_onClickUpdatesStateFirst() throws Exception {
843-
onClickPageTest("<html><head>\n"
846+
onClickPageTest(DOCTYPE_HTML
847+
+ "<html><head>\n"
844848
+ "<script language='JavaScript'>\n"
845849
+ "function doFoo(event) { if (this.checked) alert('foo'); else alert('bar'); }\n"
846850
+ "function doOnload() { document.getElementById('clickId').onclick = doFoo;}\n"
@@ -911,7 +915,8 @@ public void variable_onClick() throws Exception {
911915
@Test
912916
@Alerts("foo")
913917
public void setOnClick() throws Exception {
914-
onClickPageTest("<html><body><form>\n"
918+
onClickPageTest(DOCTYPE_HTML
919+
+ "<html><body><form>\n"
915920
+ "<button type='button' id='clickId' onclick='alert(\"foo\"); onclick=null;'>Item</button>\n"
916921
+ "</form></body></html>", 2);
917922
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public class DefaultElementFactoryTest extends SimpleWebTestCase {
4040
@Test
4141
public void attributeOrder() throws Exception {
4242
// Construct the test page.
43-
final String html = "<html><head><title>test page</title></head>\n"
43+
final String html = DOCTYPE_HTML
44+
+ "<html><head><title>test page</title></head>\n"
4445
+ "<body><div>test message</div></body></html>";
4546

4647
// Load the test page.
@@ -88,7 +89,8 @@ private static void verifyAttributes(final HtmlAnchor anchor) {
8889
*/
8990
@Test
9091
public void attributeOrderLive() throws Exception {
91-
final String html = "<html><body>\n"
92+
final String html = DOCTYPE_HTML
93+
+ "<html><body>\n"
9294
+ "<a href='http://www.google.com' tabindex='2' accesskey='F'>foo</a>\n"
9395
+ "</body></html>";
9496
final HtmlPage page = loadPage(html);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static Collection<String[]> data() {
7171
* @param elementHtml the HTML representing the element to test with attribute <code>id='element1'</code>
7272
*/
7373
public DisabledElementTest(final String elementHtml) {
74-
final String htmlContent = "<html><body><form id='form1'>{0}</form></body></html>";
74+
final String htmlContent = DOCTYPE_HTML + "<html><body><form id='form1'>{0}</form></body></html>";
7575
htmlContent_ = MessageFormat.format(htmlContent, new Object[]{elementHtml});
7676
}
7777

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DomAttrTest extends SimpleWebTestCase {
3232
*/
3333
@Test
3434
public void getCanonicalXPath() throws Exception {
35-
final String html = "<html id='foo'><body></body></html>";
35+
final String html = DOCTYPE_HTML + "<html id='foo'><body></body></html>";
3636
final HtmlPage page = loadPage(html);
3737
final DomAttr attr = page.getHtmlElementById("foo").getAttributeNode("id");
3838

@@ -44,7 +44,7 @@ public void getCanonicalXPath() throws Exception {
4444
*/
4545
@Test
4646
public void textContent() throws Exception {
47-
final String html = "<html id='foo'><body></body></html>";
47+
final String html = DOCTYPE_HTML + "<html id='foo'><body></body></html>";
4848
final HtmlPage page = loadPage(html);
4949
final DomAttr attr = page.getDocumentElement().getAttributeNode("id");
5050

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class DomCommentTest extends SimpleWebTestCase {
3535
*/
3636
@Test
3737
public void asNormalizedText() throws Exception {
38-
final String content = "<html><body><!-- a comment --></body></html>";
38+
final String content = DOCTYPE_HTML + "<html><body><!-- a comment --></body></html>";
3939
final HtmlPage page = loadPage(content);
4040
assertEquals("", page.asNormalizedText());
4141
}
@@ -47,7 +47,7 @@ public void asNormalizedText() throws Exception {
4747
@Test
4848
public void asXml() throws Exception {
4949
final String comment = "<!-- a comment -->";
50-
final String content = "<html><body><span id='foo'>" + comment + "</span></body></html>";
50+
final String content = DOCTYPE_HTML + "<html><body><span id='foo'>" + comment + "</span></body></html>";
5151
final HtmlPage page = loadPage(content);
5252
final HtmlElement elt = page.getHtmlElementById("foo");
5353
final DomNode node = elt.getFirstChild();
@@ -60,7 +60,7 @@ public void asXml() throws Exception {
6060
*/
6161
@Test
6262
public void textSibling() throws Exception {
63-
final String content = "<html><body id='body'><!-- c1 -->text<!-- c2 --></body></html>";
63+
final String content = DOCTYPE_HTML + "<html><body id='body'><!-- c1 -->text<!-- c2 --></body></html>";
6464
final HtmlPage page = loadPage(content);
6565
final DomNode node = page.getHtmlElementById("body").getFirstChild();
6666
assertEquals(DomText.NODE_NAME, node.getNextSibling().getNodeName());
@@ -71,7 +71,7 @@ public void textSibling() throws Exception {
7171
*/
7272
@Test
7373
public void setTextContent() throws Exception {
74-
final String html = "<html><body><span id='s'><!--abc--></span></body></html>";
74+
final String html = DOCTYPE_HTML + "<html><body><span id='s'><!--abc--></span></body></html>";
7575
final HtmlPage page = loadPage(html);
7676
final DomComment comment = (DomComment) page.getElementById("s").getFirstChild();
7777
assertEquals("abc", comment.getTextContent());
@@ -87,7 +87,7 @@ public void setTextContent() throws Exception {
8787
*/
8888
@Test
8989
public void getCanonicalXPath_withoutCommentSiblings() throws Exception {
90-
final String html = "<html><body><span id='s'><!--abc--></span></body></html>";
90+
final String html = DOCTYPE_HTML + "<html><body><span id='s'><!--abc--></span></body></html>";
9191
final HtmlPage page = loadPage(html);
9292
final DomComment comment = (DomComment) page.getElementById("s").getFirstChild();
9393
assertEquals("/html/body/span/comment()", comment.getCanonicalXPath());
@@ -102,7 +102,7 @@ public void getCanonicalXPath_withoutCommentSiblings() throws Exception {
102102
*/
103103
@Test
104104
public void getCanonicalXPath_withCommentSiblings() throws Exception {
105-
final String html = "<html><body><span id='s'><!--abc--><br/><!--def--></span></body></html>";
105+
final String html = DOCTYPE_HTML + "<html><body><span id='s'><!--abc--><br/><!--def--></span></body></html>";
106106
final HtmlPage page = loadPage(html);
107107

108108
final DomComment comment1 = (DomComment) page.getElementById("s").getFirstChild();

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public class DomDocumentFragmentTest extends WebDriverTestCase {
3535
@Test
3636
@Alerts({"undefined", "undefined"})
3737
public void xml() throws Exception {
38-
final String html = "<html><head><script>\n"
38+
final String html = DOCTYPE_HTML
39+
+ "<html><head><script>\n"
3940
+ LOG_TITLE_FUNCTION
4041
+ " function test() {\n"
4142
+ " var doc = document.implementation.createDocument('', '', null);\n"

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public final class DomElement2Test extends SimpleWebTestCase {
3636
*/
3737
@Test
3838
public void isMouseOver() throws Exception {
39-
final String html = "<html>\n"
39+
final String html = DOCTYPE_HTML
40+
+ "<html>\n"
4041
+ "<head></head>\n"
4142
+ "<body>\n"
4243
+ " <div id='d1'>\n"

0 commit comments

Comments
 (0)