From: <rb...@us...> - 2013-05-05 12:21:42
|
Revision: 8261 http://sourceforge.net/p/htmlunit/code/8261 Author: rbri Date: 2013-05-05 12:21:38 +0000 (Sun, 05 May 2013) Log Message: ----------- test for reset of form input fields finally migrated into separate web driver based tests; again some issues found and fixed Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -15,8 +15,9 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCHANGE_LOSING_FOCUS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; import java.io.IOException; import java.util.Map; @@ -247,4 +248,15 @@ } valueAtFocus_ = isChecked(); } + + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if (hasFeature(HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE) && "value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -17,6 +17,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCHANGE_LOSING_FOCUS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; import java.io.IOException; import java.util.List; @@ -307,4 +308,15 @@ } valueAtFocus_ = isChecked(); } + + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if (hasFeature(HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE) && "value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -35,9 +35,11 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "initial-initial", "some text-some text", "some text-some text" }, - IE8 = { "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) - public void reset() throws Exception { + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -47,11 +49,17 @@ + " document.getElementById('testReset').click;\n" + " alert(button.value + '-' + button.defaultValue);\n" - + " button.value = 'some text';\n" + + " button.value = 'newValue';\n" + " alert(button.value + '-' + button.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.defaultValue = 'newDefault';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(button.value + '-' + button.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -68,8 +76,48 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.value = 'newValue';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.defaultValue = 'newDefault';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='button' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-newValue", "newDefault-newDefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newDefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -80,9 +128,9 @@ + " button.defaultValue = 'default';\n" + " alert(button.value + '-' + button.defaultValue);\n" - + " button.value = 'some text';\n" + + " button.value = 'newValue';\n" + " alert(button.value + '-' + button.defaultValue);\n" - + " button.defaultValue = 'newdefault';\n" + + " button.defaultValue = 'newDefault';\n" + " alert(button.value + '-' + button.defaultValue);\n" + " }\n" + "</script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -615,7 +615,7 @@ */ @Test @Alerts({ "on", "on", "on", "on" }) - public void defaultValue() throws Exception { + public void defaultDefaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -644,6 +644,113 @@ } /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByClick() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var checkbox = document.getElementById('testId');\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.value = 'newValue';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.defaultValue = 'newDefault';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='checkbox' id='testId' name='radar' value='initial'>\n" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var checkbox = document.getElementById('testId');\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.value = 'newValue';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.defaultValue = 'newDefault';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='checkbox' id='testId' name='radar' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "newValue-newValue", "newDefault-newDefault" }) + public void defaultValue() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var checkbox = document.getElementById('testId');\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.defaultValue = 'default';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + + " checkbox.value = 'newValue';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + " checkbox.defaultValue = 'newDefault';\n" + + " alert(checkbox.value + '-' + checkbox.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='checkbox' id='testId' name='radar' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** * Call to JS function click() should trigger the onchange handler but neither the onfocus handler * nor the mousedown/up handlers. * @throws Exception if the test fails Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -306,6 +306,71 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "initial-newDefault", "initial-newDefault" }) + public void resetByClick() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var file = document.getElementById('testId');\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " file.defaultValue = 'newDefault';\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='text' id='testId' value='initial'>\n" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "initial-newDefault", "initial-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var file = document.getElementById('testId');\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " file.defaultValue = 'newDefault';\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(file.value + '-' + file.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='text' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = { "-initial", "-default" }, IE8 = { "-", "-default" }) public void defaultValue() throws Exception { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -56,9 +56,11 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "initial-initial", "some text-some text", "some text-some text" }, - IE8 = { "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) - public void reset() throws Exception { + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -68,11 +70,17 @@ + " document.getElementById('testReset').click;\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" - + " hidden.value = 'some text';\n" + + " hidden.value = 'newValue';\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.defaultValue = 'newDefault';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -89,8 +97,48 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var hidden = document.getElementById('testId');\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.value = 'newValue';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.defaultValue = 'newDefault';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='hidden' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-newValue", "newDefault-newDefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newDefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -101,9 +149,9 @@ + " hidden.defaultValue = 'default';\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" - + " hidden.value = 'some text';\n" + + " hidden.value = 'newValue';\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" - + " hidden.defaultValue = 'newdefault';\n" + + " hidden.defaultValue = 'newDefault';\n" + " alert(hidden.value + '-' + hidden.defaultValue);\n" + " }\n" + "</script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -34,8 +34,9 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-some text", "some text-some text" }) - public void reset() throws Exception { + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -45,11 +46,17 @@ + " document.getElementById('testReset').click;\n" + " alert(image.value + '-' + image.defaultValue);\n" - + " image.value = 'some text';\n" + + " image.value = 'newValue';\n" + " alert(image.value + '-' + image.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.defaultValue = 'newDefault';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(image.value + '-' + image.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -66,7 +73,45 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var image = document.getElementById('testId');\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.value = 'newValue';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.defaultValue = 'newDefault';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='image' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "newValue-newValue", "newDefault-newDefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -77,9 +122,9 @@ + " image.defaultValue = 'default';\n" + " alert(image.value + '-' + image.defaultValue);\n" - + " image.value = 'some text';\n" + + " image.value = 'newValue';\n" + " alert(image.value + '-' + image.defaultValue);\n" - + " image.defaultValue = 'newdefault';\n" + + " image.defaultValue = 'newDefault';\n" + " alert(image.value + '-' + image.defaultValue);\n" + " }\n" + "</script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -168,8 +168,9 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) - public void reset() throws Exception { + @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -179,11 +180,17 @@ + " document.getElementById('testReset').click;\n" + " alert(password.value + '-' + password.defaultValue);\n" - + " password.value = 'some text';\n" + + " password.value = 'newValue';\n" + " alert(password.value + '-' + password.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.defaultValue = 'newDefault';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(password.value + '-' + password.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -200,8 +207,46 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-default", "some text-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var password = document.getElementById('testId');\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.value = 'newValue';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.defaultValue = 'newDefault';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='password' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-default", "newValue-newdefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newdefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -212,7 +257,7 @@ + " password.defaultValue = 'default';\n" + " alert(password.value + '-' + password.defaultValue);\n" - + " password.value = 'some text';\n" + + " password.value = 'newValue';\n" + " alert(password.value + '-' + password.defaultValue);\n" + " password.defaultValue = 'newdefault';\n" + " alert(password.value + '-' + password.defaultValue);\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -714,7 +714,7 @@ */ @Test @Alerts({ "on", "on", "on", "on" }) - public void defaultValue() throws Exception { + public void defaultDefaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -743,6 +743,113 @@ } /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByClick() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var radio = document.getElementById('testId');\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.value = 'newValue';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.defaultValue = 'newDefault';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='radio' id='testId' name='radar' value='initial'>\n" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var radio = document.getElementById('testId');\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.value = 'newValue';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.defaultValue = 'newDefault';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='radio' id='testId' name='radar' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "newValue-newValue", "newDefault-newDefault" }) + public void defaultValue() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var radio = document.getElementById('testId');\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.defaultValue = 'default';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + + " radio.value = 'newValue';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + " radio.defaultValue = 'newDefault';\n" + + " alert(radio.value + '-' + radio.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='radio' id='testId' name='radar' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** * Call to JS function click() should trigger the onchange handler but neither the onfocus handler * nor the mousedown/up handlers. * @throws Exception if the test fails Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -34,8 +34,89 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var reset = document.getElementById('testId');\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.value = 'newValue';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.defaultValue = 'newDefault';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='reset' id='testId' value='initial'>\n" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var reset = document.getElementById('testId');\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.value = 'newValue';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.defaultValue = 'newDefault';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='reset' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-newValue", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newdefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -46,7 +127,7 @@ + " reset.defaultValue = 'default';\n" + " alert(reset.value + '-' + reset.defaultValue);\n" - + " reset.value = 'some text';\n" + + " reset.value = 'newValue';\n" + " alert(reset.value + '-' + reset.defaultValue);\n" + " reset.defaultValue = 'newdefault';\n" + " alert(reset.value + '-' + reset.defaultValue);\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -196,9 +196,11 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "initial-initial", "some text-some text", "some text-some text" }, - IE8 = { "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) - public void reset() throws Exception { + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -208,11 +210,17 @@ + " document.getElementById('testReset').click;\n" + " alert(submit.value + '-' + submit.defaultValue);\n" - + " submit.value = 'some text';\n" + + " submit.value = 'newValue';\n" + " alert(submit.value + '-' + submit.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.defaultValue = 'newDefault';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -229,8 +237,48 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "initial-initial", "newValue-newValue", "newValue-newValue", + "newDefault-newDefault", "newDefault-newDefault" }, + IE = { "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var submit = document.getElementById('testId');\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.value = 'newValue';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.defaultValue = 'newDefault';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='submit' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-newValue", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newdefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -241,7 +289,7 @@ + " submit.defaultValue = 'default';\n" + " alert(submit.value + '-' + submit.defaultValue);\n" - + " submit.value = 'some text';\n" + + " submit.value = 'newValue';\n" + " alert(submit.value + '-' + submit.defaultValue);\n" + " submit.defaultValue = 'newdefault';\n" + " alert(submit.value + '-' + submit.defaultValue);\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -34,6 +34,81 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "newValue-", "newValue-", "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var text = document.getElementById('testId');\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.value = 'newValue';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'newDefault';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <textarea id='testId' value='initial'></textarea>\n" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "newValue-", "newValue-", "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var text = document.getElementById('testId');\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.value = 'newValue';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'newDefault';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <textarea id='testId' value='initial'></textarea>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = { "-", "default-default", "some text-default", "some text-newdefault" }, IE = { "-", "-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -34,8 +34,9 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) - public void reset() throws Exception { + @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" @@ -45,11 +46,17 @@ + " document.getElementById('testReset').click;\n" + " alert(text.value + '-' + text.defaultValue);\n" - + " text.value = 'some text';\n" + + " text.value = 'newValue';\n" + " alert(text.value + '-' + text.defaultValue);\n" + " document.getElementById('testReset').click;\n" + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'newDefault';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" @@ -66,8 +73,46 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-default", "some text-newdefault" }, - IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) + @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", + "newValue-newDefault", "newValue-newDefault" }) + public void resetByJS() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var text = document.getElementById('testId');\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.value = 'newValue';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'newDefault';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.forms[0].reset;\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='text' id='testId' value='initial'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-initial", "default-default", "newValue-default", "newValue-newDefault" }, + IE8 = { "initial-initial", "initial-default", "newValue-default", "newValue-newDefault" }) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -78,9 +123,9 @@ + " text.defaultValue = 'default';\n" + " alert(text.value + '-' + text.defaultValue);\n" - + " text.value = 'some text';\n" + + " text.value = 'newValue';\n" + " alert(text.value + '-' + text.defaultValue);\n" - + " text.defaultValue = 'newdefault';\n" + + " text.defaultValue = 'newDefault';\n" + " alert(text.value + '-' + text.defaultValue);\n" + " }\n" + "</script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java 2013-05-04 18:01:04 UTC (rev 8260) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java 2013-05-05 12:21:38 UTC (rev 8261) @@ -255,187 +255,9 @@ } /** - * Tests form reset and input default values while emulating IE. * @throws Exception if the test fails */ @Test - public void formReset() throws Exception { - // As tested with IE 6.0 on Win2k; note that refreshing the page will get you different results; - // you need to open a new browser instance each time you test this. - final String[] expectedIE = { - "before setting default values", /* Before setting default values. */ - "text: initial1 initial1 false false", - "file: initial2 false false", - "image: initial3 initial3 false false", - "radio: initial4 initial4 true true", - "reset: initial5 initial5 false false", - "hidden: initial6 initial6 false false", - "button: initial7 initial7 false false", - "submit: initial8 initial8 false false", - "password: initial9 initial9 false false", - "checkbox: initial10 initial10 true true", - "textarea: initial11 initial11 undefined undefined", - "after setting default values", /* After setting default values. */ - "text: default1 default1 false false", - "file: default2 false false", - "image: default3 default3 false false", - "radio: default4 default4 false false", - "reset: default5 default5 false false", - "hidden: default6 default6 false false", - "button: default7 default7 false false", - "submit: default8 default8 false false", - "password: default9 default9 false false", - "checkbox: default10 default10 false false", - "textarea: initial11 default11 undefined undefined", - "after resetting the form", /* After resetting the form. */ - "text: default1 default1 false false", - "file: default2 false false", - "image: default3 default3 false false", - "radio: default4 default4 false false", - "reset: default5 default5 false false", - "hidden: default6 default6 false false", - "button: default7 default7 false false", - "submit: default8 default8 false false", - "password: default9 default9 false false", - "checkbox: default10 default10 false false", - "textarea: default11 default11 undefined undefined" }; - - // As tested with Firefox 2.0.20 and 3.0.13 on Linux. - final String[] expectedFF = { - "before setting default values", /* Before setting default values. */ - "text: initial1 initial1 false false", - "file: initial2 false false", // THIS LINE DIFFERS FROM IE; see HtmlFileInput constructor. - "image: initial3 initial3 false false", - "radio: initial4 initial4 true true", - "reset: initial5 initial5 false false", - "hidden: initial6 initial6 false false", - "button: initial7 initial7 false false", - "submit: initial8 initial8 false false", - "password: initial9 initial9 false false", - "checkbox: initial10 initial10 true true", - "textarea: initial11 initial11 undefined undefined", - "after setting default values", /* After setting default values. */ - "text: default1 default1 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "file: default2 false false", - "image: default3 default3 false false", - "radio: default4 default4 false false", // DIFFERS FROM IE; see HtmlRadioButtonInput.setDefaultChecked() - "reset: default5 default5 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "hidden: default6 default6 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "button: default7 default7 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "submit: default8 default8 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "password: default9 default9 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "checkbox: default10 default10 false false", // DIFFERS FROM IE; see HtmlCheckBoxInput.setDefaultChecked() - "textarea: default11 default11 undefined undefined", - "after resetting the form", /* After resetting the form. */ - "text: default1 default1 false false", - "file: default2 false false", - "image: default3 default3 false false", - "radio: default4 default4 false false", - "reset: default5 default5 false false", // DIFFERS FROM IE; see HtmlInput.setDefaultValue() - "hidden: default6 default6 false false", - "button: default7 default7 false false"... [truncated message content] |