Skip to content

Commit a837400

Browse files
committed
on the way to use html5 doctype for all our tests
1 parent 4aecbd4 commit a837400

11 files changed

+465
-407
lines changed

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

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public class HtmlElement2Test extends WebDriverTestCase {
5151
*/
5252
@Test
5353
public void onpropertychange() throws Exception {
54-
final String html =
55-
"<html><head><script>\n"
54+
final String html = DOCTYPE_HTML
55+
+ "<html><head><script>\n"
5656
+ LOG_TITLE_FUNCTION
5757
+ " function test() {\n"
5858
+ " document.getElementById('input1').value = 'New Value';\n"
@@ -74,8 +74,8 @@ public void onpropertychange() throws Exception {
7474
@Test
7575
@Alerts({"true", "true"})
7676
public void duplicateId() throws Exception {
77-
final String html
78-
= "<html>\n"
77+
final String html = DOCTYPE_HTML
78+
+ "<html>\n"
7979
+ "<script>\n"
8080
+ LOG_TITLE_FUNCTION
8181
+ " function test() {\n"
@@ -98,7 +98,8 @@ public void duplicateId() throws Exception {
9898
*/
9999
@Test
100100
public void onpropertychange2() throws Exception {
101-
final String html = "<html><head><script>\n"
101+
final String html = DOCTYPE_HTML
102+
+ "<html><head><script>\n"
102103
+ LOG_TITLE_FUNCTION
103104
+ " function test() {\n"
104105
+ " document.getElementById('input1').value = 'New Value';\n"
@@ -124,7 +125,8 @@ public void onpropertychange2() throws Exception {
124125
@Test
125126
@Alerts({"false", "true", "a", "a", "b", "b", "b", "c"})
126127
public void clonedNodeAttributes() throws Exception {
127-
final String html = "<html><body id='a' title='b'><script>\n"
128+
final String html = DOCTYPE_HTML
129+
+ "<html><body id='a' title='b'><script>\n"
128130
+ LOG_TITLE_FUNCTION
129131
+ "var x = document.body.cloneNode(true);\n"
130132
+ "log(document.body == x);\n"
@@ -149,8 +151,8 @@ public void clonedNodeAttributes() throws Exception {
149151
@Test
150152
@Alerts({"true", "undefined", "undefined"})
151153
public void textAndXmlUndefined() throws Exception {
152-
final String html
153-
= "<html><head></head>\n"
154+
final String html = DOCTYPE_HTML
155+
+ "<html><head></head>\n"
154156
+ "<body>\n"
155157
+ " <input type='text' id='textfield1' onfocus='log(1)'>\n"
156158
+ " <script>\n"
@@ -176,8 +178,8 @@ public void textAndXmlUndefined() throws Exception {
176178
//TODO: fails because of HTMLElement.getContentEditable doesn't detect DomElement.ATTRIBUTE_VALUE_EMPTY
177179
// this could be a general attribute issue
178180
public void contentEditable() throws Exception {
179-
final String html
180-
= "<html>\n"
181+
final String html = DOCTYPE_HTML
182+
+ "<html>\n"
181183
+ "<body contentEditable><p>initial</p></body>\n"
182184
+ "</html>";
183185

@@ -199,7 +201,8 @@ public void contentEditable() throws Exception {
199201
@BuggyWebDriver(FF_ESR = "down: 49,0 press: 33,33 up: 49,0 down: 220,0 press: 124,124 up: 220,0",
200202
FF = "down: 49,0 press: 33,33 up: 49,0 down: 220,0 press: 124,124 up: 220,0")
201203
public void shiftKeys() throws Exception {
202-
final String html = "<html><head><script>\n"
204+
final String html = DOCTYPE_HTML
205+
+ "<html><head><script>\n"
203206
+ " function appendMessage(message) {\n"
204207
+ " document.getElementById('result').innerHTML += message + ' ';\n"
205208
+ " }\n"
@@ -226,8 +229,7 @@ public void shiftKeys() throws Exception {
226229
CHROME = "[object HTMLInputElement] onblur onfocusout [object HTMLBodyElement]",
227230
EDGE = "[object HTMLInputElement] onblur onfocusout [object HTMLBodyElement]")
228231
public void removeActiveElement() throws Exception {
229-
final String html =
230-
HtmlPageTest.STANDARDS_MODE_PREFIX_
232+
final String html = DOCTYPE_HTML
231233
+ "<html>\n"
232234
+ "<head>\n"
233235
+ "<script>\n"
@@ -259,8 +261,7 @@ public void removeActiveElement() throws Exception {
259261
CHROME = "[object HTMLInputElement] onblur1 onfocusout1 [object HTMLBodyElement]",
260262
EDGE = "[object HTMLInputElement] onblur1 onfocusout1 [object HTMLBodyElement]")
261263
public void removeParentOfActiveElement() throws Exception {
262-
final String html =
263-
HtmlPageTest.STANDARDS_MODE_PREFIX_
264+
final String html = DOCTYPE_HTML
264265
+ "<html>\n"
265266
+ "<head>\n"
266267
+ "<script>\n"
@@ -304,8 +305,7 @@ public void addRemove() throws Exception {
304305
getMockWebConnection().setResponse(urlImage, directBytes, 200, "ok", "image/jpg", Collections.emptyList());
305306
}
306307

307-
final String html =
308-
HtmlPageTest.STANDARDS_MODE_PREFIX_
308+
final String html = DOCTYPE_HTML
309309
+ "<html>\n"
310310
+ "<head>\n"
311311
+ "<script>\n"
@@ -344,7 +344,8 @@ public void addRemove() throws Exception {
344344
*/
345345
@Test
346346
public void keyPressEventWhenPreventsDefault() throws Exception {
347-
final String html = "<html>\n"
347+
final String html = DOCTYPE_HTML
348+
+ "<html>\n"
348349
+ "<body>\n"
349350
+ " <input id='suppress' onkeydown='event.preventDefault()' onkeypress='alert(\"press\")'>\n"
350351
+ "</body></html>";
@@ -360,7 +361,8 @@ public void keyPressEventWhenPreventsDefault() throws Exception {
360361
@Test
361362
@Alerts("press")
362363
public void keyUpEventWhenPreventsDefault() throws Exception {
363-
final String html = "<html>\n"
364+
final String html = DOCTYPE_HTML
365+
+ "<html>\n"
364366
+ "<body>\n"
365367
+ " <input id='suppress' onkeydown='event.preventDefault()' onkeyup='alert(\"press\")'>\n"
366368
+ "</body></html>";
@@ -376,7 +378,8 @@ public void keyUpEventWhenPreventsDefault() throws Exception {
376378
@Test
377379
@Alerts({"[object HTMLHtmlElement]", "null"})
378380
public void detach() throws Exception {
379-
final String html = "<html><head><script>\n"
381+
final String html = DOCTYPE_HTML
382+
+ "<html><head><script>\n"
380383
+ LOG_TITLE_FUNCTION
381384
+ " function test() {\n"
382385
+ " var xhr = new XMLHttpRequest();\n"
@@ -404,7 +407,8 @@ public void detach() throws Exception {
404407
@Test
405408
@Alerts("Hello-world")
406409
public void typeAtEndOfEditableDiv() throws Exception {
407-
final String html = "<html><head><script>\n"
410+
final String html = DOCTYPE_HTML
411+
+ "<html><head><script>\n"
408412
+ " function test() {\n"
409413
+ " alert(document.getElementById('myInput').value);\n"
410414
+ " }\n"
@@ -429,7 +433,8 @@ public void typeAtEndOfEditableDiv() throws Exception {
429433
@BuggyWebDriver(FF = "Hello\n-world",
430434
FF_ESR = "Hello\n-world")
431435
public void typeAtEndOfEditableDivWithParagraphInside() throws Exception {
432-
final String html = "<html><head><script>\n"
436+
final String html = DOCTYPE_HTML
437+
+ "<html><head><script>\n"
433438
+ " function test() {\n"
434439
+ " alert(document.getElementById('myInput').value);\n"
435440
+ " }\n"
@@ -453,7 +458,8 @@ public void typeAtEndOfEditableDivWithParagraphInside() throws Exception {
453458
@Test
454459
@Alerts({"bottom", "bottom", "bottom", "", "bottom", "bottom"})
455460
public void setGetStyle() throws Exception {
456-
final String html = "<html>\n"
461+
final String html = DOCTYPE_HTML
462+
+ "<html>\n"
457463
+ "<head>\n"
458464
+ "<script>\n"
459465
+ LOG_TITLE_FUNCTION

0 commit comments

Comments
 (0)