From: <rb...@us...> - 2013-05-01 16:13:38
|
Revision: 8253 http://sourceforge.net/p/htmlunit/code/8253 Author: rbri Date: 2013-05-01 16:13:34 +0000 (Wed, 01 May 2013) Log Message: ----------- The value of input controls changes when the defaultValue was changed in IE8ff (only exception is text area) Some more tests. Fix a browser feature name and introduce a new one for text area Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-01 16:13:34 UTC (rev 8253) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + The value of input controls changes when the defaultValue was changed in IE8ff. + </action> + <action type="fix" dev="rbri"> The default value of input-file is no longer empty in IE8ff. </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -598,10 +598,6 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLIMAGE_NAME_VALUE_PARAMS, - /** */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) - HTMLINPUT_DEFAULT_IS_CHECKED, - /** Set this checked state back to default when added to page (IE6). */ @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) HTMLINPUT_SET_CHECKED_TO_DEFAULT_WHEN_ADDED, @@ -610,6 +606,14 @@ @BrowserFeature(@WebBrowser(value = IE)) HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE, + /** Setting defaultCheced updates checked also. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 8), @WebBrowser(CHROME) }) + HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED, + + /** Setting defaultValue updates the value also. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 8), @WebBrowser(CHROME) }) + HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE, + /** * Set this property if the browser does NOT * support the disabling of an individual option group. @@ -648,6 +652,10 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLSCRIPT_TRIM_TYPE, + /** Setting defaultValue updates the value also. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) + HTMLTEXTAREA_SET_DEFAULT_VALUE_UPDATES_VALUE, + /** Do not allow anything in color, but restrict to valid values only. */ @BrowserFeature({ @WebBrowser(IE), @WebBrowser(value = FF, maxVersion = 3.6f) }) HTML_COLOR_RESTRICT, 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-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCHANGE_LOSING_FOCUS; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_DEFAULT_IS_CHECKED; +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 java.io.IOException; @@ -168,7 +168,7 @@ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; - if (hasFeature(HTMLINPUT_DEFAULT_IS_CHECKED)) { + if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { setChecked(defaultChecked); } if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java 2013-05-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -14,7 +14,7 @@ */ package com.gargoylesoftware.htmlunit.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_DEFAULT_IS_CHECKED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE; import java.io.IOException; import java.util.Collection; @@ -358,7 +358,7 @@ * @see HtmlFileInput#setDefaultValue(String) */ public void setDefaultValue(final String defaultValue) { - final boolean modifyValue = hasFeature(HTMLINPUT_DEFAULT_IS_CHECKED); + final boolean modifyValue = hasFeature(HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE); setDefaultValue(defaultValue, modifyValue); } 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-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCHANGE_LOSING_FOCUS; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_DEFAULT_IS_CHECKED; +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 java.io.IOException; @@ -221,7 +221,7 @@ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; - if (hasFeature(HTMLINPUT_DEFAULT_IS_CHECKED)) { + if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { setChecked(isDefaultChecked()); } if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java 2013-05-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -14,7 +14,7 @@ */ package com.gargoylesoftware.htmlunit.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_DEFAULT_IS_CHECKED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLTEXTAREA_SET_DEFAULT_VALUE_UPDATES_VALUE; import java.io.PrintWriter; import java.util.Collection; @@ -178,7 +178,7 @@ } // for FF, if value is still default value, change value too - if (hasFeature(HTMLINPUT_DEFAULT_IS_CHECKED) + if (hasFeature(HTMLTEXTAREA_SET_DEFAULT_VALUE_UPDATES_VALUE) && getText().equals(getDefaultValue())) { setTextInternal(defaultValue); } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HtmlTextInput}. + * + * @version $Revision$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HtmlTextArea2Test extends WebDriverTestCase { + + /** + * @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 { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var text = document.getElementById('testId');\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'default';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.value = 'some text';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + " text.defaultValue = 'newdefault';\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); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HtmlTextInput}. + * + * @version $Revision$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HtmlTextInput2Test extends WebDriverTestCase { + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var text = document.getElementById('testId');\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.defaultValue = 'default';\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); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property 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-01 14:08:36 UTC (rev 8252) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java 2013-05-01 16:13:34 UTC (rev 8253) @@ -265,7 +265,7 @@ final String[] expectedIE = { "before setting default values", /* Before setting default values. */ "text: initial1 initial1 false false", - "file: false false", + "file: initial2 false false", "image: initial3 initial3 false false", "radio: initial4 initial4 true true", "reset: initial5 initial5 false false", @@ -276,26 +276,26 @@ "checkbox: initial10 initial10 true true", "textarea: initial11 initial11 undefined undefined", "after setting default values", /* After setting default values. */ - "text: initial1 default1 false false", + "text: default1 default1 false false", "file: default2 false false", "image: default3 default3 false false", - "radio: default4 default4 true false", - "reset: initial5 default5 false false", - "hidden: initial6 default6 false false", - "button: initial7 default7 false false", - "submit: initial8 default8 false false", - "password: initial9 default9 false false", - "checkbox: default10 default10 true 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: initial5 default5 false false", + "reset: default5 default5 false false", "hidden: default6 default6 false false", - "button: initial7 default7 false false", - "submit: initial8 default8 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" }; @@ -342,7 +342,7 @@ final String[] expectedAlerts = getBrowserVersion().isFirefox() ? expectedFF : expectedIE; setExpectedAlerts(expectedAlerts); - final String html = "<html>\n" + final String html = "<!DOCTYPE HTML>\n<html>\n" + " <head>\n" + " <title>Reset Test</title>\n" + " <script>\n" |
From: <rb...@us...> - 2013-05-02 17:06:00
|
Revision: 8254 http://sourceforge.net/p/htmlunit/code/8254 Author: rbri Date: 2013-05-02 17:05:55 +0000 (Thu, 02 May 2013) Log Message: ----------- fixes for defaultValue processing for the various input controls together with more tests Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -26,6 +26,7 @@ * @author <a href="mailto:cs...@dy...">Christian Sell</a> * @author Daniel Gredler * @author Ahmed Ashour + * @author Ronald Brill */ public class HtmlButtonInput extends HtmlInput { @@ -51,5 +52,14 @@ // Empty. } + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if ("value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } - Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -46,6 +46,17 @@ } /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if ("value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } + + /** * @see com.gargoylesoftware.htmlunit.html.HtmlInput#asText() * @return an empty string as an hidden field is not visible */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -144,4 +144,15 @@ super.setDefaultValue(defaultValue); setValueAttribute(defaultValue); } + + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if ("value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -353,7 +353,8 @@ } /** - * {@inheritDoc} Also sets the value attribute when emulating Netscape browsers. + * {@inheritDoc} + * Also sets the value attribute when emulating Netscape browsers. * @see SubmittableElement#setDefaultValue(String) * @see HtmlFileInput#setDefaultValue(String) */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -16,6 +16,8 @@ import java.util.Map; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE; + import com.gargoylesoftware.htmlunit.SgmlPage; import com.gargoylesoftware.htmlunit.html.impl.SelectableTextInput; import com.gargoylesoftware.htmlunit.html.impl.SelectionDelegate; @@ -29,6 +31,7 @@ * @author <a href="mailto:cs...@dy...">Christian Sell</a> * @author Daniel Gredler * @author Ahmed Ashour + * @author Ronald Brill */ public class HtmlPasswordInput extends HtmlInput implements SelectableTextInput { @@ -174,4 +177,13 @@ setSelectionEnd(attributeValue.length()); } } + + /** + * {@inheritDoc} + */ + public void setDefaultValue(final String defaultValue) { + boolean modifyValue = hasFeature(HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE); + modifyValue = modifyValue && getValueAttribute().equals(getDefaultValue()); + setDefaultValue(defaultValue, modifyValue); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -28,6 +28,7 @@ * @author <a href="mailto:cs...@dy...">Christian Sell</a> * @author Daniel Gredler * @author Ahmed Ashour + * @author Ronald Brill */ public class HtmlResetInput extends HtmlInput { @@ -67,4 +68,14 @@ // Empty. } + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if ("value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -149,4 +149,15 @@ } return super.getSubmitKeyValuePairs(); } + + /** + * {@inheritDoc} + */ + @Override + public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { + if ("value".equals(qualifiedName)) { + setDefaultValue(attributeValue, false); + } + super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE; + import java.util.Map; import com.gargoylesoftware.htmlunit.SgmlPage; @@ -30,6 +32,7 @@ * @author Daniel Gredler * @author Ahmed Ashour * @author Marc Guillemot + * @author Ronald Brill */ public class HtmlTextInput extends HtmlInput implements SelectableTextInput { @@ -176,4 +179,13 @@ protected Object clone() throws CloneNotSupportedException { return new HtmlTextInput(getNamespaceURI(), getQualifiedName(), getPage(), getAttributesMap()); } + + /** + * {@inheritDoc} + */ + public void setDefaultValue(final String defaultValue) { + boolean modifyValue = hasFeature(HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE); + modifyValue = modifyValue && getValueAttribute().equals(getDefaultValue()); + setDefaultValue(defaultValue, modifyValue); + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HtmlButtonInput}. + * + * @version $Revision$ + * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HtmlButtonInput2Test extends WebDriverTestCase { + + /** + * @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 { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.value = 'some text';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.defaultValue = 'default';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + + " button.value = 'some text';\n" + + " alert(button.value + '-' + button.defaultValue);\n" + + " button.defaultValue = 'newdefault';\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); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonTest.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonTest.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -48,7 +48,7 @@ * @throws Exception if the test fails */ @Test - public void testButtonClick_onClick() throws Exception { + public void buttonClick_onClick() throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" @@ -72,7 +72,7 @@ * @throws Exception if the test fails */ @Test - public void testSubmitClick_onClick() throws Exception { + public void submitClick_onClick() throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" @@ -95,95 +95,9 @@ * @throws Exception if the test fails */ @Test - public void testResetClick_onClick() throws Exception { + public void buttonTypeSubmit() throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>\n" - + "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" - + " <button type='reset' name='button' id='button' " - + "onClick='alert(\"foo\")'>Push me</button>\n" - + "</form></body></html>"; - final List<String> collectedAlerts = new ArrayList<String>(); - final HtmlPage page = loadPage(htmlContent, collectedAlerts); - final HtmlButton button = page.getHtmlElementById("button"); - - final HtmlPage secondPage = button.click(); - - final String[] expectedAlerts = {"foo", "reset"}; - assertEquals(expectedAlerts, collectedAlerts); - - assertSame(page, secondPage); - } - - /** - * @throws Exception if the test fails - */ - @Test - public void testReset() throws Exception { - final String htmlContent - = "<html><head><title>foo</title></head><body>\n" - + "<form id='form1'>\n" - + "<input type='text' name='textfield1' id='textfield1' value='foo'/>\n" - + "<input type='password' name='password1' id='password1' value='foo'/>\n" - + "<input type='hidden' name='hidden1' id='hidden1' value='foo'/>\n" - + "<input type='radio' name='radioButton' value='foo' checked/>\n" - + "<input type='radio' name='radioButton' value='bar'/>\n" - + "<input type='checkbox' name='checkBox' value='check'/>\n" - + "<select id='select1'>\n" - + " <option id='option1' selected value='1'>Option1</option>\n" - + " <option id='option2' value='2'>Option2</option>\n" - + "</select>\n" - + "<textarea id='textarea1'>Foobar</textarea>\n" - + "<isindex prompt='Enter some text' id='isindex1'>\n" - + "<button type='reset' id='resetButton' value='pushme'/>\n" - + "</form></body></html>"; - final HtmlPage page = loadPage(htmlContent); - final HtmlForm form = page.getHtmlElementById("form1"); - final HtmlButton resetInput = page.getHtmlElementById("resetButton"); - - // change all the values to something else - form.<HtmlRadioButtonInput>getFirstByXPath( - "//input[@type='radio' and @name='radioButton' and @value='bar']").setChecked(true); - ((HtmlCheckBoxInput) form.getInputByName("checkBox")).setChecked(true); - page.<HtmlOption>getHtmlElementById("option1").setSelected(false); - page.<HtmlOption>getHtmlElementById("option2").setSelected(true); - page.<HtmlTextArea>getHtmlElementById("textarea1").setText("Flintstone"); - page.<HtmlTextInput>getHtmlElementById("textfield1").setValueAttribute("Flintstone"); - page.<HtmlHiddenInput>getHtmlElementById("hidden1").setValueAttribute("Flintstone"); - page.<HtmlPasswordInput>getHtmlElementById("password1").setValueAttribute("Flintstone"); - page.<HtmlIsIndex>getHtmlElementById("isindex1").setValue("Flintstone"); - - // Check to make sure they did get changed - assertEquals("bar", form.getCheckedRadioButton("radioButton").getValueAttribute()); - assertTrue(form.<HtmlCheckBoxInput>getInputByName("checkBox").isChecked()); - assertFalse(page.<HtmlOption>getHtmlElementById("option1").isSelected()); - assertTrue(page.<HtmlOption>getHtmlElementById("option2").isSelected()); - assertEquals("Flintstone", page.<HtmlTextArea>getHtmlElementById("textarea1").getText()); - assertEquals("Flintstone", page.<HtmlTextInput>getHtmlElementById("textfield1").getValueAttribute()); - assertEquals("Flintstone", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); - assertEquals("Flintstone", page.<HtmlIsIndex>getHtmlElementById("isindex1").getValue()); - - final HtmlPage secondPage = (HtmlPage) resetInput.click(); - assertSame(page, secondPage); - - // Check to make sure all the values have been set back to their original values. - assertEquals("foo", form.getCheckedRadioButton("radioButton").getValueAttribute()); - assertFalse(form.<HtmlCheckBoxInput>getInputByName("checkBox").isChecked()); - assertTrue(page.<HtmlOption>getHtmlElementById("option1").isSelected()); - assertFalse(page.<HtmlOption>getHtmlElementById("option2").isSelected()); - assertEquals("Foobar", page.<HtmlTextArea>getHtmlElementById("textarea1").getText()); - assertEquals("foo", page.<HtmlTextInput>getHtmlElementById("textfield1").getValueAttribute()); - assertEquals("foo", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); - assertEquals("foo", page.<HtmlPasswordInput>getHtmlElementById("password1").getValueAttribute()); - assertEquals("", page.<HtmlIsIndex>getHtmlElementById("isindex1").getValue()); - } - - /** - * @throws Exception if the test fails - */ - @Test - public void testButtonTypeSubmit() throws Exception { - final String htmlContent - = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' method='post' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" + " <button type='submit' name='button' id='button' value='foo'" + " >Push me</button>\n" @@ -212,7 +126,7 @@ * @throws Exception if the test fails */ @Test - public void testDefaultButtonType_StandardsCompliantBrowser() throws Exception { + public void defaultButtonType_StandardsCompliantBrowser() throws Exception { final String expectedType = getBrowserVersion().isFirefox() ? "submit" : "button"; final String firstContent = "<html><head><title>First</title></head><body>\n" 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-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -22,6 +22,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; /** * Tests for {@link HtmlHiddenInput}. @@ -51,4 +52,65 @@ assertEquals("", input.getText()); } + /** + * @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 { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var hidden = document.getElementById('testId');\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.value = 'some text';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var hidden = document.getElementById('testId');\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.defaultValue = 'default';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + + " hidden.value = 'some text';\n" + + " alert(hidden.value + '-' + hidden.defaultValue);\n" + + " hidden.defaultValue = 'newdefault';\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); + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HtmlImageInput}. + * + * @version $Revision$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HtmlImageInput2Test extends WebDriverTestCase { + + /** + * @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 { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var image = document.getElementById('testId');\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.value = 'some text';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var image = document.getElementById('testId');\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.defaultValue = 'default';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + + " image.value = 'some text';\n" + + " alert(image.value + '-' + image.defaultValue);\n" + + " image.defaultValue = 'newdefault';\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); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property 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-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -26,6 +26,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; /** * Tests for {@link HtmlPasswordInput}. @@ -162,4 +163,66 @@ final String[] expectedAlerts2 = {"foo", "change", "boo", "blur", "boo", "blur"}; assertEquals(expectedAlerts2, getCollectedAlerts(driver)); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) + public void reset() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var password = document.getElementById('testId');\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.value = 'some text';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-default", "some text-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var password = document.getElementById('testId');\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.defaultValue = 'default';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + + " password.value = 'some text';\n" + + " alert(password.value + '-' + password.defaultValue);\n" + + " password.defaultValue = 'newdefault';\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); + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HtmlResetInput}. + * + * @version $Revision$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HtmlResetInput2Test extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var reset = document.getElementById('testId');\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.defaultValue = 'default';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + + " reset.value = 'some text';\n" + + " alert(reset.value + '-' + reset.defaultValue);\n" + + " reset.defaultValue = 'newdefault';\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); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java 2013-05-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -41,7 +41,8 @@ @Test public void reset() throws Exception { final String htmlContent - = "<html><head><title>foo</title></head><body>\n" + = "<!DOCTYPE HTML>\n" + + "<html><head><title>foo</title></head><body>\n" + "<form id='form1'>\n" + "<input type='text' name='textfield1' id='textfield1' value='foo'/>\n" + "<input type='password' name='password1' id='password1' value='foo'/>\n" @@ -94,7 +95,11 @@ assertFalse(page.<HtmlOption>getHtmlElementById("option2").isSelected()); assertEquals("Foobar", page.<HtmlTextArea>getHtmlElementById("textarea1").getText()); assertEquals("foo", page.<HtmlTextInput>getHtmlElementById("textfield1").getValueAttribute()); - assertEquals("foo", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); + + // this is strange but this is the way the browsers are working + // com.gargoylesoftware.htmlunit.html.HtmlHiddenInputTest.reset() + assertEquals("Flintstone", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); + assertEquals("foo", page.<HtmlPasswordInput>getHtmlElementById("password1").getValueAttribute()); assertEquals("", page.<HtmlIsIndex>getHtmlElementById("isindex1").getValue()); } @@ -103,6 +108,30 @@ * @throws Exception if the test fails */ @Test + public void resetClick_onClick() throws Exception { + final String htmlContent + = "<!DOCTYPE HTML>\n" + + "<html><head><title>foo</title></head><body>\n" + + "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" + + " <button type='reset' name='button' id='button' " + + "onClick='alert(\"foo\")'>Push me</button>\n" + + "</form></body></html>"; + final List<String> collectedAlerts = new ArrayList<String>(); + final HtmlPage page = loadPage(htmlContent, collectedAlerts); + final HtmlButton button = page.getHtmlElementById("button"); + + final HtmlPage secondPage = button.click(); + + final String[] expectedAlerts = {"foo", "reset"}; + assertEquals(expectedAlerts, collectedAlerts); + + assertSame(page, secondPage); + } + + /** + * @throws Exception if the test fails + */ + @Test public void outsideForm() throws Exception { final String html = "<html><head></head>\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-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -38,6 +38,7 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class HtmlSubmitInputTest extends WebDriverTestCase { @@ -46,7 +47,7 @@ * @throws Exception if the test fails */ @Test - public void testSubmit() throws Exception { + public void submit() throws Exception { final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' method='post'>\n" @@ -71,7 +72,7 @@ */ @Test @Alerts({ "foo", "bar" }) - public void testClick_onClick() throws Exception { + public void click_onClick() throws Exception { final String html = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' onSubmit='alert(\"bar\"); return false;'>\n" @@ -90,7 +91,7 @@ * @throws Exception if the test fails */ @Test - public void testClick_onClick_JavascriptReturnsTrue() throws Exception { + public void click_onClick_JavascriptReturnsTrue() throws Exception { final String html = "<html><head><title>First</title></head><body>\n" + "<form name='form1' method='get' action='foo.html'>\n" @@ -114,7 +115,7 @@ */ @Test @Alerts("1") - public void testOutsideForm() throws Exception { + public void outsideForm() throws Exception { final String html = "<html><head></head>\n" + "<body>\n" @@ -190,4 +191,66 @@ assertEquals("next page", wd.getTitle()); assertEquals(3, mockWebConnection.getRequestCount()); } + + /** + * @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 { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var submit = document.getElementById('testId');\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.getElementById('testReset').click;\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.value = 'some text';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + public void defaultValue() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var submit = document.getElementById('testId');\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.defaultValue = 'default';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + + " submit.value = 'some text';\n" + + " alert(submit.value + '-' + submit.defaultValue);\n" + + " submit.defaultValue = 'newdefault';\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); + } } 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-01 16:13:34 UTC (rev 8253) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-02 17:05:55 UTC (rev 8254) @@ -29,11 +29,44 @@ */ @RunWith(BrowserRunner.class) public class HtmlTextInput2Test extends WebDriverTestCase { + /** * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default" }) + @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) + public void reset() throws Exception { + final String html = "<!DOCTYPE HTML>\n<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 = 'some text';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + + " document.getElementById('testReset').click;\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" + + " <input type='reset' id='testReset'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "initial-initial", "default-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" @@ -43,6 +76,11 @@ + " text.defaultValue = 'default';\n" + " alert(text.value + '-' + text.defaultValue);\n" + + + " text.value = 'some text';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + + " text.defaultValue = 'newdefault';\n" + + " alert(text.value + '-' + text.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" |
From: <rb...@us...> - 2013-05-02 18:33:22
|
Revision: 8255 http://sourceforge.net/p/htmlunit/code/8255 Author: rbri Date: 2013-05-02 18:33:18 +0000 (Thu, 02 May 2013) Log Message: ----------- Calling clone does not copy all event listeners in IE8ff. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-02 17:05:55 UTC (rev 8254) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-02 18:33:18 UTC (rev 8255) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + Calling clone does not copy all event listeners in IE8ff. + </action> + <action type="fix" dev="rbri"> The value of input controls changes when the defaultValue was changed in IE8ff. </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-02 17:05:55 UTC (rev 8254) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-02 18:33:18 UTC (rev 8255) @@ -759,10 +759,10 @@ JS_CLIENT_LEFT_TOP_ZERO, /** Indicates that the cloneNode call copies all event listeners. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) JS_CLONE_NODE_COPIES_EVENT_LISTENERS, - /** Indicates that "constructor" propery is defined, e.g. <tt>document.constructor</tt>. */ + /** Indicates that "constructor" property is defined, e.g. <tt>document.constructor</tt>. */ @BrowserFeature(@WebBrowser(FF)) JS_CONSTRUCTOR, Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java 2013-05-02 17:05:55 UTC (rev 8254) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java 2013-05-02 18:33:18 UTC (rev 8255) @@ -552,10 +552,12 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF = "in click", IE = { "in click", "in click", "in click" }) + @Alerts(DEFAULT = "in click", + IE6 = { "in click", "in click", "in click" }, + IE7 = { "in click", "in click", "in click" }) public void testCloneNode_copiesListenerOnlyForIE() throws Exception { final String html = - "<html>\n" + "<!DOCTYPE HTML>\n<html>\n" + " <head>\n" + " <script type='text/javascript'>\n" + " function go() {\n" |
From: <rb...@us...> - 2013-05-03 07:09:46
|
Revision: 8256 http://sourceforge.net/p/htmlunit/code/8256 Author: rbri Date: 2013-05-03 07:09:37 +0000 (Fri, 03 May 2013) Log Message: ----------- rechecked default handling with IE8; test adjusted and impl fixed Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.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/HtmlResetInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -216,7 +216,7 @@ EXECCOMMAND_THROWS_ON_WRONG_COMMAND, /** */ - @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 8)) FILEINPUT_EMPTY_DEFAULT_VALUE, /** For new pages the focus points to the html root node. */ @@ -611,9 +611,13 @@ HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED, /** Setting defaultValue updates the value also. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 8), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 9), @WebBrowser(CHROME) }) HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE, + /** Setting value updates the defaultValue also. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 9), @WebBrowser(CHROME) }) + HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE, + /** * Set this property if the browser does NOT * support the disabling of an individual option group. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; + import java.util.Map; import com.gargoylesoftware.htmlunit.SgmlPage; @@ -57,7 +59,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if ("value".equals(qualifiedName)) { + 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/HtmlHiddenInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; + import java.util.Map; import com.gargoylesoftware.htmlunit.SgmlPage; @@ -50,7 +52,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if ("value".equals(qualifiedName)) { + 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/HtmlResetInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; + import java.io.IOException; import java.util.Map; @@ -73,7 +75,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if ("value".equals(qualifiedName)) { + 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/HtmlSubmitInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.SUBMITINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED; import java.io.IOException; @@ -155,7 +156,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if ("value".equals(qualifiedName)) { + 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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -35,9 +35,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-some text", "some text-some text" }) + @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 { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -67,9 +68,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" 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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -40,8 +40,8 @@ import org.openqa.selenium.ie.InternetExplorerDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.WebDriverTestCase; -import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; /** * Tests for {@link HtmlFileInput}. @@ -306,7 +306,8 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-initial", "-default" }) + @Alerts(DEFAULT = { "-initial", "-default" }, + IE8 = { "-", "-default" }) public void defaultValue() throws Exception { final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" 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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -56,9 +56,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-some text", "some text-some text" }) + @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 { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var hidden = document.getElementById('testId');\n" @@ -88,9 +89,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var hidden = document.getElementById('testId');\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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -36,7 +36,7 @@ @Test @Alerts({ "initial-initial", "initial-initial", "some text-some text", "some text-some text" }) public void reset() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var image = document.getElementById('testId');\n" @@ -68,7 +68,7 @@ @Test @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var image = document.getElementById('testId');\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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -170,7 +170,7 @@ @Test @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) public void reset() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var password = document.getElementById('testId');\n" @@ -200,9 +200,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-default", "some text-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var password = document.getElementById('testId');\n" 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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -34,9 +34,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var reset = document.getElementById('testId');\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java 2013-05-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInputTest.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -41,8 +41,7 @@ @Test public void reset() throws Exception { final String htmlContent - = "<!DOCTYPE HTML>\n" - + "<html><head><title>foo</title></head><body>\n" + = "<html><head><title>foo</title></head><body>\n" + "<form id='form1'>\n" + "<input type='text' name='textfield1' id='textfield1' value='foo'/>\n" + "<input type='password' name='password1' id='password1' value='foo'/>\n" @@ -98,7 +97,12 @@ // this is strange but this is the way the browsers are working // com.gargoylesoftware.htmlunit.html.HtmlHiddenInputTest.reset() - assertEquals("Flintstone", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); + if (getBrowserVersion().isIE() && getBrowserVersion().getBrowserVersionNumeric() < 9) { + assertEquals("foo", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); + } + else { + assertEquals("Flintstone", page.<HtmlHiddenInput>getHtmlElementById("hidden1").getValueAttribute()); + } assertEquals("foo", page.<HtmlPasswordInput>getHtmlElementById("password1").getValueAttribute()); assertEquals("", page.<HtmlIsIndex>getHtmlElementById("isindex1").getValue()); @@ -110,8 +114,7 @@ @Test public void resetClick_onClick() throws Exception { final String htmlContent - = "<!DOCTYPE HTML>\n" - + "<html><head><title>foo</title></head><body>\n" + = "<html><head><title>foo</title></head><body>\n" + "<form id='form1' onSubmit='alert(\"bar\")' onReset='alert(\"reset\")'>\n" + " <button type='reset' name='button' id='button' " + "onClick='alert(\"foo\")'>Push me</button>\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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -196,9 +196,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "initial-initial", "some text-some text", "some text-some text" }) + @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 { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var submit = document.getElementById('testId');\n" @@ -228,9 +229,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-some text", "newdefault-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var submit = document.getElementById('testId');\n" 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-02 18:33:18 UTC (rev 8255) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-03 07:09:37 UTC (rev 8256) @@ -36,7 +36,7 @@ @Test @Alerts({ "initial-initial", "initial-initial", "some text-initial", "some text-initial" }) public void reset() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var text = document.getElementById('testId');\n" @@ -66,9 +66,10 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "initial-initial", "default-default", "some text-default", "some text-newdefault" }) + @Alerts(DEFAULT = { "initial-initial", "default-default", "some text-default", "some text-newdefault" }, + IE8 = { "initial-initial", "initial-default", "some text-default", "some text-newdefault" }) public void defaultValue() throws Exception { - final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var text = document.getElementById('testId');\n" |
From: <rb...@us...> - 2013-05-03 07:18:24
|
Revision: 8257 http://sourceforge.net/p/htmlunit/code/8257 Author: rbri Date: 2013-05-03 07:18:17 +0000 (Fri, 03 May 2013) Log Message: ----------- revert last change because validation with real IE8 shows that the assumption was wrong Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-03 07:09:37 UTC (rev 8256) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-03 07:18:17 UTC (rev 8257) @@ -9,9 +9,6 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> - Calling clone does not copy all event listeners in IE8ff. - </action> - <action type="fix" dev="rbri"> The value of input controls changes when the defaultValue was changed in IE8ff. </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-03 07:09:37 UTC (rev 8256) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-03 07:18:17 UTC (rev 8257) @@ -763,7 +763,7 @@ JS_CLIENT_LEFT_TOP_ZERO, /** Indicates that the cloneNode call copies all event listeners. */ - @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) + @BrowserFeature(@WebBrowser(IE)) JS_CLONE_NODE_COPIES_EVENT_LISTENERS, /** Indicates that "constructor" property is defined, e.g. <tt>document.constructor</tt>. */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java 2013-05-03 07:09:37 UTC (rev 8256) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeTest.java 2013-05-03 07:18:17 UTC (rev 8257) @@ -553,11 +553,10 @@ */ @Test @Alerts(DEFAULT = "in click", - IE6 = { "in click", "in click", "in click" }, - IE7 = { "in click", "in click", "in click" }) + IE = { "in click", "in click", "in click" }) public void testCloneNode_copiesListenerOnlyForIE() throws Exception { final String html = - "<!DOCTYPE HTML>\n<html>\n" + "<html>\n" + " <head>\n" + " <script type='text/javascript'>\n" + " function go() {\n" |
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] |
From: <rb...@us...> - 2013-05-05 17:46:21
|
Revision: 8263 http://sourceforge.net/p/htmlunit/code/8263 Author: rbri Date: 2013-05-05 17:46:16 +0000 (Sun, 05 May 2013) Log Message: ----------- test the default value of form input fields added; 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/HtmlTextInput2Test.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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -65,6 +65,7 @@ // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified if (getAttribute("value") == ATTRIBUTE_NOT_DEFINED) { setAttribute("value", "on"); + setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); } } 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -65,6 +65,7 @@ // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified if (getAttribute("value") == ATTRIBUTE_NOT_DEFINED) { setAttribute("value", "on"); + setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); } defaultCheckedState_ = hasAttribute("checked"); 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -35,6 +35,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('button1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'button';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"button\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='button' id='button1'>\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", 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -614,29 +614,35 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "on", "on", "on", "on" }) - public void defaultDefaultValue() throws Exception { + @Alerts(DEFAULT = { "on-", "on-", "on-", "on-", "on-" }, + IE = { "on-", "on-", "on-", "on-", "on-on" }) + public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" - + " alert(document.getElementById('chkbox').value);\n" + + " var input = document.getElementById('chkbox1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" - + " var input = document.createElement('input');\n" + + " input = document.getElementById('chkbox2');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + " input.type = 'checkbox';\n" - + " alert(input.value);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " var builder = document.createElement('div');\n" + " builder.innerHTML = '<input type=\"checkbox\">';\n" - + " var input = builder.firstChild;\n" - + " alert(input.value);\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " input = input.cloneNode(false);\n" - + " alert(input.value);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "<form>\n" - + " <input type='checkbox' id='chkbox'>\n" + + " <input type='checkbox' id='chkbox1'>\n" + + " <input type='checkbox' id='chkbox2' checked='true'>\n" + "</form>\n" + "</body></html>"; 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -306,6 +306,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('file1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'file';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"file\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='file' id='file1'>\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 resetByClick() 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -56,6 +56,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('hidden1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'hidden';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"hidden\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='hidden' id='hidden1'>\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", 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -34,6 +34,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('image1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'image';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"image\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='image' id='image1'>\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 resetByClick() throws Exception { 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -168,6 +168,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('password1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'password';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"password\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='password' id='password1'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", "newValue-newDefault", "newValue-newDefault" }) public void resetByClick() throws Exception { 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -713,29 +713,35 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "on", "on", "on", "on" }) - public void defaultDefaultValue() throws Exception { + @Alerts(DEFAULT = { "on-", "on-", "on-", "on-", "on-" }, + IE = { "on-", "on-", "on-", "on-", "on-on" }) + public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" - + " alert(document.getElementById('rdo').value);\n" + + " var input = document.getElementById('radio1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" - + " var input = document.createElement('input');\n" + + " input = document.getElementById('radio2');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + " input.type = 'radio';\n" - + " alert(input.value);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " var builder = document.createElement('div');\n" + " builder.innerHTML = '<input type=\"radio\">';\n" - + " var input = builder.firstChild;\n" - + " alert(input.value);\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " input = input.cloneNode(false);\n" - + " alert(input.value);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" + "<form>\n" - + " <input type='radio' id='rdo'>\n" + + " <input type='radio' id='radio1'>\n" + + " <input type='radio' id='radio2' checked='true'>\n" + "</form>\n" + "</body></html>"; 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -34,6 +34,41 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "-", "-", "-", "-" }, + IE = { "Reset-", "Reset-", "Reset-", "Reset-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('reset1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'reset';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"reset\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='reset' id='reset1'>\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", 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -196,6 +196,41 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "-", "-", "-", "-" }, + IE = { "Submit Query-", "Submit Query-", "Submit Query-", "Submit Query-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('submit1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'submit';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"submit\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='submit' id='submit1'>\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", 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-05 14:41:41 UTC (rev 8262) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-05 17:46:16 UTC (rev 8263) @@ -34,6 +34,40 @@ * @throws Exception if the test fails */ @Test + @Alerts({ "-", "-", "-", "-" }) + public void defaultValues() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('text1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'text';\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"text\">';\n" + + " input = builder.firstChild;\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='text' id='text1'>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts({ "initial-initial", "initial-initial", "newValue-initial", "newValue-initial", "newValue-newDefault", "newValue-newDefault" }) public void resetByClick() throws Exception { |
From: <rb...@us...> - 2013-05-06 17:04:40
|
Revision: 8264 http://sourceforge.net/p/htmlunit/code/8264 Author: rbri Date: 2013-05-06 17:04:31 +0000 (Mon, 06 May 2013) Log Message: ----------- and again more test for the default values and some more fixes Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 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/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.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/HtmlTextInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -543,6 +543,22 @@ @BrowserFeature(@WebBrowser(IE)) HTMLBGSOUND, + /** Set this checked state back to default when added to page (IE6). */ + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) + HTMLCHECKEDINPUT_SET_CHECKED_TO_DEFAULT_WHEN_ADDED, + + /** Set this checked state to false when added to page (IE). */ + @BrowserFeature(@WebBrowser(value = IE)) + HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE, + + /** Setting defaultCheced updates checked also. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 8), @WebBrowser(CHROME) }) + HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED, + + /** Set the default value based on the current value when clone (IE). */ + @BrowserFeature(@WebBrowser(value = IE)) + HTMLCHECKEDINPUT_SET_DEFAULT_VALUE_WHEN_CLONE, + /** Indicates that comment nodes should be treated similar to elements, e.g. getElementsByTagName(). */ @BrowserFeature(@WebBrowser(IE)) HTMLCOLLECTION_COMMENT_IS_ELEMENT, @@ -598,18 +614,6 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLIMAGE_NAME_VALUE_PARAMS, - /** Set this checked state back to default when added to page (IE6). */ - @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) - HTMLINPUT_SET_CHECKED_TO_DEFAULT_WHEN_ADDED, - - /** Set this checked state to false when added to page (IE). */ - @BrowserFeature(@WebBrowser(value = IE)) - HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE, - - /** Setting defaultCheced updates checked also. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 8), @WebBrowser(CHROME) }) - HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED, - /** Setting defaultValue updates the value also. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 9), @WebBrowser(CHROME) }) HTMLINPUT_SET_DEFAULT_VALUE_UPDATES_VALUE, @@ -1192,6 +1196,10 @@ @BrowserFeature(@WebBrowser(value = IE, minVersion = 8)) QUERYSELECTORALL_NOT_IN_QUIRKS, + /** Set the value attribute of a reset input to 'Reset' if no value attribute specified. */ + @BrowserFeature(@WebBrowser(IE)) + RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED, + /** Indicates that escaping in attrubute selectors is supported. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) SELECTOR_ATTRIBUTE_ESCAPING, 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -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.HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCHECKEDINPUT_SET_DEFAULT_VALUE_WHEN_CLONE; import java.io.IOException; import java.util.Map; @@ -169,10 +170,10 @@ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; - if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { setChecked(defaultChecked); } - if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { reset(); forceChecked_ = true; } @@ -219,10 +220,13 @@ @Override public DomNode cloneNode(final boolean deep) { final HtmlCheckBoxInput clone = (HtmlCheckBoxInput) super.cloneNode(deep); - if (wasCreatedByJavascript() && hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { + if (wasCreatedByJavascript() && hasFeature(HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { clone.removeAttribute("checked"); clone.forceChecked_ = isDefaultChecked(); } + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_VALUE_WHEN_CLONE)) { + clone.setDefaultValue(getValueAttribute(), false); + } return clone; } @@ -254,7 +258,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED) && "value".equals(qualifiedName)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED) && "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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -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_DEFAULT_CHECKED_UPDATES_CHECKED; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCHECKEDINPUT_SET_DEFAULT_VALUE_WHEN_CLONE; import java.io.IOException; import java.util.List; @@ -222,10 +223,10 @@ @Override public void setDefaultChecked(final boolean defaultChecked) { defaultCheckedState_ = defaultChecked; - if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED)) { setChecked(isDefaultChecked()); } - if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { reset(); forceChecked_ = true; } @@ -267,7 +268,7 @@ @Override protected void onAddedToDocumentFragment() { super.onAddedToPage(); - if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { forceChecked_ = true; } } @@ -279,10 +280,13 @@ public DomNode cloneNode(final boolean deep) { final HtmlRadioButtonInput clone = (HtmlRadioButtonInput) super.cloneNode(deep); clone.forceChecked_ = false; - if (wasCreatedByJavascript() && hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { + if (wasCreatedByJavascript() && hasFeature(HTMLCHECKEDINPUT_SET_CHECKED_TO_FALSE_WHEN_CLONE)) { clone.removeAttribute("checked"); clone.forceChecked_ = true; } + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_VALUE_WHEN_CLONE)) { + clone.setDefaultValue(getValueAttribute(), false); + } return clone; } @@ -314,7 +318,7 @@ */ @Override public void setAttributeNS(final String namespaceURI, final String qualifiedName, final String attributeValue) { - if (hasFeature(HTMLINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED) && "value".equals(qualifiedName)) { + if (hasFeature(HTMLCHECKEDINPUT_SET_DEFAULT_CHECKED_UPDATES_CHECKED) && "value".equals(qualifiedName)) { setDefaultValue(attributeValue, false); } super.setAttributeNS(namespaceURI, qualifiedName, attributeValue); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -15,10 +15,12 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLINPUT_SET_VALUE_UPDATES_DEFAULT_VALUE; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED; import java.io.IOException; import java.util.Map; +import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.SgmlPage; /** @@ -35,6 +37,11 @@ public class HtmlResetInput extends HtmlInput { /** + * Value to use if no specified <tt>value</tt> attribute. + */ + private static final String DEFAULT_VALUE = "Reset"; + + /** * Creates an instance. * * @param namespaceURI the URI that identifies an XML namespace @@ -44,10 +51,40 @@ */ HtmlResetInput(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { - super(namespaceURI, qualifiedName, page, attributes); + super(namespaceURI, qualifiedName, page, addValueIfNeeded(page, attributes)); + + // fix the default value in case we have set it + if (hasFeature(RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED) + && getAttribute("value") == DEFAULT_VALUE) { + setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); + } } /** + * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option + * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its + * parent. + */ + private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, + final Map<String, DomAttr> attributes) { + + final BrowserVersion browserVersion = page.getWebClient().getBrowserVersion(); + if (browserVersion.hasFeature(RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED)) { + for (final String key : attributes.keySet()) { + if ("value".equalsIgnoreCase(key)) { + return attributes; // value attribute was specified + } + } + + // value attribute was not specified, add it + final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); + attributes.put("value", newAttr); + } + + return attributes; + } + + /** * {@inheritDoc} */ @Override Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -56,6 +56,12 @@ HtmlSubmitInput(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { super(namespaceURI, qualifiedName, page, addValueIfNeeded(page, attributes)); + + // fix the default value in case we have set it + if (hasFeature(SUBMITINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED) + && getAttribute("value") == DEFAULT_VALUE) { + setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); + } } /** 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -35,7 +35,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -51,9 +51,40 @@ + " builder.innerHTML = '<input type=\"button\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='button' id='button1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('button1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'button';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"button\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -614,8 +614,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "on-", "on-", "on-", "on-", "on-" }, - IE = { "on-", "on-", "on-", "on-", "on-on" }) + @Alerts({ "on-", "on-", "on-", "on-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -634,9 +633,46 @@ + " builder.innerHTML = '<input type=\"checkbox\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='checkbox' id='chkbox1'>\n" + + " <input type='checkbox' id='chkbox2' checked='true'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "on-", "on-", "on-", "on-" }, + IE = { "on-on", "on-on", "on-on", "on-on" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('chkbox1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.getElementById('chkbox2');\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'checkbox';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"checkbox\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -306,7 +306,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -322,9 +322,40 @@ + " builder.innerHTML = '<input type=\"file\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='file' id='file1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('file1');\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " input = input.cloneNode(false);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'file';\n" + + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"file\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInputTest.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -56,7 +56,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -72,9 +72,40 @@ + " builder.innerHTML = '<input type=\"hidden\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='hidden' id='hidden1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('hidden1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'hidden';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"hidden\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -34,7 +34,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -50,9 +50,40 @@ + " builder.innerHTML = '<input type=\"image\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='image' id='image1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterclone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('image1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'image';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"image\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInputTest.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -168,7 +168,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -184,9 +184,40 @@ + " builder.innerHTML = '<input type=\"password\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='password' id='password1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('password1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'password';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"password\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -713,8 +713,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "on-", "on-", "on-", "on-", "on-" }, - IE = { "on-", "on-", "on-", "on-", "on-on" }) + @Alerts({ "on-", "on-", "on-", "on-", }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -733,9 +732,46 @@ + " builder.innerHTML = '<input type=\"radio\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='radio' id='radio1'>\n" + + " <input type='radio' id='radio2' checked='true'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "on-", "on-", "on-", "on-" }, + IE = { "on-on", "on-on", "on-on", "on-on" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('radio1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.getElementById('radio2');\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'radio';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"radio\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -34,8 +34,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "-", "-", "-", "-" }, - IE = { "Reset-", "Reset-", "Reset-", "Reset-" }) + @Alerts(DEFAULT = { "-", "-", "-" }, + IE = { "Reset-", "Reset-", "Reset-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -51,9 +51,41 @@ + " builder.innerHTML = '<input type=\"reset\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='reset' id='reset1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "-", "-", "-" }, + IE = { "Reset-", "Reset-", "Reset-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('reset1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'reset';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"reset\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInputTest.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -196,8 +196,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "-", "-", "-", "-" }, - IE = { "Submit Query-", "Submit Query-", "Submit Query-", "Submit Query-" }) + @Alerts(DEFAULT = { "-", "-", "-" }, + IE = { "Submit Query-", "Submit Query-", "Submit Query-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -213,9 +213,41 @@ + " builder.innerHTML = '<input type=\"submit\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='submit' id='submit1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "-", "-", "-" }, + IE = { "Submit Query-", "Submit Query-", "Submit Query-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('submit1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'submit';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"submit\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" 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-05 17:46:16 UTC (rev 8263) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput2Test.java 2013-05-06 17:04:31 UTC (rev 8264) @@ -34,7 +34,7 @@ * @throws Exception if the test fails */ @Test - @Alerts({ "-", "-", "-", "-" }) + @Alerts({ "-", "-", "-" }) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -50,9 +50,40 @@ + " builder.innerHTML = '<input type=\"text\">';\n" + " input = builder.firstChild;\n" + " alert(input.value + '-' + input.defaultValue);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <input type='text' id='text1'>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "-", "-", "-" }) + public void defaultValuesAfterClone() throws Exception { + final String html = "<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var input = document.getElementById('text1');\n" + " input = input.cloneNode(false);\n" + " alert(input.value + '-' + input.defaultValue);\n" + + + " input = document.createElement('input');\n" + + " input.type = 'text';\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"text\">';\n" + + " input = builder.firstChild;\n" + + " input = input.cloneNode(false);\n" + + " alert(input.value + '-' + input.defaultValue);\n" + " }\n" + "</script>\n" + "</head><body onload='test()'>\n" |
From: <rb...@us...> - 2013-05-06 19:09:45
|
Revision: 8265 http://sourceforge.net/p/htmlunit/code/8265 Author: rbri Date: 2013-05-06 19:09:39 +0000 (Mon, 06 May 2013) Log Message: ----------- more fixes for the default values Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EventTest.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-06 17:04:31 UTC (rev 8264) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-05-06 19:09:39 UTC (rev 8265) @@ -41,6 +41,11 @@ */ public class HtmlCheckBoxInput extends HtmlInput { + /** + * Value to use if no specified <tt>value</tt> attribute. + */ + private static final String DEFAULT_VALUE = "on"; + private boolean defaultCheckedState_; private boolean valueAtFocus_; private boolean forceChecked_; @@ -58,16 +63,36 @@ */ HtmlCheckBoxInput(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { - super(namespaceURI, qualifiedName, page, attributes); + // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified + super(namespaceURI, qualifiedName, page, addValueIfNeeded(page, attributes)); - //From the checkbox creator + // fix the default value in case we have set it + if (getAttribute("value") == DEFAULT_VALUE) { + setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); + } + defaultCheckedState_ = hasAttribute("checked"); + } - // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified - if (getAttribute("value") == ATTRIBUTE_NOT_DEFINED) { - setAttribute("value", "on"); - setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); + /** + * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option + * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its + * parent. + */ + private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, + final Map<String, DomAttr> attributes) { + + for (final String key : attributes.keySet()) { + if ("value".equalsIgnoreCase(key)) { + return attributes; // value attribute was specified + } } + + // value attribute was not specified, add it + final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); + attributes.put("value", newAttr); + + return attributes; } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java 2013-05-06 17:04:31 UTC (rev 8264) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java 2013-05-06 19:09:39 UTC (rev 8265) @@ -19,6 +19,7 @@ import java.io.File; import java.net.URI; import java.net.URISyntaxException; +import java.util.HashMap; import java.util.Map; import org.apache.commons.lang3.StringUtils; @@ -53,14 +54,37 @@ */ HtmlFileInput(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { - super(namespaceURI, qualifiedName, page, attributes); - setAttribute("value", ""); + super(namespaceURI, qualifiedName, page, addValueIfNeeded(page, attributes)); + if (hasFeature(FILEINPUT_EMPTY_DEFAULT_VALUE)) { - setDefaultValue(""); + setDefaultValue("", false); } + else { + for (final Map.Entry<String, DomAttr> entry : attributes.entrySet()) { + if ("value".equalsIgnoreCase(entry.getKey())) { + setDefaultValue(entry.getValue().getNodeValue(), false); + } + } + } } /** + * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option + * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its + * parent. + */ + private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, + final Map<String, DomAttr> attributes) { + + // we need a copy here because we have to check attributes later again + final Map<String, DomAttr> result = new HashMap<String, DomAttr>(attributes); + final DomAttr newAttr = new DomAttr(page, null, "value", "", true); + result.put("value", newAttr); + + return result; + } + + /** * Returns the in-memory data assigned to this file input element, if any. * @return <code>null</code> if {@link #setData(byte[])} hasn't be used */ 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-06 17:04:31 UTC (rev 8264) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java 2013-05-06 19:09:39 UTC (rev 8265) @@ -45,6 +45,11 @@ */ public class HtmlRadioButtonInput extends HtmlInput { + /** + * Value to use if no specified <tt>value</tt> attribute. + */ + private static final String DEFAULT_VALUE = "on"; + private boolean defaultCheckedState_; private boolean valueAtFocus_; private boolean forceChecked_; @@ -61,11 +66,11 @@ */ HtmlRadioButtonInput(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { - super(namespaceURI, qualifiedName, page, attributes); + // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified + super(namespaceURI, qualifiedName, page, addValueIfNeeded(page, attributes)); - // default value for both IE6 and Mozilla 1.7 even if spec says it is unspecified - if (getAttribute("value") == ATTRIBUTE_NOT_DEFINED) { - setAttribute("value", "on"); + // fix the default value in case we have set it + if (getAttribute("value") == DEFAULT_VALUE) { setDefaultValue(ATTRIBUTE_NOT_DEFINED, false); } @@ -73,6 +78,27 @@ } /** + * Add missing attribute if needed by fixing attribute map rather to add it afterwards as this second option + * triggers the instantiation of the script object at a time where the DOM node has not yet been added to its + * parent. + */ + private static Map<String, DomAttr> addValueIfNeeded(final SgmlPage page, + final Map<String, DomAttr> attributes) { + + for (final String key : attributes.keySet()) { + if ("value".equalsIgnoreCase(key)) { + return attributes; // value attribute was specified + } + } + + // value attribute was not specified, add it + final DomAttr newAttr = new DomAttr(page, null, "value", DEFAULT_VALUE, true); + attributes.put("value", newAttr); + + return attributes; + } + + /** * {@inheritDoc} * @see SubmittableElement#reset() */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EventTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EventTest.java 2013-05-06 17:04:31 UTC (rev 8264) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EventTest.java 2013-05-06 19:09:39 UTC (rev 8265) @@ -42,6 +42,7 @@ * @author Ahmed Ashour * @author Daniel Gredler * @author Marc Guillemot + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class EventTest extends WebDriverTestCase { @@ -708,10 +709,26 @@ @Alerts({ "from theField", "from theForm", "from document", "from window" }) public void eventHandlersParentScopeChain_formFields() throws Exception { eventHandlersParentScopeChain("<button", "</button>"); + eventHandlersParentScopeChain("<input type='text'", ""); + eventHandlersParentScopeChain("<input type='password'", ""); + eventHandlersParentScopeChain("<input type='hidden'", ""); + + eventHandlersParentScopeChain("<input type='checkbox'", ""); + eventHandlersParentScopeChain("<input type='radio'", ""); + + eventHandlersParentScopeChain("<input type='file'", ""); + eventHandlersParentScopeChain("<input type='image'", ""); + + eventHandlersParentScopeChain("<input type='button'", ""); + eventHandlersParentScopeChain("<input type='submit' value='xxx'", ""); // case without value attribute was failing first with IE due to the way the value attribute was added eventHandlersParentScopeChain("<input type='submit'", ""); + + eventHandlersParentScopeChain("<input type='reset' value='xxx'", ""); + // case without value attribute was failing first with IE due to the way the value attribute was added + eventHandlersParentScopeChain("<input type='reset'", ""); } /** @@ -725,19 +742,21 @@ } private void eventHandlersParentScopeChain(final String startTag, final String endTag) throws Exception { - final String html = "<html><body id='body'>\n" + final String html = "<html><html>\n" + + "<head><title>foo</title></head>\n" + + "<body id='body'>\n" + "<form id='theForm'>\n" - + "<div id='theDiv'>\n" - + startTag + " id='theField' onclick='alert(foo); return false;'>click me" + endTag + "\n" - + "</div>\n" + + " <div id='theDiv'>\n" + + " " + startTag + " id='theField' onclick='alert(foo); return false;'>click me" + endTag + "\n" + + " </div>\n" + "</form>\n" + "<script>\n" - + "var foo = 'from window';\n" - + "document.foo = 'from document';\n" - + "document.body.foo = 'from body';\n" - + "document.getElementById('theForm').foo = 'from theForm';\n" - + "document.getElementById('theDiv').foo = 'from theDiv';\n" - + "document.getElementById('theField').foo = 'from theField';\n" + + " var foo = 'from window';\n" + + " document.foo = 'from document';\n" + + " document.body.foo = 'from body';\n" + + " document.getElementById('theForm').foo = 'from theForm';\n" + + " document.getElementById('theDiv').foo = 'from theDiv';\n" + + " document.getElementById('theField').foo = 'from theField';\n" + "</script>\n" + "</body></html>"; |
From: <rb...@us...> - 2013-05-07 16:53:24
|
Revision: 8267 http://sourceforge.net/p/htmlunit/code/8267 Author: rbri Date: 2013-05-07 16:53:15 +0000 (Tue, 07 May 2013) Log Message: ----------- some override annotations added Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2013-05-07 16:25:25 UTC (rev 8266) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2013-05-07 16:53:15 UTC (rev 8267) @@ -97,6 +97,7 @@ /** * {@inheritDoc} */ + @Override public final boolean isDisabled() { return hasAttribute("disabled"); } @@ -104,6 +105,7 @@ /** * {@inheritDoc} */ + @Override public NameValuePair[] getSubmitKeyValuePairs() { return new NameValuePair[]{new NameValuePair(getNameAttribute(), getValueAttribute())}; } @@ -113,6 +115,7 @@ * * @see SubmittableElement#reset() */ + @Override public void reset() { if (LOG.isDebugEnabled()) { LOG.debug("reset() not implemented for this element"); @@ -124,6 +127,7 @@ * * @see SubmittableElement#setDefaultValue(String) */ + @Override public void setDefaultValue(final String defaultValue) { if (LOG.isDebugEnabled()) { LOG.debug("setDefaultValue() not implemented for this element"); @@ -135,6 +139,7 @@ * * @see SubmittableElement#getDefaultValue() */ + @Override public String getDefaultValue() { if (LOG.isDebugEnabled()) { LOG.debug("getDefaultValue() not implemented for this element"); @@ -152,6 +157,7 @@ * @see HtmlRadioButtonInput#setDefaultChecked(boolean) * @see HtmlCheckBoxInput#setDefaultChecked(boolean) */ + @Override public void setDefaultChecked(final boolean defaultChecked) { // Empty. } @@ -166,6 +172,7 @@ * @see HtmlRadioButtonInput#isDefaultChecked() * @see HtmlCheckBoxInput#isDefaultChecked() */ + @Override public boolean isDefaultChecked() { return false; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-07 16:25:25 UTC (rev 8266) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-07 16:53:15 UTC (rev 8267) @@ -34,6 +34,7 @@ * @author Brad Clarke * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class HtmlButton2Test extends WebDriverTestCase { |
From: <rb...@us...> - 2013-05-19 15:23:40
|
Revision: 8274 http://sourceforge.net/p/htmlunit/code/8274 Author: rbri Date: 2013-05-19 15:23:35 +0000 (Sun, 19 May 2013) Log Message: ----------- add testcase for issue #1502 - NYI(IE) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-05-11 07:52:06 UTC (rev 8273) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-05-19 15:23:35 UTC (rev 8274) @@ -977,7 +977,7 @@ } return; } - else if (commentTill != null) { + if (commentTill != null) { final XMLStringBuffer buffer = new XMLStringBuffer(); int ch; while ((ch = read()) != -1) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-05-11 07:52:06 UTC (rev 8273) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParser2Test.java 2013-05-19 15:23:35 UTC (rev 8274) @@ -1324,4 +1324,33 @@ public void childNodes_xmp() throws Exception { loadPageWithAlerts2(createHtmlForChildNodes("xmp")); } + + /** + * conditional comments are removed from the dom. + * @throws Exception on test failure + */ + @Test + @Alerts(DEFAULT = { "<!--[if gt IE 11]><br><![endif]-->", "<!--[if lt IE 11]><br><![endif]-->" }, + IE = { "", "<BR>" }) + @NotYetImplemented(IE) + public void ieConditionalCommentsNotInDom() throws Exception { + final String html = "<html><head>\n" + + "<script>\n" + + "function test() {\n" + + "try {\n" + + " var tmp = document.getElementById('my1');\n" + + " alert(tmp.innerHTML)\n" + + " tmp = document.getElementById('my2');\n" + + " alert(tmp.innerHTML)\n" + + "} catch(e) { alert('exception'); }\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <div id='my1'><!--[if gt IE 11]><br><![endif]--></div>\n" + + " <div id='my2'><!--[if lt IE 11]><br><![endif]--></div>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2013-05-20 10:10:43
|
Revision: 8276 http://sourceforge.net/p/htmlunit/code/8276 Author: rbri Date: 2013-05-20 10:10:41 +0000 (Mon, 20 May 2013) Log Message: ----------- Use the correct frame/iframe for a given target if more than one exists for the given name. Issue 1488 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-20 09:52:14 UTC (rev 8275) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-20 10:10:41 UTC (rev 8276) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri" issue="1488"> + Use the correct frame/iframe for a given target if more than one exists for the given name. + </action> <action type="fix" dev="rbri"> The value of input controls changes when the defaultValue was changed in IE8ff. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-05-20 09:52:14 UTC (rev 8275) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-05-20 10:10:41 UTC (rev 8276) @@ -857,14 +857,33 @@ return null; } - if (!name.isEmpty()) { - try { - return getWebWindowByName(name); + // first search for frame windows inside our window hierarchy + WebWindow window = opener; + while (true) { + final Page page = window.getEnclosedPage(); + if (page instanceof HtmlPage) { + try { + final FrameWindow frame = ((HtmlPage) page).getFrameByName(name); + return frame; + } + catch (final ElementNotFoundException e) { + // Fall through + } } - catch (final WebWindowNotFoundException e) { - // Fall through - a new window will be created below + + if (window == window.getParentWindow()) { + // TODO: should getParentWindow() return null on top windows? + break; } + window = window.getParentWindow(); } + + try { + return getWebWindowByName(name); + } + catch (final WebWindowNotFoundException e) { + // Fall through - a new window will be created below + } return null; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame2Test.java 2013-05-20 09:52:14 UTC (rev 8275) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame2Test.java 2013-05-20 10:10:41 UTC (rev 8276) @@ -14,6 +14,9 @@ */ package com.gargoylesoftware.htmlunit.html; +import java.net.URL; + +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -22,6 +25,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -84,4 +88,103 @@ loadPageWithAlerts2(html); } + + /** + * Test, the right frame is used for a target, even if some frames + * have the same name. + * + * @throws Exception if the test fails + */ + @Test + public void targetResolution() throws Exception { + final String framesContent = "<html><head><title>Top Page</title></head>\n" + + "<body><div id='content'>Body of top frame</div>\n" + + " <iframe src='left.html' id='id-left' name='left'></iframe>\n" + + " <iframe src='right.html' id='id-right' name='right'></iframe>\n" + + "</body>\n" + + "</html>"; + + final String rightFrame = "<html><head><title>Right Frame</title></head>\n" + + "<body><div id='content'>Body of right frame</div></body>\n" + + "</html>"; + + final String leftFrame = "<html><head><title>Left Frame</title></head>\n" + + "<body>\n" + + " <div id='content'>Body of left frame</div>\n" + + " <a id='link' name='link' href='new_inner.html' target='right'>Click link</a>" + + " <iframe id='id-inner' name='right' width='100' height='100' src='inner.html'></iframe>" + + "</body>\n" + + "</html>"; + + final String innerFrame = "<html><head><title>Inner Frame</title></head>\n" + + "<body><div id='content'>Body of inner frame</div></body>\n" + + "</html>"; + + final String newInnerFrame = "<html><head><title>New inner Frame</title></head>\n" + + "<body><div id='content'>Body of new inner frame</div></body>\n" + + "</html>"; + + final String baseUrl = URL_FIRST.toString(); + + final URL leftFrameUrl = new URL(baseUrl + "left.html"); + final URL rightFrameUrl = new URL(baseUrl + "right.html"); + final URL innerFrameURL = new URL(baseUrl + "inner.html"); + final URL newInnerFrameURL = new URL(baseUrl + "new_inner.html"); + + final MockWebConnection webConnection = getMockWebConnection(); + webConnection.setResponse(leftFrameUrl, leftFrame); + webConnection.setResponse(rightFrameUrl, rightFrame); + webConnection.setResponse(innerFrameURL, innerFrame); + webConnection.setResponse(newInnerFrameURL, newInnerFrame); + + final WebDriver driver = loadPage2(framesContent); + + // top frame + assertEquals("Top Page", driver.getTitle()); + assertEquals("Body of top frame", driver.findElement(By.id("content")).getText()); + + // start REMOVE ME + // because of the return value change done for + // com.gargoylesoftware.htmlunit.html.BaseFrameElement.getEnclosedWindow() + // this test does not work with the current selenium driver + // this hack is only to inform us, if selenium uses the latest htmlunit + // then we can remove this + try { + driver.switchTo().frame("id-left"); + Assert.fail("Switching the frame seems to work now in selenium. Please remove this code."); + } + catch (final NoSuchMethodError e) { + // expected, no chance to implement the test without this + return; + } + // end REMOVE ME + + // left frame + driver.switchTo().frame("id-left"); + assertEquals("Body of left frame", driver.findElement(By.id("content")).getText()); + // inner frame + driver.switchTo().frame("id-inner"); + assertEquals("Body of inner frame", driver.findElement(By.id("content")).getText()); + // right frame + driver.switchTo().defaultContent(); + driver.switchTo().frame("id-right"); + assertEquals("Body of right frame", driver.findElement(By.id("content")).getText()); + + // clicking on a link which contains a target 'right'. But this target frame is defined two times. + driver.switchTo().defaultContent(); + driver.switchTo().frame("id-left"); + driver.findElement(By.id("link")).click(); + + // left frame + driver.switchTo().defaultContent(); + driver.switchTo().frame("id-left"); + assertEquals("Body of left frame", driver.findElement(By.id("content")).getText()); + // inner frame + driver.switchTo().frame("id-inner"); + assertEquals("Body of new inner frame", driver.findElement(By.id("content")).getText()); + // right frame + driver.switchTo().defaultContent(); + driver.switchTo().frame("id-right"); + assertEquals("Body of right frame", driver.findElement(By.id("content")).getText()); + } } |
From: <rb...@us...> - 2013-05-22 20:46:24
|
Revision: 8283 http://sourceforge.net/p/htmlunit/code/8283 Author: rbri Date: 2013-05-22 20:46:21 +0000 (Wed, 22 May 2013) Log Message: ----------- fix wrong mouse event triggering because of broken selenium Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlOption2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-22 18:10:43 UTC (rev 8282) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-22 20:46:21 UTC (rev 8283) @@ -184,11 +184,11 @@ EVENT_ONLOAD_IFRAME_CREATED_BY_JAVASCRIPT, /** Does not trigger "onmousedown" event handler for the select options. */ - @BrowserFeature({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(IE) }) + @BrowserFeature({ @WebBrowser(IE) }) EVENT_ONMOUSEDOWN_FOR_SELECT_OPTION_TRIGGERS_ADDITIONAL_DOWN_FOR_SELECT, /** Does not trigger "onmousedown" event handler for the select options. */ - @BrowserFeature({ @WebBrowser(value = FF, minVersion = 10) }) + @BrowserFeature({ }) EVENT_ONMOUSEDOWN_FOR_SELECT_OPTION_TRIGGERS_ADDITIONAL_UP_FOR_SELECT, /** Does not trigger "onmousedown" event handler for the select options. */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlOption2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlOption2Test.java 2013-05-22 18:10:43 UTC (rev 8282) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlOption2Test.java 2013-05-22 20:46:21 UTC (rev 8283) @@ -23,6 +23,8 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -38,10 +40,14 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "sDown,dDown,sUp,dUp,oDown,sDown,dDown,oUp,sUp,dUp,", + @Alerts(DEFAULT = "oDown,sDown,dDown,oUp,sUp,dUp,", FF3_6 = "sUp,dUp,oUp,sUp,dUp,", IE = "sDown,dDown,sUp,dUp,", CHROME = "sUp,dUp,") + // there seems to be a bug in selenium; for FF >= 10 this triggers + // "sDown,dDown,sUp,dUp,oDown,sDown,dDown,oUp,sUp,dUp," but a + // manual test shows, that this is wrong. + @BuggyWebDriver({ Browser.FF10, Browser.FF17 }) public void onMouse() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" |
From: <mgu...@us...> - 2013-05-23 12:30:51
|
Revision: 8285 http://sourceforge.net/p/htmlunit/code/8285 Author: mguillem Date: 2013-05-23 12:30:48 +0000 (Thu, 23 May 2013) Log Message: ----------- - asXml(): don't generated self closing tags for empty a, p, and dd nodes - moved unit test with JS from HtmlParagrapTest to HTMLParagraphElementTest Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescription.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlParagraph.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAnchorTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlParagraphTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLParagraphElementTest.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescriptionTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlAnchor.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -310,4 +310,9 @@ final WebWindow newWindow = getPage().getWebClient().openWindow(target, windowName); return newWindow.getEnclosedPage(); } + + @Override + protected boolean isEmptyXmlTagExpanded() { + return true; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescription.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescription.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescription.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -44,4 +44,9 @@ final Map<String, DomAttr> attributes) { super(namespaceURI, qualifiedName, page, attributes); } + + @Override + protected boolean isEmptyXmlTagExpanded() { + return true; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlParagraph.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlParagraph.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlParagraph.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -65,4 +65,9 @@ protected boolean isBlock() { return true; } + + @Override + protected boolean isEmptyXmlTagExpanded() { + return true; + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAnchorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAnchorTest.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlAnchorTest.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -653,4 +653,18 @@ final HtmlPage page2 = span.click(); assertEquals(new URL(getDefaultUrl(), "page2.html"), page2.getUrl()); } + + /** + * @throws Exception if the test fails + */ + @Test + public void asXml_emptyTag() throws Exception { + final String html = "<html><body>\n" + + "<a name='foo'></a>\n" + + "</body></html>"; + + final HtmlPage page = loadPage(html); + final HtmlAnchor htmlAnchor = page.getAnchorByName("foo"); + assertTrue(htmlAnchor.asXml().contains("</a>")); + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescriptionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescriptionTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlDefinitionDescriptionTest.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.SimpleWebTestCase; + +/** + * Tests for {@link HtmlDefinitionDescription}. + * + * @version $Revision: 7931 $ + * @author Marc Guillemot + */ +@RunWith(BrowserRunner.class) +public class HtmlDefinitionDescriptionTest extends SimpleWebTestCase { + /** + * @throws Exception if the test fails + */ + @Test + public void asXml_emptyTag() throws Exception { + final String html = "<html><body>\n" + + "<dd id='foo'></dd>\n" + + "</body></html>"; + + final HtmlPage page = loadPage(html); + final HtmlElement element = page.getHtmlElementById("foo"); + assertTrue(element.asXml().contains("</dd>")); + } +} Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlParagraphTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlParagraphTest.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlParagraphTest.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -16,42 +16,29 @@ import org.junit.Test; import org.junit.runner.RunWith; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.htmlunit.HtmlUnitDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.SimpleWebTestCase; /** * Tests for {@link HtmlParagraph}. * * @version $Revision$ - * @author Ahmed Ashour + * @author Marc Guillemot */ @RunWith(BrowserRunner.class) -public class HtmlParagraphTest extends WebDriverTestCase { - +public class HtmlParagraphTest extends SimpleWebTestCase { /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "[object HTMLParagraphElement]", IE = "[object]") - public void simpleScriptable() throws Exception { - final String html = "<html><head>\n" - + "<script>\n" - + " function test() {\n" - + " alert(document.getElementById('myId'));\n" - + " }\n" - + "</script>\n" - + "</head><body onload='test()'>\n" - + " <p id='myId'/>\n" + public void asXml_emptyTag() throws Exception { + final String html = "<html><body>\n" + + "<p id='foo'></p>\n" + "</body></html>"; - final WebDriver driver = loadPageWithAlerts2(html); - if (driver instanceof HtmlUnitDriver) { - final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage(); - assertTrue(HtmlParagraph.class.isInstance(page.getHtmlElementById("myId"))); - } + final HtmlPage page = loadPage(html); + final HtmlElement element = page.getHtmlElementById("foo"); + assertTrue(element.asXml().contains("</p>")); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLParagraphElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLParagraphElementTest.java 2013-05-23 05:26:45 UTC (rev 8284) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLParagraphElementTest.java 2013-05-23 12:30:48 UTC (rev 8285) @@ -16,20 +16,48 @@ import org.junit.Test; import org.junit.runner.RunWith; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.htmlunit.HtmlUnitDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.SimpleWebTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import com.gargoylesoftware.htmlunit.html.HtmlParagraph; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** * Tests for {@link HTMLParagraphElement}. * @version $Revision$ * @author Daniel Gredler + * @author Ahmed Ashour */ @RunWith(BrowserRunner.class) -public class HTMLParagraphElementTest extends SimpleWebTestCase { +public class HTMLParagraphElementTest extends WebDriverTestCase { /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object HTMLParagraphElement]", IE = "[object]") + public void simpleScriptable() throws Exception { + final String html = "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(document.getElementById('myId'));\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + " <p id='myId'/>\n" + + "</body></html>"; + + final WebDriver driver = loadPageWithAlerts2(html); + if (driver instanceof HtmlUnitDriver) { + final HtmlPage page = (HtmlPage) getWebWindowOf((HtmlUnitDriver) driver).getEnclosedPage(); + assertTrue(HtmlParagraph.class.isInstance(page.getHtmlElementById("myId"))); + } + } + + /** * @throws Exception if an error occurs */ @Test @@ -63,7 +91,7 @@ + " </head>\n" + " <body onload='test()'><p id='p'>foo</p></body>\n" + "</html>"; - loadPageWithAlerts(html); + loadPageWithAlerts2(html); } } |
From: <mgu...@us...> - 2013-05-23 13:58:38
|
Revision: 8288 http://sourceforge.net/p/htmlunit/code/8288 Author: mguillem Date: 2013-05-23 13:58:35 +0000 (Thu, 23 May 2013) Log Message: ----------- dispatchEvent of type submit on a form has to submit the form Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java 2013-05-23 13:54:10 UTC (rev 8287) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java 2013-05-23 13:58:35 UTC (rev 8288) @@ -54,6 +54,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.Event; import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection; /** @@ -471,4 +472,12 @@ return null; } + @Override + public boolean dispatchEvent(final Event event) { + if (event.getType().equals(Event.TYPE_SUBMIT)) { + submit(); + return true; + } + return super.dispatchEvent(event); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-05-23 13:54:10 UTC (rev 8287) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-05-23 13:58:35 UTC (rev 8288) @@ -18,6 +18,8 @@ import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF17; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE; +import java.net.URL; + import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.WebDriver; @@ -2033,6 +2035,48 @@ * @throws Exception if an error occurs */ @Test + @Alerts(DEFAULT = "page2 loaded", IE = "exception") + public void dispatchEvent_submitOnForm() throws Exception { + final String html = "<html><head><title>page 1</title></head><body>\n" + + "<form action='page2' id='theForm'><span id='foo'/></form>\n" + + "<script>\n" + + "try {\n" + + " var e = document.createEvent('HTMLEvents');\n" + + " e.initEvent('submit', true, false);\n" + + " document.getElementById('theForm').dispatchEvent(e);\n" + + "} catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + + final String page2 = "<html><body><script>alert('page2 loaded');</script></body></html>"; + + getMockWebConnection().setResponse(new URL(getDefaultUrl() + "page2"), page2); + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(IE = "exception") + public void dispatchEvent_submitOnFormChild() throws Exception { + final String html = "<html><head><title>page 1</title></head><body>\n" + + "<form action='page2'><span id='foo'/></form>\n" + + "<script>\n" + + "try {\n" + + " var e = document.createEvent('HTMLEvents');\n" + + " e.initEvent('submit', true, false);\n" + + " document.getElementById('foo').dispatchEvent(e);\n" + + "} catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + + final WebDriver webDriver = loadPageWithAlerts2(html); + assertEquals("page 1", webDriver.getTitle()); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts(DEFAULT = { "true", "true", "false" }, IE = "exception") public void hasAttribute() throws Exception { final String html = |
From: <rb...@us...> - 2013-05-25 09:38:24
|
Revision: 8302 http://sourceforge.net/p/htmlunit/code/8302 Author: rbri Date: 2013-05-25 09:38:20 +0000 (Sat, 25 May 2013) Log Message: ----------- Adjust the window.outherHeight for the newer FF versions. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-25 07:52:01 UTC (rev 8301) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-25 09:38:20 UTC (rev 8302) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri"> + Adjust the window.outherHeight for the newer FF versions. + </action> <action type="fix" dev="rbri" issue="1488"> Use the correct frame/iframe for a given target if more than one exists for the given name. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-25 07:52:01 UTC (rev 8301) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-25 09:38:20 UTC (rev 8302) @@ -131,6 +131,10 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) DISPLAYED_COLLAPSE, + /** FF 3.6 has a much lager menu bar. */ + @BrowserFeature({ @WebBrowser(value = FF, minVersion = 3.6f, maxVersion = 3.6f) }) + DISPLAY_LARGE_MENU_BAR, + /** */ @BrowserFeature(@WebBrowser(IE)) DOCTYPE_4_0_TRANSITIONAL_STANDARDS, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-05-25 07:52:01 UTC (rev 8301) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-05-25 09:38:20 UTC (rev 8302) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.DISPLAY_LARGE_MENU_BAR; + import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -53,7 +55,7 @@ private boolean closed_; private int innerHeight_ = 605; - private int outerHeight_ = innerHeight_ + 150; + private int outerHeight_ = innerHeight_ + 111; private int innerWidth_ = 1256; private int outerWidth_ = innerWidth_ + 8; @@ -74,6 +76,11 @@ WebAssert.notNull("webClient", webClient); webClient_ = webClient; jobManager_ = BackgroundJavaScriptFactory.theFactory().createJavaScriptJobManager(this); + + // adjust inner height for ff 3.6 + if (webClient.getBrowserVersion().hasFeature(DISPLAY_LARGE_MENU_BAR)) { + outerHeight_ = innerHeight_ + 166; + } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-05-25 07:52:01 UTC (rev 8301) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-05-25 09:38:20 UTC (rev 8302) @@ -629,15 +629,16 @@ */ @Test @Browsers(FF) - @Alerts(FF = { "true", "true", "true", "true", "true", "true" }, - FF10 = { "true", "true", "false", "true", "true", "true" }) + @Alerts(DEFAULT = { "true", "true", "false", "true", "true", "true", "true" }, + FF3_6 = { "true", "true", "true", "false", "true", "true", "true" }) public void heightsAndWidths() throws Exception { final String html = "<html><body onload='test()'><script>\n" + "function test() {\n" + " alert(window.innerHeight > 0);\n" + " alert(window.innerHeight == document.body.clientHeight);\n" - + " alert(window.outerHeight == window.innerHeight + 150);\n" + + " alert(window.outerHeight == window.innerHeight + 166);\n" // FF 3.6 + + " alert(window.outerHeight == window.innerHeight + 111);\n" + " alert(window.innerWidth > 0);\n" + " alert(window.innerWidth == document.body.clientWidth);\n" + " alert(window.outerWidth == window.innerWidth + 8);\n" |
From: <rb...@us...> - 2013-05-26 13:21:07
|
Revision: 8305 http://sourceforge.net/p/htmlunit/code/8305 Author: rbri Date: 2013-05-26 13:21:04 +0000 (Sun, 26 May 2013) Log Message: ----------- try to fix the event sequence (not complete) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-05-26 07:47:17 UTC (rev 8304) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-05-26 13:21:04 UTC (rev 8305) @@ -1187,8 +1187,13 @@ mouseDown(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); // give focus to current element (if possible) or only remove it from previous one - final HtmlElement elementToFocus = (this instanceof SubmittableElement || this instanceof HtmlAnchor) - ? this : null; + HtmlElement elementToFocus = null; + if (this instanceof SubmittableElement || this instanceof HtmlAnchor) { + elementToFocus = this; + } + else if (this instanceof HtmlOption) { + elementToFocus = ((HtmlOption) this).getEnclosingSelect(); + } ((HtmlPage) page).setFocusedElement(elementToFocus); mouseUp(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInput2Test.java 2013-05-26 07:47:17 UTC (rev 8304) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlInput2Test.java 2013-05-26 13:21:04 UTC (rev 8305) @@ -14,12 +14,20 @@ */ package com.gargoylesoftware.htmlunit.html; +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; @@ -31,6 +39,7 @@ */ @RunWith(BrowserRunner.class) public final class HtmlInput2Test extends WebDriverTestCase { + private static final String TEST_ID = "clickId"; /** * @throws Exception if the test fails @@ -69,4 +78,138 @@ + "</body></html>"; loadPageWithAlerts2(html); } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "mousedown; onfocus; mouseup; onclick;", "" }) + public void clickButtonEventSequence() throws Exception { + testClickEventSequence("<input type='button' id='" + TEST_ID + "'>Check", false); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "mousedown; onfocus; mouseup; onclick;", "" }) + public void clickImageEventSequence() throws Exception { + testClickEventSequence("<input type='image' id='" + TEST_ID + "'>Check", true); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @BuggyWebDriver(Browser.IE) + @Alerts(DEFAULT = { "mousedown; onfocus; mouseup; onclick; onchange;", "" }, + IE = { "mousedown; onfocus; mouseup; onclick;", "onchange;" }) + public void clickCheckboxEventSequence() throws Exception { + testClickEventSequence("<input type='checkbox' id='" + TEST_ID + "'>Check", false); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "mousedown; onfocus; mouseup; onclick;", "" }) + public void clickPasswordEventSequence() throws Exception { + testClickEventSequence("<input type='password' id='" + TEST_ID + "'>Check", false); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @BuggyWebDriver(Browser.IE) + @Alerts(DEFAULT = { "mousedown; onfocus; mouseup; onclick; onchange;", "" }, + IE = { "mousedown; onfocus; mouseup; onclick;", "onchange;" }) + public void clickRadioEventSequence() throws Exception { + testClickEventSequence("<input type='radio' name='test' id='" + TEST_ID + "'>Check", false); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "mousedown; onfocus; mouseup; onclick;", "" }) + public void clickResetEventSequence() throws Exception { + testClickEventSequence("<input type='reset' id='" + TEST_ID + "'>Check", true); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "mousedown; onfocus; mouseup; onclick;", "" }) + public void clickTextEventSequence() throws Exception { + testClickEventSequence("<input type='text' id='" + TEST_ID + "'>Check", false); + } + + /** + * Test for the right event sequence when clicking. + * + * @throws Exception if the test fails + */ + @Test + @BuggyWebDriver +// @NotYetImplemented + @Alerts({ "mousedown; onfocus; mouseup; onchange; onclick;", "" }) + public void clickOptionEventSequence() throws Exception { + testClickEventSequence("<select size='2'><option id='" + TEST_ID + "'>1</option></select>", false); + } + + private void testClickEventSequence(final String input, final boolean onClickRetFalse) throws Exception { + final String events = " onmousedown=\"log('mousedown')\" onmouseup=\"log('mouseup')\" " + + "onfocus=\"log('onfocus')\" onchange=\"log('onchange')\" " + + "onclick=\"log('onclick')\""; + String tag = StringUtils.replaceOnce(input, ">", events + ">"); + if (onClickRetFalse) { + tag = StringUtils.replaceOnce(tag, "onclick')", "onclick');return false;"); + } + + final String html = "<html><head>\n" + + "<script>\n" + + " function log(x) {\n" + + " document.getElementById('log_').value += x + '; ';\n" + + " }\n" + + "</script>\n" + + + "</head>\n<body>\n" + + "<form>\n" + + " <textarea id='log_' rows='4' cols='50'></textarea>\n" + + tag + "\n" + + " <input type='text' id='next'>\n" + + "</form>\n" + + + "</body></html>"; + + final List<String> alerts = new LinkedList<String>(); + + final WebDriver driver = loadPage2(html); + final WebElement log = driver.findElement(By.id("log_")); + + driver.findElement(By.id(TEST_ID)).click(); + alerts.add(log.getAttribute("value").trim()); + + log.clear(); + driver.findElement(By.id("next")).click(); + + alerts.add(log.getAttribute("value").trim()); + assertEquals(getExpectedAlerts(), alerts); + } } |
From: <rb...@us...> - 2013-05-26 15:56:51
|
Revision: 8308 http://sourceforge.net/p/htmlunit/code/8308 Author: rbri Date: 2013-05-26 15:56:47 +0000 (Sun, 26 May 2013) Log Message: ----------- Basefont support removed from Firefox after 3.6. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-26 15:56:47 UTC (rev 8308) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + Basefont support removed from Firefox after 3.6. + </action> + <action type="fix" dev="rbri"> Adjust the window.outherHeight for the newer FF versions. </action> <action type="fix" dev="rbri" issue="1488"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -538,8 +538,11 @@ @BrowserFeature(@WebBrowser(value = IE, minVersion = 7)) HTMLABBREVIATED, - /** Should {@link com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement#isEndTagForbidden} - * return <code>true</code>. */ + /** Supports basefont. */ + @BrowserFeature({ @WebBrowser(IE), @WebBrowser(value = FF, maxVersion = 3.6f) }) + HTMLBASEFONT_SUPPORTED, + + /** Should {@link com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement#isEndTagForbidden}. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLBASEFONT_END_TAG_FORBIDDEN, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -16,6 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CANVAS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTML5_TAGS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_SUPPORTED; import java.util.Arrays; import java.util.LinkedHashMap; @@ -180,7 +181,12 @@ element = new HtmlBase(namespaceURI, qualifiedName, page, attributeMap); } else if (tagName.equals(HtmlBaseFont.TAG_NAME)) { - element = new HtmlBaseFont(namespaceURI, qualifiedName, page, attributeMap); + if (page.getWebClient().getBrowserVersion().hasFeature(HTMLBASEFONT_SUPPORTED)) { + element = new HtmlBaseFont(namespaceURI, qualifiedName, page, attributeMap); + } + else { + element = new HtmlSpan(namespaceURI, qualifiedName, page, attributeMap); + } } else if (tagName.equals(HtmlBidirectionalOverride.TAG_NAME)) { element = new HtmlBidirectionalOverride(namespaceURI, qualifiedName, page, attributeMap); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -42,6 +42,9 @@ HtmlBaseFont(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { super(namespaceURI, qualifiedName, page, attributes); + if (ATTRIBUTE_NOT_DEFINED == getSizeAttribute()) { + setAttribute("size", "3"); + } } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -15,12 +15,15 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_END_TAG_FORBIDDEN; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import net.sourceforge.htmlunit.corejs.javascript.Context; import com.gargoylesoftware.htmlunit.html.HtmlBaseFont; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; /** * The JavaScript object "HTMLBaseFontElement". @@ -28,7 +31,7 @@ * @version $Revision$ * @author Ahmed Ashour */ -@JsxClass(domClasses = HtmlBaseFont.class) +@JsxClass(domClasses = HtmlBaseFont.class, browsers = { @WebBrowser(IE), @WebBrowser(value = FF, maxVersion = 3.6f) }) public class HTMLBaseFontElement extends HTMLElement { /** Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HTMLBaseFontElement}. + * @version $Revision:$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HTMLBaseFontElementTest extends WebDriverTestCase { + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented(Browser.FF3_6) + @Alerts(DEFAULT = { "[object HTMLSpanElement]", "undefined", "undefined", "undefined" }, + FF3_6 = { "[object HTMLBaseFontElement]", "", "-1", "" }, + IE = { "[object]", "", "3", "" }) + public void defaults() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base);\n" + + " alert(base.face);\n" + + " alert(base.size);\n" + + " alert(base.color);\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17 }) + @Alerts(DEFAULT = { "undefined", "42" }, + FF3_6 = { "4", "42" }, + IE = { "4", "42" }) + public void size() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='4' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.size);\n" + + " try {\n" + + " base.size=42;\n" + + " alert(base.size);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17 }) + @Alerts(DEFAULT = { "undefined", "helvetica" }, + FF3_6 = { "swiss", "helvetica" }, + IE = { "swiss", "helvetica" }) + public void face() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='5' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.face);\n" + + " try {\n" + + " base.face='helvetica';\n" + + " alert(base.face);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17, Browser.IE }) + @Alerts(DEFAULT = { "undefined", "blue" }, + FF3_6 = { "red", "blue" }, + IE = { "#ff0000", "#0000ff" }) + public void color() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='4' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.color);\n" + + " try {\n" + + " base.color='blue';\n" + + " alert(base.color);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |
From: <rb...@us...> - 2013-05-26 20:13:00
|
Revision: 8311 http://sourceforge.net/p/htmlunit/code/8311 Author: rbri Date: 2013-05-26 20:12:57 +0000 (Sun, 26 May 2013) Log Message: ----------- fix event handling for IE Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-05-26 20:10:47 UTC (rev 8310) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-05-26 20:12:57 UTC (rev 8311) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ALIGN_FOR_INPUT_IGNORES_VALUES; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_CLICK_CHECKBOX_TRIGGERS_NO_CHANGE_EVENT; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; @@ -387,7 +388,9 @@ final boolean newState = domNode.isChecked(); if (originalState != newState - && (domNode instanceof HtmlCheckBoxInput || domNode instanceof HtmlRadioButtonInput)) { + && (domNode instanceof HtmlRadioButtonInput + || (domNode instanceof HtmlCheckBoxInput + && !getBrowserVersion().hasFeature(JS_CLICK_CHECKBOX_TRIGGERS_NO_CHANGE_EVENT)))) { domNode.fireEvent(Event.TYPE_CHANGE); } } 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-26 20:10:47 UTC (rev 8310) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-05-26 20:12:57 UTC (rev 8311) @@ -26,7 +26,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; @@ -799,7 +798,6 @@ */ @Test @Alerts(DEFAULT = "changed", IE = { }) - @NotYetImplemented(Browser.IE) public void clickShouldTriggerOnchange() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" |
From: <rb...@us...> - 2013-05-27 10:05:26
|
Revision: 8312 http://sourceforge.net/p/htmlunit/code/8312 Author: rbri Date: 2013-05-27 10:05:23 +0000 (Mon, 27 May 2013) Log Message: ----------- various hacks at the airport; feature naming, test fix, some NYI tests implemented Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -384,10 +384,6 @@ /** Was originally .isIE(). */ @BrowserFeature(@WebBrowser(IE)) - GENERATED_44, - - /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) GENERATED_45, /** Was originally .isIE(). */ @@ -752,6 +748,14 @@ @BrowserFeature(@WebBrowser(IE)) JS_BOUNDING_CLIENT_RECT_OFFSET_TWO, + /** Trying to change the type of a button element throws an exception (IE). */ + @BrowserFeature(@WebBrowser(IE)) + JS_BUTTON_SET_TYPE_THROWS_EXCEPTION, + + /** IE uses the content of a button tag as value instead of the attribute. */ + @BrowserFeature(@WebBrowser(IE)) + JS_BUTTON_USE_CONTENT_AS_VALUE, + /** Indicates that the browser emulates the char attribute. */ @BrowserFeature(@WebBrowser(IE)) JS_CHAR_EMULATED, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -14,7 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_44; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_BUTTON_SET_TYPE_THROWS_EXCEPTION; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_BUTTON_USE_CONTENT_AS_VALUE; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import java.io.IOException; @@ -36,6 +37,7 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass(domClasses = HtmlButton.class) public class HTMLButtonElement extends FormField { @@ -48,7 +50,7 @@ */ @JsxSetter public void setType(final String newType) { - if (getBrowserVersion().hasFeature(GENERATED_44)) { + if (getBrowserVersion().hasFeature(JS_BUTTON_SET_TYPE_THROWS_EXCEPTION)) { throw Context.reportRuntimeError("Object doesn't support this action"); } getDomNodeOrDie().setAttribute("type", newType); @@ -64,6 +66,30 @@ } /** + * {@inheritDoc} + */ + @Override + @JsxGetter + public String getValue() { + if (getBrowserVersion().hasFeature(JS_BUTTON_USE_CONTENT_AS_VALUE)) { + return getText(); + } + return super.getValue(); + } + + /** + * {@inheritDoc} + */ + @Override + @JsxSetter + public void setValue(final String newValue) { + if (getBrowserVersion().hasFeature(JS_BUTTON_USE_CONTENT_AS_VALUE)) { + setInnerText(newValue); + } + super.setValue(newValue); + } + + /** * {@inheritDoc} Overridden to modify browser configurations. */ @Override Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -34,7 +34,9 @@ * @throws Exception if the test fails */ @Test - @Alerts(FF = "[object HTMLBaseFontElement]", IE = "[object]") + @Alerts(DEFAULT = "[object HTMLSpanElement]", + FF3_6 = "[object HTMLBaseFontElement]", + IE = "[object]") public void simpleScriptable() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -47,6 +49,8 @@ + "</body></html>"; final HtmlPage page = loadPageWithAlerts(html); - assertTrue(HtmlBaseFont.class.isInstance(page.getHtmlElementById("myId"))); + if (getBrowserVersion().isIE()) { + assertTrue(HtmlBaseFont.class.isInstance(page.getHtmlElementById("myId"))); + } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -21,8 +21,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; -import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -68,7 +66,6 @@ @Test @Alerts(DEFAULT = { "-undefined", "-", "-" }, IE = { "OK-undefined", "-", "-" }) - @NotYetImplemented(Browser.IE) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -137,7 +134,6 @@ "newValue-newDefault", "newValue-newDefault" }, IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -179,7 +175,6 @@ "newValue-newDefault", "newValue-newDefault" }, IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void resetByJS() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -218,7 +213,6 @@ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }, IE8 = { "OK-undefined", "OK-default", "newValue-default", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -49,10 +49,12 @@ + " alert(document.getElementById('myId'));\n" + " }\n" + "</script>\n" - + "</head><body onload='test()'>\n" - + "<form id='form1' method='post'>\n" - + "<isindex id='myId' prompt='enterSomeText'></isindex>\n" - + "</form></body></html>"; + + "</head>\n" + + "<body onload='test()'>\n" + + " <form id='form1' method='post'>\n" + + " <isindex id='myId' prompt='enterSomeText'></isindex>\n" + + " </form>\n" + + "</body></html>"; final WebDriver driver = loadPageWithAlerts2(html); if (driver instanceof HtmlUnitDriver) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -48,16 +48,16 @@ IE = "exception") public void getComputedStyleOnChild() throws Exception { final String html = "<html><head><style>\n" - + "body > div { background-color: green#FF0000; }\n" + + " body > div { background-color: green#FF0000; }\n" + "</style></head>\n" + "<body>\n" + "<script>\n" - + "try {\n" - + " var frag = document.createDocumentFragment();\n" - + " var d = document.createElement('div');\n" - + " frag.appendChild(d);\n" - + " alert(window.getComputedStyle(d, null));\n" - + "} catch (e) { alert('exception'); }\n" + + " try {\n" + + " var frag = document.createDocumentFragment();\n" + + " var d = document.createElement('div');\n" + + " frag.appendChild(d);\n" + + " alert(window.getComputedStyle(d, null));\n" + + " } catch (e) { alert('exception'); }\n" + "</script>\n" + "</body>\n" + "</html>"; |
From: <rb...@us...> - 2013-05-27 21:33:57
|
Revision: 8314 http://sourceforge.net/p/htmlunit/code/8314 Author: rbri Date: 2013-05-27 21:33:52 +0000 (Mon, 27 May 2013) Log Message: ----------- fix test for IE8 Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 13:31:49 UTC (rev 8313) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 21:33:52 UTC (rev 8314) @@ -753,7 +753,7 @@ JS_BUTTON_SET_TYPE_THROWS_EXCEPTION, /** IE uses the content of a button tag as value instead of the attribute. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) JS_BUTTON_USE_CONTENT_AS_VALUE, /** Indicates that the browser emulates the char attribute. */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 13:31:49 UTC (rev 8313) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 21:33:52 UTC (rev 8314) @@ -21,6 +21,8 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -64,17 +66,15 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "-undefined", "-", "-" }, - IE = { "OK-undefined", "-", "-" }) + @Alerts(DEFAULT = { "-undefined", "-undefined", "-" }) public void defaultValues() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('button1');\n" + " alert(input.value + '-' + input.defaultValue);\n" - + " input = document.createElement('input');\n" - + " input.type = 'button';\n" + + " input = document.createElement('button');\n" + " alert(input.value + '-' + input.defaultValue);\n" + " var builder = document.createElement('div');\n" @@ -98,7 +98,7 @@ @Test @Alerts({ "-undefined", "-", "-" }) public void defaultValuesAfterClone() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('button1');\n" @@ -131,11 +131,9 @@ */ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-undefined", "newValue-undefined", "newValue-undefined", - "newValue-newDefault", "newValue-newDefault" }, - IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) public void resetByClick() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -172,11 +170,9 @@ */ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-undefined", "newValue-undefined", "newValue-undefined", - "newValue-newDefault", "newValue-newDefault" }, - IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) public void resetByJS() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -211,10 +207,9 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }, - IE8 = { "OK-undefined", "OK-default", "newValue-default", "newValue-newDefault" }) + @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }) public void defaultValue() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -237,4 +232,92 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-OK", "newValue-OK", "newValue-OK" }) + public void innerHtml() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + + " button.value = 'newValue';\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + + " button.innerHtml = 'Cancel';\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-undefined", "newValue-undefined", "newValue-Cancel" }, + IE8 = { "initial-OK", "newValue-OK", "newValue-Cancel" }) + public void innerText() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.innerText);\n" + + + " button.value = 'newValue';\n" + + " alert(button.value + '-' + button.innerText);\n" + + + " button.innerText = 'Cancel';\n" + + " alert(button.value + '-' + button.innerText);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @NotYetImplemented(Browser.IE8) + @Alerts(DEFAULT = { "initial-initial-OK", "newValue-newValue-OK", "newValue-newValue-OK" }, + IE8 = { "initial-initial-OK", "newValue--OK", "newValue--OK" }) + public void valueAttributeNode() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " var attr = button.getAttributeNode('value');\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + + " attr.value = 'newValue';\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + + " button.innerHtml = 'Cancel';\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2013-06-01 18:45:00
|
Revision: 8317 http://sourceforge.net/p/htmlunit/code/8317 Author: rbri Date: 2013-06-01 18:44:57 +0000 (Sat, 01 Jun 2013) Log Message: ----------- Textarea cols() and rows() property processing fixed. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-06-01 14:28:20 UTC (rev 8316) +++ trunk/htmlunit/src/changes/changes.xml 2013-06-01 18:44:57 UTC (rev 8317) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + Textarea cols() and rows() property processing fixed. + </action> + <action type="fix" dev="rbri"> Basefont support removed from Firefox after 3.6. </action> <action type="fix" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-06-01 14:28:20 UTC (rev 8316) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-06-01 18:44:57 UTC (rev 8317) @@ -1105,27 +1105,41 @@ /** Getting the property cols returns 20, if the defined value is not convertible into an integer (IE). * FF returns -1 in this case. */ - @BrowserFeature(@WebBrowser(IE)) - JS_TEXT_AREA_COLS_RETURNS_20, + @BrowserFeature(@WebBrowser(value = FF, maxVersion = 3.6f)) + JS_TEXT_AREA_COLS_RETURNS_MINUS1, /** Getting the property rows returns 2, if the defined value is not convertible into an integer (IE). * FF returns -1 in this case. */ + @BrowserFeature(@WebBrowser(value = FF, maxVersion = 3.6f)) + JS_TEXT_AREA_ROWS_RETURNS_MINUS1, + + /** Setting the property cols throws an exception, if the provided value is less + * than 0 (IE). + * FF ignores the provided value in this case. + */ @BrowserFeature(@WebBrowser(IE)) - JS_TEXT_AREA_ROWS_RETURNS_2, + JS_TEXT_AREA_SET_COLS_NEGATIVE_THROWS_EXCEPTION, /** Setting the property cols throws an exception, if the provided value is not * convertible into an integer (IE). * FF ignores the provided value in this case and sets cols to 0. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature({ @WebBrowser(IE), @WebBrowser(value = FF, minVersion = 10) }) JS_TEXT_AREA_SET_COLS_THROWS_EXCEPTION, + /** Setting the property rows throws an exception, if the provided value is less + * than 0 (IE). + * FF ignores the provided value in this case. + */ + @BrowserFeature(@WebBrowser(IE)) + JS_TEXT_AREA_SET_ROWS_NEGATIVE_THROWS_EXCEPTION, + /** Setting the property rows throws an exception, if the provided value is not * convertible into an integer (IE). * FF ignores the provided value in this case and sets rows to 0. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature({ @WebBrowser(IE), @WebBrowser(value = FF, minVersion = 10) }) JS_TEXT_AREA_SET_ROWS_THROWS_EXCEPTION, /** It looks likes TreeWalker.expandEntityReferences is always <code>false</code> for FF17. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElement.java 2013-06-01 14:28:20 UTC (rev 8316) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElement.java 2013-06-01 18:44:57 UTC (rev 8317) @@ -14,9 +14,11 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_COLS_RETURNS_20; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_ROWS_RETURNS_2; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_COLS_RETURNS_MINUS1; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_ROWS_RETURNS_MINUS1; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_SET_COLS_NEGATIVE_THROWS_EXCEPTION; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_SET_COLS_THROWS_EXCEPTION; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_SET_ROWS_NEGATIVE_THROWS_EXCEPTION; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TEXT_AREA_SET_ROWS_THROWS_EXCEPTION; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.TEXTAREA_CRNL; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; @@ -91,10 +93,10 @@ return Integer.parseInt(s); } catch (final NumberFormatException e) { - if (getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_20)) { - return 20; + if (getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_MINUS1)) { + return -1; } - return -1; + return 20; } } @@ -108,13 +110,21 @@ try { i = Float.valueOf(cols).intValue(); if (i < 0) { - throw new NumberFormatException("New value for cols '" + cols + "' is smaller than zero."); + if (getBrowserVersion().hasFeature(JS_TEXT_AREA_SET_COLS_NEGATIVE_THROWS_EXCEPTION) + || getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_MINUS1)) { + throw new NumberFormatException("New value for cols '" + cols + "' is smaller than zero."); + } + getDomNodeOrDie().setAttribute("cols", null); + return; } } catch (final NumberFormatException e) { if (getBrowserVersion().hasFeature(JS_TEXT_AREA_SET_COLS_THROWS_EXCEPTION)) { throw Context.throwAsScriptRuntimeEx(e); } + if (!getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_MINUS1)) { + return; + } i = 0; } getDomNodeOrDie().setAttribute("cols", Integer.toString(i)); @@ -131,10 +141,10 @@ return Integer.parseInt(s); } catch (final NumberFormatException e) { - if (getBrowserVersion().hasFeature(JS_TEXT_AREA_ROWS_RETURNS_2)) { - return 2; + if (getBrowserVersion().hasFeature(JS_TEXT_AREA_ROWS_RETURNS_MINUS1)) { + return -1; } - return -1; + return 2; } } @@ -148,13 +158,21 @@ try { i = new Float(rows).intValue(); if (i < 0) { - throw new NumberFormatException("New value for rows '" + rows + "' is smaller than zero."); + if (getBrowserVersion().hasFeature(JS_TEXT_AREA_SET_ROWS_NEGATIVE_THROWS_EXCEPTION) + || getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_MINUS1)) { + throw new NumberFormatException("New value for rows '" + rows + "' is smaller than zero."); + } + getDomNodeOrDie().setAttribute("rows", null); + return; } } catch (final NumberFormatException e) { if (getBrowserVersion().hasFeature(JS_TEXT_AREA_SET_ROWS_THROWS_EXCEPTION)) { throw Context.throwAsScriptRuntimeEx(e); } + if (!getBrowserVersion().hasFeature(JS_TEXT_AREA_COLS_RETURNS_MINUS1)) { + return; + } i = 0; } getDomNodeOrDie().setAttribute("rows", Integer.toString(i)); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElementTest.java 2013-06-01 14:28:20 UTC (rev 8316) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTextAreaElementTest.java 2013-06-01 18:44:57 UTC (rev 8317) @@ -37,6 +37,7 @@ * @author Marc Guillemot * @author Ahmed Ashour * @author Daniel Gredler + * @author Ronald Brill */ @RunWith(BrowserRunner.class) public class HTMLTextAreaElementTest extends WebDriverTestCase { @@ -48,17 +49,22 @@ @Alerts({ "1234", "PoohBear" }) public void getValue() throws Exception { final String html - = "<html><head><title>foo</title><script>\n" - + "function doTest(){\n" - + "alert(document.form1.textarea1.value)\n" - + "document.form1.textarea1.value='PoohBear';\n" - + "alert(document.form1.textarea1.value )\n" - + "}\n" - + "</script></head><body onload='doTest()'>\n" - + "<p>hello world</p>\n" - + "<form name='form1' method='post' >\n" - + "<textarea name='textarea1' cols='45' rows='4'>1234</textarea>\n" - + "</form></body></html>"; + = "<html>\n" + + "<head><title>foo</title>\n" + + " <script>\n" + + " function doTest(){\n" + + " alert(document.form1.textarea1.value)\n" + + " document.form1.textarea1.value='PoohBear';\n" + + " alert(document.form1.textarea1.value )\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='doTest()'>\n" + + " <p>hello world</p>\n" + + " <form name='form1' method='post' >\n" + + " <textarea name='textarea1' cols='45' rows='4'>1234</textarea>\n" + + " </form>\n" + + "</body></html>"; loadPageWithAlerts2(html); } @@ -69,13 +75,15 @@ @Test @Alerts("foo") public void onChange() throws Exception { - final String html = "<html><head><title>foo</title>\n" - + "</head><body>\n" - + "<p>hello world</p>\n" - + "<form name='form1'>\n" - + " <textarea name='textarea1' onchange='alert(this.value)'></textarea>\n" - + "<input name='myButton' type='button' onclick='document.form1.textarea1.value=\"from button\"'>\n" - + "</form>\n" + final String html + = "<html>\n" + + "<head><title>foo</title></head>\n" + + "<body>\n" + + " <p>hello world</p>\n" + + " <form name='form1'>\n" + + " <textarea name='textarea1' onchange='alert(this.value)'></textarea>\n" + + " <input name='myButton' type='button' onclick='document.form1.textarea1.value=\"from button\"'>\n" + + " </form>\n" + "</body></html>"; final WebDriver driver = loadPage2(html); @@ -94,21 +102,23 @@ @Test @Alerts({ "TEXTAREA", "INPUT" }) public void setValue() throws Exception { - final String content = "<html><head></head>\n" + final String html + = "<html>\n" + + "<head><title>foo</title></head>\n" + "<body>\n" - + "<form name='form1'>\n" - + "<textarea name='question'></textarea>\n" - + "<input type='button' name='btn_submit' value='Next'>\n" - + "</form>\n" - + "<script>\n" - + "document.form1.question.value = 'some text';\n" - + "alert(document.form1.elements[0].tagName);\n" - + "alert(document.form1.elements[1].tagName);\n" - + "</script>\n" + + " <form name='form1'>\n" + + " <textarea name='question'></textarea>\n" + + " <input type='button' name='btn_submit' value='Next'>\n" + + " </form>\n" + + " <script>\n" + + " document.form1.question.value = 'some text';\n" + + " alert(document.form1.elements[0].tagName);\n" + + " alert(document.form1.elements[1].tagName);\n" + + " </script>\n" + "</body>\n" + "</html>"; - loadPageWithAlerts2(content); + loadPageWithAlerts2(html); } /** @@ -118,20 +128,22 @@ @Alerts(IE = {"undefined", "undefined" }, FF = {"11", "0" }) public void textLength() throws Exception { - final String content = "<html>\n" + final String html + = "<html>\n" + + "<head><title>foo</title></head>\n" + "<body>\n" - + "<textarea id='myTextArea'></textarea>\n" - + "<script>\n" + + " <textarea id='myTextArea'></textarea>\n" + + " <script>\n" + " var textarea = document.getElementById('myTextArea');\n" + " textarea.value = 'hello there';\n" + " alert(textarea.textLength);\n" + " textarea.value = '';\n" + " alert(textarea.textLength);\n" - + "</script>\n" + + " </script>\n" + "</body>\n" + "</html>"; - loadPageWithAlerts2(content); + loadPageWithAlerts2(html); } /** @@ -172,10 +184,12 @@ } private void selection(final int selectionStart, final int selectionEnd) throws Exception { - final String html = "<html>\n" + final String html + = "<html>\n" + + "<head><title>foo</title></head>\n" + "<body>\n" - + "<textarea id='myTextArea'></textarea>\n" - + "<script>\n" + + " <textarea id='myTextArea'></textarea>\n" + + " <script>\n" + " var textarea = document.getElementById('myTextArea');\n" + " textarea.value = 'Hello there';\n" + " alert(textarea.selectionStart + ',' + textarea.selectionEnd);\n" @@ -183,7 +197,7 @@ + " alert(textarea.selectionStart + ',' + textarea.selectionEnd);\n" + " textarea.selectionEnd = " + selectionEnd + ";\n" + " alert(textarea.selectionStart + ',' + textarea.selectionEnd);\n" - + "</script>\n" + + " </script>\n" + "</body>\n" + "</html>"; @@ -239,15 +253,20 @@ private void value(final String textAreaBody) throws Exception { final String html - = "<html><head><title>foo</title><script>\n" - + "function doTest(){\n" - + " alert(document.form1.textarea1.value)\n" - + "}\n" - + "</script></head><body onload='doTest()'>\n" - + "<form name='form1' method='post' >\n" - + "<textarea name='textarea1'>" + textAreaBody + "</textarea>\n" - + "</textarea>\n" - + "</form></body></html>"; + = "<html>\n" + + "<head><title>foo</title>\n" + + " <script>\n" + + " function doTest(){\n" + + " alert(document.form1.textarea1.value);\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='doTest()'>\n" + + " <form name='form1' method='post' >\n" + + " <textarea name='textarea1'>" + textAreaBody + "</textarea>\n" + + " </textarea>\n" + + " </form>\n" + + "</body></html>"; loadPageWithAlerts2(html); } @@ -282,7 +301,8 @@ @Test @Alerts({ "true", "false" }) public void readOnly() throws Exception { - final String html = "<html><head>\n" + final String html + = "<html><head>\n" + "<script>\n" + " function test() {\n" + " var t = document.getElementById('textArea');\n" @@ -331,35 +351,49 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF3_6 = { "-1", "5", "8", "2", "0", "0", "0", "3" }, - FF = { "20", "5", "8", "2", "error", "error", "8", "2", "20", "3" }, - IE = { "20", "5", "8", "2", "error", "error", "8", "2", "error", "8", "3" }) - @NotYetImplemented(Browser.FF17) + @Alerts(FF3_6 = { "-1", "5", "8", "4", "0", "0", "0", "3" }, + FF = { "20", "5", "8", "4", "error", "4", "error", "4", "20", "3" }, + IE = { "20", "5", "8", "4", "error", "4", "error", "4", "error", "4", "3" }) public void cols() throws Exception { final String html - = "<html><body><textarea id='a1'>a1</textarea><textarea id='a2' cols='5'>a2</textarea><script>\n" - + " function set(e, value) {\n" + = "<html><head>\n" + + "<script>\n" + + " function setCols(e, value) {\n" + " try {\n" + " e.cols = value;\n" + " } catch (e) {\n" + " alert('error');\n" + " }\n" + " }\n" - + " var a1 = document.getElementById('a1'), a2 = document.getElementById('a2');\n" - + " alert(a1.cols);\n" - + " alert(a2.cols);\n" - + " set(a1, '8');\n" - + " set(a2, 2);\n" - + " alert(a1.cols);\n" - + " alert(a2.cols);\n" - + " set(a1, 'a');\n" - + " set(a2, '');\n" - + " alert(a1.cols);\n" - + " alert(a2.cols);\n" - + " set(a1, -1);\n" - + " set(a2, 3.4);\n" - + " alert(a1.cols);\n" - + " alert(a2.cols);\n" + + "</script>\n" + + "</head>\n" + + + "<body>\n" + + " <textarea id='a1'>a1</textarea>\n" + + " <textarea id='a2' cols='5'>a2</textarea>\n" + + + " <script>\n" + + " var a1 = document.getElementById('a1'), a2 = document.getElementById('a2');\n" + + " alert(a1.cols);\n" + + " alert(a2.cols);\n" + + + " setCols(a1, '8');\n" + + " alert(a1.cols);\n" + + + " setCols(a1, 4);\n" + + " alert(a1.cols);\n" + + + " setCols(a1, 'a');\n" + + " alert(a1.cols);\n" + + + " setCols(a1, '');\n" + + " alert(a1.cols);\n" + + + " setCols(a1, -1);\n" + + " alert(a1.cols);\n" + + + " setCols(a1, 3.4);\n" + + " alert(a1.cols);\n" + "</script></body></html>"; loadPageWithAlerts2(html); } @@ -368,36 +402,51 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF3_6 = { "-1", "5", "8", "2", "0", "0", "0", "3" }, - FF = { "2", "5", "8", "2", "error", "error", "8", "2", "2", "3" }, - IE = { "2", "5", "8", "2", "error", "error", "8", "2", "error", "8", "3" }) - @NotYetImplemented(Browser.FF17) + @Alerts(FF3_6 = { "-1", "5", "8", "4", "0", "0", "0", "3" }, + FF = { "2", "5", "8", "4", "error", "4", "error", "4", "2", "3" }, + IE = { "2", "5", "8", "4", "error", "4", "error", "4", "error", "4", "3" }) public void rows() throws Exception { final String html - = "<html><body><textarea id='a1'>a1</textarea><textarea id='a2' rows='5'>a2</textarea><script>\n" - + " function set(e, value) {\n" + = "<html><head>\n" + + "<script>\n" + + " function setRows(e, value) {\n" + " try {\n" + " e.rows = value;\n" + " } catch (e) {\n" + " alert('error');\n" + " }\n" + " }\n" - + " var a1 = document.getElementById('a1'), a2 = document.getElementById('a2');\n" - + " alert(a1.rows);\n" - + " alert(a2.rows);\n" - + " set(a1, '8');\n" - + " set(a2, 2);\n" - + " alert(a1.rows);\n" - + " alert(a2.rows);\n" - + " set(a1, 'a');\n" - + " set(a2, '');\n" - + " alert(a1.rows);\n" - + " alert(a2.rows);\n" - + " set(a1, -1);\n" - + " set(a2, 3.4);\n" - + " alert(a1.rows);\n" - + " alert(a2.rows);\n" - + "</script></body></html>"; + + "</script>\n" + + "</head>\n" + + + "<body>\n" + + " <textarea id='a1'>a1</textarea>\n" + + " <textarea id='a2' rows='5'>a2</textarea>\n" + + + " <script>\n" + + " var a1 = document.getElementById('a1'), a2 = document.getElementById('a2');\n" + + " alert(a1.rows);\n" + + " alert(a2.rows);\n" + + + " setRows(a1, '8');\n" + + " alert(a1.rows);\n" + + + " setRows(a1, 4);\n" + + " alert(a1.rows);\n" + + + " setRows(a1, 'a');\n" + + " alert(a1.rows);\n" + + + " setRows(a1, '');\n" + + " alert(a1.rows);\n" + + + " setRows(a1, -1);\n" + + " alert(a1.rows);\n" + + + " setRows(a1, 3.4);\n" + + " alert(a1.rows);\n" + + " </script>\n" + + "</body></html>"; loadPageWithAlerts2(html); } @@ -409,18 +458,22 @@ @Alerts({ "9", "9", "2", "7" }) public void selectionRange() throws Exception { final String html - = "<html><head><title>foo</title><script>\n" - + "function test() {\n" - + " var ta = document.getElementById('myInput');\n" - + " ta.setSelectionRange(15, 15);\n" - + " alert(ta.selectionStart);" - + " alert(ta.selectionEnd);" - + " ta.setSelectionRange(2, 7);\n" - + " alert(ta.selectionStart);" - + " alert(ta.selectionEnd);" - + "}\n" - + "</script></head><body onload='test()'>\n" - + "<textarea id='myInput'>some test</textarea>\n" + = "<html>\n" + + "<head><title>foo</title>\n" + + " <script>\n" + + " function test() {\n" + + " var ta = document.getElementById('myInput');\n" + + " ta.setSelectionRange(15, 15);\n" + + " alert(ta.selectionStart);" + + " alert(ta.selectionEnd);" + + " ta.setSelectionRange(2, 7);\n" + + " alert(ta.selectionStart);" + + " alert(ta.selectionEnd);" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='myInput'>some test</textarea>\n" + "</body></html>"; loadPageWithAlerts2(html); @@ -435,7 +488,7 @@ public void getAttributeAndSetValue() throws Exception { final String html = "<html>\n" - + " <head>\n" + + " <head><title>foo</title>\n" + " <script>\n" + " function test() {\n" + " var t = document.getElementById('t');\n" |
From: <mgu...@us...> - 2013-06-04 07:09:24
|
Revision: 8321 http://sourceforge.net/p/htmlunit/code/8321 Author: mguillem Date: 2013-06-04 07:09:15 +0000 (Tue, 04 Jun 2013) Log Message: ----------- dispatching submit event on HTMLForm should trigger submit listeners Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java 2013-06-02 12:29:50 UTC (rev 8320) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java 2013-06-04 07:09:15 UTC (rev 8321) @@ -474,10 +474,11 @@ @Override public boolean dispatchEvent(final Event event) { + final boolean result = super.dispatchEvent(event); + if (event.getType().equals(Event.TYPE_SUBMIT)) { submit(); - return true; } - return super.dispatchEvent(event); + return result; } } 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-06-02 12:29:50 UTC (rev 8320) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElementTest.java 2013-06-04 07:09:15 UTC (rev 8321) @@ -1109,4 +1109,33 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "in listener", "page2 loaded" }, IE = "exception") + public void dispatchEventSubmitTriggersHandlers() throws Exception { + // use an iframe to capture alerts among 2 pages + final String container = "<html><body><iframe src='page1'></iframe></body></html>\n"; + final String page1 = "<html><body>\n" + + "<form action='page2' id='theForm'><span id='foo'/></form>\n" + + "<script>\n" + + "function listener(e) {\n" + + " alert('in listener');\n" + + "}\n" + + "try {\n" + + " document.forms[0].addEventListener('submit', listener, true);\n" + + " var e = document.createEvent('HTMLEvents');\n" + + " e.initEvent('submit', true, false);\n" + + " document.getElementById('theForm').dispatchEvent(e);\n" + + "} catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + + final String page2 = "<html><body><script>alert('page2 loaded');</script></body></html>"; + + getMockWebConnection().setResponse(new URL(getDefaultUrl() + "page1"), page1); + getMockWebConnection().setResponse(new URL(getDefaultUrl() + "page2"), page2); + loadPageWithAlerts2(container); + } } |
From: <mgu...@us...> - 2013-06-12 14:00:30
|
Revision: 8334 http://sourceforge.net/p/htmlunit/code/8334 Author: mguillem Date: 2013-06-12 14:00:27 +0000 (Wed, 12 Jun 2013) Log Message: ----------- waitForBackgroundJavaScript: handle ugly case where the frame window with the background job is closed due to the job Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientWaitForBackgroundJobsTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-06-11 16:28:05 UTC (rev 8333) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-06-12 14:00:27 UTC (rev 8334) @@ -66,6 +66,7 @@ import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; import com.gargoylesoftware.htmlunit.javascript.JavaScriptErrorListener; import com.gargoylesoftware.htmlunit.javascript.ProxyAutoConfig; +import com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManager; import com.gargoylesoftware.htmlunit.javascript.host.Event; import com.gargoylesoftware.htmlunit.javascript.host.Location; import com.gargoylesoftware.htmlunit.javascript.host.Node; @@ -146,6 +147,8 @@ private final Set<WebWindowListener> webWindowListeners_ = new HashSet<WebWindowListener>(5); private final Stack<TopLevelWindow> topLevelWindows_ = new Stack<TopLevelWindow>(); // top-level windows private final List<WebWindow> windows_ = Collections.synchronizedList(new ArrayList<WebWindow>()); // all windows + private transient List<WeakReference<JavaScriptJobManager>> jobManagers_ = + Collections.synchronizedList(new ArrayList<WeakReference<JavaScriptJobManager>>()); private WebWindow currentWindow_; private HTMLParserListener htmlParserListener_; @@ -1004,6 +1007,8 @@ public void registerWebWindow(final WebWindow webWindow) { WebAssert.notNull("webWindow", webWindow); windows_.add(webWindow); + // register JobManager here but don't deregister in deregisterWebWindow as it can live longer + jobManagers_.add(new WeakReference<JavaScriptJobManager>(webWindow.getJobManager())); } /** @@ -1736,18 +1741,25 @@ public int waitForBackgroundJavaScript(final long timeoutMillis) { int count = 0; final long endTime = System.currentTimeMillis() + timeoutMillis; - for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { - final WebWindow window; + for (Iterator<WeakReference<JavaScriptJobManager>> i = jobManagers_.iterator(); i.hasNext();) { + final JavaScriptJobManager jobManager; + final WeakReference<JavaScriptJobManager> reference; try { - window = i.next(); + reference = i.next(); + jobManager = reference.get(); + if (jobManager == null) { + i.remove(); + continue; + } } catch (final ConcurrentModificationException e) { - i = windows_.iterator(); + i = jobManagers_.iterator(); count = 0; continue; } + final long newTimeout = endTime - System.currentTimeMillis(); - count += window.getJobManager().waitForJobs(newTimeout); + count += jobManager.waitForJobs(newTimeout); } if (count != getAggregateJobCount()) { final long newTimeout = endTime - System.currentTimeMillis(); @@ -1783,18 +1795,24 @@ public int waitForBackgroundJavaScriptStartingBefore(final long delayMillis) { int count = 0; final long endTime = System.currentTimeMillis() + delayMillis; - for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { - final WebWindow window; + for (Iterator<WeakReference<JavaScriptJobManager>> i = jobManagers_.iterator(); i.hasNext();) { + final JavaScriptJobManager jobManager; + final WeakReference<JavaScriptJobManager> reference; try { - window = i.next(); + reference = i.next(); + jobManager = reference.get(); + if (jobManager == null) { + i.remove(); + continue; + } } catch (final ConcurrentModificationException e) { - i = windows_.iterator(); + i = jobManagers_.iterator(); count = 0; continue; } final long newDelay = endTime - System.currentTimeMillis(); - count += window.getJobManager().waitForJobsStartingBefore(newDelay); + count += jobManager.waitForJobsStartingBefore(newDelay); } if (count != getAggregateJobCount()) { final long newDelay = endTime - System.currentTimeMillis(); @@ -1809,17 +1827,24 @@ */ private int getAggregateJobCount() { int count = 0; - for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { - final WebWindow window; + for (Iterator<WeakReference<JavaScriptJobManager>> i = jobManagers_.iterator(); i.hasNext();) { + final JavaScriptJobManager jobManager; + final WeakReference<JavaScriptJobManager> reference; try { - window = i.next(); + reference = i.next(); + jobManager = reference.get(); + if (jobManager == null) { + i.remove(); + continue; + } } catch (final ConcurrentModificationException e) { - i = windows_.iterator(); + i = jobManagers_.iterator(); count = 0; continue; } - count += window.getJobManager().getJobCount(); + final int jobCount = jobManager.getJobCount(); + count += jobCount; } return count; } @@ -1831,6 +1856,7 @@ in.defaultReadObject(); webConnection_ = createWebConnection(); scriptEngine_ = new JavaScriptEngine(this); + jobManagers_ = Collections.synchronizedList(new ArrayList<WeakReference<JavaScriptJobManager>>()); } private WebConnection createWebConnection() { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientWaitForBackgroundJobsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientWaitForBackgroundJobsTest.java 2013-06-11 16:28:05 UTC (rev 8333) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClientWaitForBackgroundJobsTest.java 2013-06-12 14:00:27 UTC (rev 8334) @@ -17,6 +17,7 @@ import static org.junit.Assert.assertNotNull; import java.io.IOException; +import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -547,6 +548,62 @@ noOfJobs = client.waitForBackgroundJavaScriptStartingBefore(500); assertTrue(noOfJobs == 1 || noOfJobs == 2); // maybe one is running } + + /** + * Methods waitForBackgroundJavaScript[StartingBefore] should not look for running jobs only on the existing + * windows but as well on the ones that have been (freshly) closed. + * This test shows the case where a background job in a frame causes the window of this frame to be unregistered + * by the WebClient but this job should still be considered until it completes. + * @throws Exception if the test fails + */ + @Test + public void jobsFromAClosedWindowShouldntBeIgnore() throws Exception { + final String html = "<html><head><title>page 1</title></head>\n" + + "<body>\n" + + "<iframe src='iframe.html'></iframe>\n" + + "</body></html>"; + + final String iframe = "<html><body>\n" + + "<script>\n" + + "setTimeout(function() { parent.location = '/page3.html'; }, 50);\n" + + "</script>\n" + + "</body></html>"; + final String page3 = "<html><body><script>\n" + + "parent.location = '/delayedPage4.html';\n" + + "</script></body></html>"; + + final WebClient client = getWebClient(); + + final ThreadSynchronizer threadSynchronizer = new ThreadSynchronizer(); + + final MockWebConnection webConnection = new MockWebConnection() { + @Override + public WebResponse getResponse(final WebRequest request) throws IOException { + if (request.getUrl().toExternalForm().endsWith("/delayedPage4.html")) { + threadSynchronizer.setState("/delayedPage4.html requested"); + threadSynchronizer.waitForState("ready to call waitForBGJS"); + threadSynchronizer.sleep(1000); + } + return super.getResponse(request); + } + }; + + webConnection.setDefaultResponse(html); + webConnection.setResponse(new URL(getDefaultUrl(), "iframe.html"), iframe); + webConnection.setResponse(new URL(getDefaultUrl(), "page3.html"), page3); + webConnection.setResponseAsGenericHtml(new URL(getDefaultUrl(), "delayedPage4.html"), "page 4"); + client.setWebConnection(webConnection); + + client.getPage(getDefaultUrl()); + + threadSynchronizer.waitForState("/delayedPage4.html requested"); + threadSynchronizer.setState("ready to call waitForBGJS"); + final int noOfJobs = client.waitForBackgroundJavaScriptStartingBefore(500); + assertEquals(0, noOfJobs); + + final HtmlPage page = (HtmlPage) client.getCurrentWindow().getEnclosedPage(); + assertEquals("page 4", page.getTitleText()); + } } /** |
From: <rb...@us...> - 2013-06-14 20:24:06
|
Revision: 8344 http://sourceforge.net/p/htmlunit/code/8344 Author: rbri Date: 2013-06-14 20:24:02 +0000 (Fri, 14 Jun 2013) Log Message: ----------- use english as locale for upper/lowecase conversion instead of the default one to reduce the environment dependencies Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultPageCreator.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/FormEncodingType.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlMeta.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/InputElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/xpath/XPathAdapter.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/ProxyAutoConfig.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ActiveXObject.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Console.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventListenersContainer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleRule.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/EncodingSniffer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/MimeType.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/StringUtils.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/xml/XmlUtil.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/HttpWebConnection2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/UrlFetchWebConnectionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/AttributesTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/BaseFrameElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultPageCreator.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultPageCreator.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/DefaultPageCreator.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -147,7 +147,7 @@ * @return the new page object */ public Page createPage(final WebResponse webResponse, final WebWindow webWindow) throws IOException { - final String contentType = determineContentType(webResponse.getContentType().toLowerCase(), + final String contentType = determineContentType(webResponse.getContentType().toLowerCase(Locale.ENGLISH), webResponse.getContentAsStream()); final PageType pageType = determinePageType(contentType); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/FormEncodingType.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/FormEncodingType.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/FormEncodingType.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit; import java.io.Serializable; +import java.util.Locale; /** * A collection of constants that represent the various ways a form can be encoded when submitted. @@ -53,7 +54,7 @@ * @return the constant corresponding to the specified name, {@link #URL_ENCODED} if none match. */ public static FormEncodingType getInstance(final String name) { - final String lowerCaseName = name.toLowerCase(); + final String lowerCaseName = name.toLowerCase(Locale.ENGLISH); if (MULTIPART.getName().equals(lowerCaseName)) { return MULTIPART; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -21,6 +21,7 @@ import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import org.xml.sax.Attributes; @@ -130,10 +131,10 @@ final String tagName; final int colonIndex = qualifiedName.indexOf(':'); if (colonIndex == -1) { - tagName = qualifiedName.toLowerCase(); + tagName = qualifiedName.toLowerCase(Locale.ENGLISH); } else { - tagName = qualifiedName.substring(colonIndex + 1).toLowerCase(); + tagName = qualifiedName.substring(colonIndex + 1).toLowerCase(Locale.ENGLISH); } // final Class<? extends HtmlElement> klass = JavaScriptConfiguration.getHtmlTagNameMapping().get(tagName); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -22,6 +22,7 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; @@ -623,7 +624,7 @@ if (caseSensitive_) { return name; } - return name.toLowerCase(); + return name.toLowerCase(Locale.ENGLISH); } /** @@ -682,10 +683,11 @@ */ public DomAttr put(final String key, final DomAttr value) { final String name = fixName(key); - if (!map_.containsKey(name)) { + final DomAttr previous = map_.put(name, value); + if (null == previous) { attrPositions_.add(name); } - return map_.put(name, value); + return previous; } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNamespaceNode.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.html; +import java.util.Locale; + import com.gargoylesoftware.htmlunit.SgmlPage; import com.gargoylesoftware.htmlunit.WebAssert; import com.gargoylesoftware.htmlunit.html.xpath.XPathUtils; @@ -73,7 +75,7 @@ public String getLocalName() { final boolean caseSensitive = getPage().hasCaseSensitiveTagNames(); if (!caseSensitive && XPathUtils.isProcessingXPath()) { // and this method was called from Xalan - return localName_.toLowerCase(); + return localName_.toLowerCase(Locale.ENGLISH); } return localName_; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Stack; @@ -359,7 +360,7 @@ tagName = tagName.substring(index + 1); } else { - tagName = tagName.toLowerCase(); + tagName = tagName.toLowerCase(Locale.ENGLISH); } final ElementFactory factory = ELEMENT_FACTORIES.get(tagName); @@ -498,7 +499,7 @@ handleCharacters(); - final String tagLower = localName.toLowerCase(); + final String tagLower = localName.toLowerCase(Locale.ENGLISH); if (page_.isParsingHtmlSnippet() && ("html".equals(tagLower) || "body".equals(tagLower))) { return; } @@ -641,7 +642,7 @@ handleCharacters(); - final String tagLower = localName.toLowerCase(); + final String tagLower = localName.toLowerCase(Locale.ENGLISH); if (page_.isParsingHtmlSnippet() && ("html".equals(tagLower) || "body".equals(tagLower))) { return; @@ -869,7 +870,7 @@ // add the attributes that don't already exist final int length = attrs.getLength(); for (int i = 0; i < length; ++i) { - final String attrName = attrs.getLocalName(i).toLowerCase(); + final String attrName = attrs.getLocalName(i).toLowerCase(Locale.ENGLISH); if (body_.getAttributes().getNamedItem(attrName) == null) { body_.setAttribute(attrName, attrs.getValue(i)); if (attrName.startsWith("on") && body_.getScriptObject() != null) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlArea.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -20,6 +20,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.util.Locale; import java.util.Map; import org.apache.commons.lang3.StringUtils; @@ -210,7 +211,7 @@ * @return <code>true</code> if the point is contained in this area */ boolean containsPoint(final int x, final int y) { - final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), "rect").toLowerCase(); + final String shape = StringUtils.defaultIfEmpty(getShapeAttribute(), "rect").toLowerCase(Locale.ENGLISH); if ("default".equals(shape) && getCoordsAttribute() != null) { return true; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlButton.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -78,7 +79,7 @@ */ @Override protected boolean doClickStateUpdate() throws IOException { - final String type = getTypeAttribute().toLowerCase(); + final String type = getTypeAttribute().toLowerCase(Locale.ENGLISH); final HtmlForm form = getEnclosingForm(); if (form != null) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -26,6 +26,7 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.List; +import java.util.Locale; import java.util.Map; import net.sourceforge.htmlunit.corejs.javascript.BaseFunction; @@ -193,7 +194,7 @@ @SuppressWarnings("unchecked") public final <E extends HtmlElement> List<E> getHtmlElementsByTagName(final String tagName) { final List<E> list = new ArrayList<E>(); - final String lowerCaseTagName = tagName.toLowerCase(); + final String lowerCaseTagName = tagName.toLowerCase(Locale.ENGLISH); final Iterable<HtmlElement> iterable = getHtmlElementDescendants(); for (final HtmlElement element : iterable) { if (lowerCaseTagName.equals(element.getTagName())) { @@ -218,7 +219,8 @@ htmlPage.removeMappedElement(this); } - super.removeAttribute(attributeName.toLowerCase()); + // TODO is this toLowerCase call needed? + super.removeAttribute(attributeName.toLowerCase(Locale.ENGLISH)); if (htmlPage != null) { htmlPage.addMappedElement(this); @@ -306,12 +308,12 @@ final String prefix = getPrefix(); if (prefix != null) { // create string builder only if needed (performance) - final StringBuilder name = new StringBuilder(prefix); + final StringBuilder name = new StringBuilder(prefix.toLowerCase(Locale.ENGLISH)); name.append(':'); - name.append(getLocalName()); - return name.toString().toLowerCase(); + name.append(getLocalName().toLowerCase(Locale.ENGLISH)); + return name.toString(); } - return getLocalName().toLowerCase(); + return getLocalName().toLowerCase(Locale.ENGLISH); } /** @@ -355,7 +357,7 @@ * @return the first element with the specified tag name that is an ancestor to this element */ public HtmlElement getEnclosingElement(final String tagName) { - final String tagNameLC = tagName.toLowerCase(); + final String tagNameLC = tagName.toLowerCase(Locale.ENGLISH); for (DomNode currentNode = getParentNode(); currentNode != null; currentNode = currentNode.getParentNode()) { if (currentNode instanceof HtmlElement && currentNode.getNodeName().equals(tagNameLC)) { @@ -706,7 +708,7 @@ final String attributeValue) { final List<E> list = new ArrayList<E>(); - final String lowerCaseTagName = elementName.toLowerCase(); + final String lowerCaseTagName = elementName.toLowerCase(Locale.ENGLISH); for (final HtmlElement next : getHtmlElementDescendants()) { if (next.getTagName().equals(lowerCaseTagName)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; @@ -229,8 +230,10 @@ * @return the charset to use for the form submission */ private String getSubmitCharset() { - if (getAcceptCharsetAttribute().length() > 0) { - return SUBMIT_CHARSET_PATTERN.matcher(getAcceptCharsetAttribute().trim()).replaceAll("").toUpperCase(); + String charset = getAcceptCharsetAttribute(); + if (charset.length() > 0) { + charset = charset.trim(); + return SUBMIT_CHARSET_PATTERN.matcher(charset).replaceAll("").toUpperCase(Locale.ENGLISH); } return getPage().getPageEncoding(); } @@ -329,7 +332,7 @@ } if (element instanceof HtmlInput) { - final String type = element.getAttribute("type").toLowerCase(); + final String type = element.getAttribute("type").toLowerCase(Locale.ENGLISH); if ("radio".equals(type) || "checkbox".equals(type)) { return element.hasAttribute("checked"); } @@ -361,7 +364,7 @@ } if (element instanceof HtmlInput) { final HtmlInput input = (HtmlInput) element; - final String type = input.getTypeAttribute().toLowerCase(); + final String type = input.getTypeAttribute().toLowerCase(Locale.ENGLISH); if ("submit".equals(type) || "image".equals(type) || "reset".equals(type) || "button".equals(type)) { return false; } @@ -402,7 +405,7 @@ final String attributeValue) { final List<E> list = new ArrayList<E>(); - final String lowerCaseTagName = elementName.toLowerCase(); + final String lowerCaseTagName = elementName.toLowerCase(Locale.ENGLISH); for (final HtmlElement next : getFormHtmlElementDescendants()) { if (next.getTagName().equals(lowerCaseTagName)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlMeta.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlMeta.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlMeta.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -16,6 +16,7 @@ import java.net.URL; import java.util.Date; +import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; @@ -69,7 +70,7 @@ String path = null; Date expires = null; for (int i = 1; i < parts.length; i++) { - final String partName = StringUtils.substringBefore(parts[i], "=").trim().toLowerCase(); + final String partName = StringUtils.substringBefore(parts[i], "=").trim().toLowerCase(Locale.ENGLISH); final String partValue = StringUtils.substringAfter(parts[i], "=").trim(); if ("path".equals(partName)) { path = partValue; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; @@ -518,7 +519,7 @@ @Override public DomElement createElement(String tagName) { if (tagName.indexOf(':') == -1) { - tagName = tagName.toLowerCase(); + tagName = tagName.toLowerCase(Locale.ENGLISH); } return HTMLParser.getFactory(tagName).createElementNS(this, null, tagName, null, true); } @@ -896,7 +897,7 @@ public List<HtmlElement> getHtmlElementsByAccessKey(final char accessKey) { final List<HtmlElement> elements = new ArrayList<HtmlElement>(); - final String searchString = Character.toString(accessKey).toLowerCase(); + final String searchString = Character.toString(accessKey).toLowerCase(Locale.ENGLISH); final List<String> acceptableTagNames = Arrays.asList( new String[]{"a", "area", "button", "input", "label", "legend", "textarea"}); @@ -1347,7 +1348,7 @@ LOG.error("Malformed refresh string (no valid number before ';') " + refreshString, e); return; } - index = refreshString.toLowerCase().indexOf("url=", index); + index = refreshString.toLowerCase(Locale.ENGLISH).indexOf("url=", index); if (index == -1) { LOG.error("Malformed refresh string (found ';' but no 'url='): " + refreshString); return; @@ -1989,11 +1990,11 @@ if (getDocumentElement() == null) { return Collections.emptyList(); // weird case, for instance if document.documentElement has been removed } - final String nameLC = httpEquiv.toLowerCase(); + final String nameLC = httpEquiv.toLowerCase(Locale.ENGLISH); final List<HtmlMeta> tags = getDocumentElement().getHtmlElementsByTagName("meta"); for (final Iterator<HtmlMeta> iter = tags.iterator(); iter.hasNext();) { final HtmlMeta element = iter.next(); - if (!nameLC.equals(element.getHttpEquivAttribute().toLowerCase())) { + if (!nameLC.equals(element.getHttpEquivAttribute().toLowerCase(Locale.ENGLISH))) { iter.remove(); } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/InputElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/InputElementFactory.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/InputElementFactory.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.html; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import org.apache.commons.logging.Log; @@ -88,7 +89,7 @@ type = ""; } else { - type = type.toLowerCase(); + type = type.toLowerCase(Locale.ENGLISH); attributeMap.get("type").setValue(type); // type value has to be lower case } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/xpath/XPathAdapter.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/xpath/XPathAdapter.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/xpath/XPathAdapter.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.html.xpath; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -105,7 +106,7 @@ final Matcher matcher = PREPROCESS_XPATH_PATTERN.matcher(xpath); while (matcher.find()) { final String attribute = matcher.group(1); - xpath = xpath.replace(attribute, attribute.toLowerCase()); + xpath = xpath.replace(attribute, attribute.toLowerCase(Locale.ENGLISH)); } return xpath; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/ProxyAutoConfig.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/ProxyAutoConfig.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/ProxyAutoConfig.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -18,6 +18,7 @@ import java.net.URL; import java.text.SimpleDateFormat; import java.util.Calendar; +import java.util.Locale; import java.util.TimeZone; import java.util.regex.Pattern; @@ -223,7 +224,7 @@ } final Calendar calendar = Calendar.getInstance(timezone); for (int i = 0; i < 7; i++) { - final String day = new SimpleDateFormat("EEE").format(calendar.getTime()).toUpperCase(); + final String day = new SimpleDateFormat("EEE").format(calendar.getTime()).toUpperCase(Locale.ENGLISH); if (day.equals(wd2)) { return true; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ActiveXObject.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ActiveXObject.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ActiveXObject.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -17,6 +17,7 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import java.lang.reflect.Method; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; @@ -145,7 +146,7 @@ if (name == null) { return false; } - name = name.toLowerCase(); + name = name.toLowerCase(Locale.ENGLISH); return "microsoft.xmlhttp".equals(name) || name.startsWith("msxml2.xmlhttp"); } @@ -158,8 +159,8 @@ if (name == null) { return false; } - name = name.toLowerCase(); - return "Microsoft.XMLDOM".equalsIgnoreCase(name) + name = name.toLowerCase(Locale.ENGLISH); + return "microsoft.xmldom".equals(name) || name.matches("msxml\\d*\\.domdocument.*") || name.matches("msxml\\d*\\.freethreadeddomdocument.*"); } @@ -173,7 +174,7 @@ if (name == null) { return false; } - name = name.toLowerCase(); + name = name.toLowerCase(Locale.ENGLISH); return name.matches("msxml\\d*\\.xsltemplate.*"); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Console.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Console.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Console.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -19,6 +19,7 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -414,7 +415,7 @@ break; default: if (ch < ' ' || ch > '~') { - sb.append("\\u" + Integer.toHexString(ch).toUpperCase()); + sb.append("\\u" + Integer.toHexString(ch).toUpperCase(Locale.ENGLISH)); } else { sb.append(ch); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -14,9 +14,9 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_DESIGN_MODE_INHERIT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_32; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_CREATE_ELEMENT_EXTENDED_SYNTAX; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_DESIGN_MODE_INHERIT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.XUL_SUPPORT; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; @@ -505,15 +505,14 @@ } else { final boolean useLocalName = getBrowserVersion().hasFeature(GENERATED_32); - final String tagNameLC = tagName.toLowerCase(); collection = new HTMLCollection(getDomNodeOrDie(), false, description) { @Override protected boolean isMatching(final DomNode node) { if (useLocalName) { - return tagNameLC.equalsIgnoreCase(node.getLocalName()); + return tagName.equalsIgnoreCase(node.getLocalName()); } - return tagNameLC.equalsIgnoreCase(node.getNodeName()); + return tagName.equalsIgnoreCase(node.getNodeName()); } }; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -23,6 +23,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; @@ -205,7 +206,7 @@ */ @JsxFunction public HTMLCollection getElementsByTagName(final String tagName) { - final String tagNameLC = tagName.toLowerCase(); + final String tagNameLC = tagName.toLowerCase(Locale.ENGLISH); if (elementsByTagName_ == null) { elementsByTagName_ = new HashMap<String, HTMLCollection>(); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventListenersContainer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventListenersContainer.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventListenersContainer.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import net.sourceforge.htmlunit.corejs.javascript.EvaluatorException; @@ -102,16 +103,17 @@ } private Handlers getHandlersOrCreateIt(final String type) { - Handlers handlers = eventHandlers_.get(type.toLowerCase()); + final String typeLC = type.toLowerCase(Locale.ENGLISH); + Handlers handlers = eventHandlers_.get(typeLC); if (handlers == null) { handlers = new Handlers(); - eventHandlers_.put(type.toLowerCase(), handlers); + eventHandlers_.put(typeLC, handlers); } return handlers; } private List<Function> getHandlers(final String eventType, final boolean useCapture) { - final Handlers handlers = eventHandlers_.get(eventType.toLowerCase()); + final Handlers handlers = eventHandlers_.get(eventType.toLowerCase(Locale.ENGLISH)); if (handlers != null) { return handlers.getHandlers(useCapture); } @@ -255,7 +257,7 @@ * @return the handler function, <code>null</code> if the property is null or not a function */ public Function getEventHandler(final String eventName) { - final Object handler = getEventHandlerProp(eventName.toLowerCase()); + final Object handler = getEventHandlerProp(eventName.toLowerCase(Locale.ENGLISH)); if (handler instanceof Function) { return (Function) handler; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventNode.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/EventNode.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -16,6 +16,8 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; +import java.util.Locale; + import org.apache.commons.lang3.StringUtils; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; @@ -375,7 +377,7 @@ } // Create the event, whose class will depend on the type specified. - final String cleanedType = StringUtils.removeStart(type.toLowerCase(), "on"); + final String cleanedType = StringUtils.removeStart(type.toLowerCase(Locale.ENGLISH), "on"); if (MouseEvent.isMouseEvent(cleanedType)) { event.setPrototype(getPrototype(MouseEvent.class)); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Locale; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -872,7 +873,9 @@ if (eventListenersContainer_ == null) { return null; } - return eventListenersContainer_.getEventHandlerProp(StringUtils.substring(eventName.toLowerCase(), 2)); + + final String name = StringUtils.substring(eventName.toLowerCase(Locale.ENGLISH), 2); + return eventListenersContainer_.getEventHandlerProp(name); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -34,6 +34,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; @@ -1825,7 +1826,7 @@ return; } if (changed instanceof HtmlLink) { - final String rel = ((HtmlLink) changed).getRelAttribute().toLowerCase(); + final String rel = ((HtmlLink) changed).getRelAttribute().toLowerCase(Locale.ENGLISH); if ("stylesheet".equals(rel)) { synchronized (computedStyles_) { computedStyles_.clear(); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; @@ -599,7 +600,7 @@ for (final String token : StringUtils.split(styleAttribute, ';')) { final int index = token.indexOf(":"); if (index != -1) { - final String key = token.substring(0, index).trim().toLowerCase(); + final String key = token.substring(0, index).trim().toLowerCase(Locale.ENGLISH); String value = token.substring(index + 1).trim(); String priority = ""; if (StringUtils.endsWithIgnoreCase(value, "!important")) { @@ -4234,7 +4235,7 @@ * @return whether the token is a reserved color keyword or not */ private static boolean isColorKeyword(final String token) { - return CSSColors_.containsKey(token.toLowerCase()); + return CSSColors_.containsKey(token.toLowerCase(Locale.ENGLISH)); } /** @@ -4244,7 +4245,7 @@ * in the form "rgb(x, y, z)" otherwise */ public static String toRGBColor(final String color) { - final String rgbValue = CSSColors_.get(color.toLowerCase()); + final String rgbValue = CSSColors_.get(color.toLowerCase(Locale.ENGLISH)); if (rgbValue != null) { return rgbValue; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleRule.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleRule.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleRule.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -16,6 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_SELECTOR_TEXT_UPPERCASE; +import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -69,10 +70,10 @@ // nothing } else if (getBrowserVersion().hasFeature(JS_SELECTOR_TEXT_UPPERCASE)) { - fixedName = fixedName.toUpperCase(); + fixedName = fixedName.toUpperCase(Locale.ENGLISH); } else { - fixedName = fixedName.toLowerCase(); + fixedName = fixedName.toLowerCase(Locale.ENGLISH); } fixedName = StringUtils.sanitizeForAppendReplacement(fixedName); m.appendReplacement(sb, fixedName); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Locale; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -126,7 +127,7 @@ } private void doGetPosition() { - final String os = System.getProperty("os.name").toLowerCase(); + final String os = System.getProperty("os.name").toLowerCase(Locale.ENGLISH); String wifiStringString = null; if (os.contains("win")) { wifiStringString = getWifiStringWindows(); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -18,6 +18,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_41; import java.net.MalformedURLException; +import java.util.Locale; import net.sourceforge.htmlunit.corejs.javascript.Context; @@ -50,7 +51,7 @@ public void createEventHandlerFromAttribute(final String attributeName, final String value) { // when many body tags are found while parsing, attributes of // different tags are added and should create an event handler when needed - if (attributeName.toLowerCase().startsWith("on")) { + if (attributeName.toLowerCase(Locale.ENGLISH).startsWith("on")) { createEventHandler(attributeName, value); } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -311,11 +311,10 @@ */ @JsxFunction(@WebBrowser(IE)) public Object tags(final String tagName) { - final String tagNameLC = tagName.toLowerCase(); final HTMLCollection collection = new HTMLSubCollection(this, ".tags('" + tagName + "')") { @Override protected boolean isMatching(final DomNode node) { - return tagNameLC.equalsIgnoreCase(node.getLocalName()); + return tagName.equalsIgnoreCase(node.getLocalName()); } }; return collection; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -43,7 +43,6 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; -import static com.gargoylesoftware.htmlunit.util.StringUtils.containsCaseInsensitive; import static com.gargoylesoftware.htmlunit.util.StringUtils.parseHttpDate; import java.io.IOException; @@ -55,7 +54,9 @@ import java.util.Collections; import java.util.Date; import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; @@ -173,40 +174,12 @@ */ private static final Map<String, Class<? extends Event>> SUPPORTED_EVENT_TYPE_MAP; - private static final List<String> EXECUTE_CMDS_IE = Arrays.asList( - "2D-Position", "AbsolutePosition", "BackColor", "BackgroundImageCache" /* Undocumented */, - "BlockDirLTR", "BlockDirRTL", "Bold", "BrowseMode", "ClearAuthenticationCache", "Copy", "CreateBookmark", - "CreateLink", "Cut", "Delete", "DirLTR", "DirRTL", - "EditMode", "FontName", "FontSize", "ForeColor", "FormatBlock", - "Indent", "InlineDirLTR", "InlineDirRTL", "InsertButton", "InsertFieldset", - "InsertHorizontalRule", "InsertIFrame", "InsertImage", "InsertInputButton", "InsertInputCheckbox", - "InsertInputFileUpload", "InsertInputHidden", "InsertInputImage", "InsertInputPassword", "InsertInputRadio", - "InsertInputReset", "InsertInputSubmit", "InsertInputText", "InsertMarquee", "InsertOrderedList", - "InsertParagraph", "InsertSelectDropdown", "InsertSelectListbox", "InsertTextArea", "InsertUnorderedList", - "Italic", "JustifyCenter", "JustifyFull", "JustifyLeft", "JustifyNone", - "JustifyRight", "LiveResize", "MultipleSelection", "Open", "Outdent", - "OverWrite", "Paste", "PlayImage", "Print", "Redo", - "Refresh", "RemoveFormat", "RemoveParaFormat", "SaveAs", "SelectAll", - "SizeToControl", "SizeToControlHeight", "SizeToControlWidth", "Stop", "StopImage", - "StrikeThrough", "Subscript", "Superscript", "UnBookmark", "Underline", - "Undo", "Unlink", "Unselect" - ); - + // all as lowercase for performance + private static final Set<String> EXECUTE_CMDS_IE = new HashSet<String>(); /** https://developer.mozilla.org/en/Rich-Text_Editing_in_Mozilla#Executing_Commands */ - private static final List<String> EXECUTE_CMDS_FF = Arrays.asList( - "backColor", "bold", "contentReadOnly", "copy", "createLink", "cut", "decreaseFontSize", "delete", - "fontName", "fontSize", "foreColor", "formatBlock", "heading", "hiliteColor", "increaseFontSize", - "indent", "insertHorizontalRule", "insertHTML", "insertImage", "insertOrderedList", "insertUnorderedList", - "insertParagraph", "italic", "justifyCenter", "justifyLeft", "justifyRight", "outdent", "paste", "redo", - "removeFormat", "selectAll", "strikeThrough", "subscript", "superscript", "underline", "undo", "unlink", - "useCSS", "styleWithCSS" - ); + private static final Set<String> EXECUTE_CMDS_FF = new HashSet<String>(); + private static final Set<String> EXECUTE_CMDS_FF17 = new HashSet<String>(); - private static final List<String> EXECUTE_CMDS_FF17 = new ArrayList<String>(EXECUTE_CMDS_FF) { { - add("JustifyFull"); - } - }; - /** * Static counter for {@link #uniqueID_}. */ @@ -248,6 +221,44 @@ eventMap.put("UIEvent", UIEvent.class); eventMap.put("UIEvents", UIEvent.class); SUPPORTED_EVENT_TYPE_MAP = Collections.unmodifiableMap(eventMap); + + // commands + List<String> cmds = Arrays.asList( + "2D-Position", "AbsolutePosition", "BackColor", "BackgroundImageCache" /* Undocumented */, + "BlockDirLTR", "BlockDirRTL", "Bold", "BrowseMode", "ClearAuthenticationCache", "Copy", "CreateBookmark", + "CreateLink", "Cut", "Delete", "DirLTR", "DirRTL", + "EditMode", "FontName", "FontSize", "ForeColor", "FormatBlock", + "Indent", "InlineDirLTR", "InlineDirRTL", "InsertButton", "InsertFieldset", + "InsertHorizontalRule", "InsertIFrame", "InsertImage", "InsertInputButton", "InsertInputCheckbox", + "InsertInputFileUpload", "InsertInputHidden", "InsertInputImage", "InsertInputPassword", "InsertInputRadio", + "InsertInputReset", "InsertInputSubmit", "InsertInputText", "InsertMarquee", "InsertOrderedList", + "InsertParagraph", "InsertSelectDropdown", "InsertSelectListbox", "InsertTextArea", "InsertUnorderedList", + "Italic", "JustifyCenter", "JustifyFull", "JustifyLeft", "JustifyNone", + "JustifyRight", "LiveResize", "MultipleSelection", "Open", "Outdent", + "OverWrite", "Paste", "PlayImage", "Print", "Redo", + "Refresh", "RemoveFormat", "RemoveParaFormat", "SaveAs", "SelectAll", + "SizeToControl", "SizeToControlHeight", "SizeToControlWidth", "Stop", "StopImage", + "StrikeThrough", "Subscript", "Superscript", "UnBookmark", "Underline", + "Undo", "Unlink", "Unselect" + ); + for (String cmd : cmds) { + EXECUTE_CMDS_IE.add(cmd.toLowerCase(Locale.ENGLISH)); + } + + cmds = Arrays.asList( + "backColor", "bold", "contentReadOnly", "copy", "createLink", "cut", "decreaseFontSize", "delete", + "fontName", "fontSize", "foreColor", "formatBlock", "heading", "hiliteColor", "increaseFontSize", + "indent", "insertHorizontalRule", "insertHTML", "insertImage", "insertOrderedList", "insertUnorderedList", + "insertParagraph", "italic", "justifyCenter", "justifyLeft", "justifyRight", "outdent", "paste", "redo", + "removeFormat", "selectAll", "strikeThrough", "subscript", "superscript", "underline", "undo", "unlink", + "useCSS", "styleWithCSS" + ); + for (String cmd : cmds) { + EXECUTE_CMDS_FF.add(cmd.toLowerCase(Locale.ENGLISH)); + EXECUTE_CMDS_FF17.add(cmd.toLowerCase(Locale.ENGLISH)); + } + + EXECUTE_CMDS_FF17.add("JustifyFull".toLowerCase(Locale.ENGLISH)); } /** @@ -929,10 +940,11 @@ final String token = st.nextToken(); final int indexEqual = token.indexOf('='); if (indexEqual > -1) { - atts.put(token.substring(0, indexEqual).toLowerCase().trim(), token.substring(indexEqual + 1).trim()); + atts.put(token.substring(0, indexEqual).trim().toLowerCase(Locale.ENGLISH), + token.substring(indexEqual + 1).trim()); } else { - atts.put(token.toLowerCase().trim(), Boolean.TRUE); + atts.put(token.trim().toLowerCase(Locale.ENGLISH), Boolean.TRUE); } } @@ -1009,7 +1021,7 @@ public String getCharset() { String charset = getHtmlPage().getPageEncoding(); if (getBrowserVersion().hasFeature(HTMLDOCUMENT_CHARSET_LOWERCASE)) { - charset = charset.toLowerCase(); + charset = charset.toLowerCase(Locale.ENGLISH); } return charset; } @@ -1603,7 +1615,7 @@ } domain_ = url.getHost(); if (getBrowserVersion().hasFeature(JS_DOCUMENT_DOMAIN_IS_LOWERCASE)) { - domain_ = domain_.toLowerCase(); + domain_ = domain_.toLowerCase(Locale.ENGLISH); } } @@ -1661,14 +1673,14 @@ } if (currentDomain.indexOf('.') > -1 - && !currentDomain.toLowerCase().endsWith("." + newDomain.toLowerCase())) { + && !currentDomain.toLowerCase(Locale.ENGLISH).endsWith("." + newDomain.toLowerCase(Locale.ENGLISH))) { throw Context.reportRuntimeError("Illegal domain value, cannot set domain from: \"" + currentDomain + "\" to: \"" + newDomain + "\""); } // Netscape down shifts the case of the domain if (browserVersion.hasFeature(JS_DOCUMENT_DOMAIN_IS_LOWERCASE)) { - domain_ = newDomain.toLowerCase(); + domain_ = newDomain.toLowerCase(Locale.ENGLISH); } else { domain_ = newDomain; @@ -1892,13 +1904,20 @@ } private boolean hasCommand(final String cmd) { + if (null == cmd) { + return false; + } + + final String cmdLC = cmd.toLowerCase(Locale.ENGLISH); if (getBrowserVersion().isIE()) { - return containsCaseInsensitive(EXECUTE_CMDS_IE, cmd); + return EXECUTE_CMDS_IE.contains(cmdLC); } else if ("FF3.6".equals(getBrowserVersion().getNickname())) { - return containsCaseInsensitive(EXECUTE_CMDS_FF, cmd); + return EXECUTE_CMDS_FF.contains(cmdLC); } - return containsCaseInsensitive(EXECUTE_CMDS_FF17, cmd); + else { + return EXECUTE_CMDS_FF17.contains(cmdLC); + } } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -52,6 +52,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; @@ -513,14 +514,15 @@ public String getLocalName() { final DomNode domNode = getDomNodeOrDie(); if (domNode.getPage() instanceof HtmlPage) { - final StringBuilder localName = new StringBuilder(); final String prefix = domNode.getPrefix(); if (prefix != null) { - localName.append(prefix); + // create string builder only if needed (performance) + final StringBuilder localName = new StringBuilder(prefix.toUpperCase(Locale.ENGLISH)); localName.append(':'); + localName.append(domNode.getLocalName().toUpperCase(Locale.ENGLISH)); + return localName.toString(); } - localName.append(domNode.getLocalName()); - return localName.toString().toUpperCase(); + return domNode.getLocalName().toUpperCase(Locale.ENGLISH); } return domNode.getLocalName(); } @@ -557,7 +559,7 @@ // can name be an attribute of current element? // first approximation: attribute are all lowercase // this should be improved because it's wrong. For instance: tabIndex, hideFocus, acceptCharset - return name.toLowerCase().equals(name); + return name.toLowerCase(Locale.ENGLISH).equals(name); } /** @@ -681,7 +683,7 @@ // FF: call corresponding event handler setOnxxx if found if (getBrowserVersion().hasFeature(JS_SET_ATTRIBUTE_SUPPORTS_EVENT_HANDLERS) && !name.isEmpty()) { - name = name.toLowerCase(); + name = name.toLowerCase(Locale.ENGLISH); if (name.startsWith("on")) { try { name = Character.toUpperCase(name.charAt(0)) + name.substring(1); @@ -928,7 +930,7 @@ final boolean isUpperCase = getBrowserVersion().hasFeature(HTMLELEMENT_OUTER_HTML_UPPER_CASE); String tag = element.getTagName(); if (isUpperCase && !scriptObject.isLowerCaseInOuterHtml()) { - tag = tag.toUpperCase(); + tag = tag.toUpperCase(Locale.ENGLISH); } buffer.append("<").append(tag); // Add the attributes. IE does not use quotes, FF does. @@ -1055,7 +1057,7 @@ parseHtmlSnippet(fragment, false, value); DomNode child = fragment.getFirstChild(); if (child instanceof DomElement) { - final String parentName = domNode.getParentNode().getNodeName().toUpperCase(); + final String parentName = domNode.getParentNode().getNodeName().toUpperCase(Locale.ENGLISH); final short[] closes = HTMLElements.getElement(child.getNodeName()).closes; if (closes != null) { for (final short close : closes) { @@ -2075,7 +2077,7 @@ final DomNode domNode = getDomNodeOrDie(); String nodeName = domNode.getNodeName(); if (domNode.getPage() instanceof HtmlPage) { - nodeName = nodeName.toUpperCase(); + nodeName = nodeName.toUpperCase(Locale.ENGLISH); } return nodeName; } @@ -2320,12 +2322,12 @@ s = null; for (final String key : COLORS_MAP_IE.keySet()) { if (key.equalsIgnoreCase(value)) { - s = COLORS_MAP_IE.get(key).toLowerCase(); + s = COLORS_MAP_IE.get(key).toLowerCase(Locale.ENGLISH); break; } } if (s == null) { - s = value.toLowerCase(); + s = value.toLowerCase(Locale.ENGLISH); if (s.charAt(0) == '#') { s = s.substring(1); } @@ -2376,7 +2378,7 @@ * (i.e., it will not actually set the align attribute) */ protected void setAlign(final String align, final boolean ignoreIfNoError) { - final String alignLC = align.toLowerCase(); + final String alignLC = align.toLowerCase(Locale.ENGLISH); final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_ALIGN_ACCEPTS_ARBITRARY_VALUES); if (acceptArbitraryValues || "center".equals(alignLC) @@ -2413,7 +2415,7 @@ * @param valid the valid values; if <tt>null</tt>, any value is valid */ protected void setVAlign(final Object vAlign, final String[] valid) { - final String s = Context.toString(vAlign).toLowerCase(); + final String s = Context.toString(vAlign).toLowerCase(Locale.ENGLISH); if (valid == null || ArrayUtils.contains(valid, s)) { getDomNodeOrDie().setAttribute("valign", s); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -21,6 +21,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import net.sourceforge.htmlunit.corejs.javascript.Context; @@ -185,7 +186,7 @@ return align; } - final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase()); + final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase(Locale.ENGLISH)); if (null != normalizedValue) { return normalizedValue; } @@ -204,7 +205,7 @@ return; } - final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase()); + final String normalizedValue = NORMALIZED_ALIGN_VALUES.get(align.toLowerCase(Locale.ENGLISH)); if (null != normalizedValue) { getDomNodeOrDie().setAttribute("align", normalizedValue); return; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-06-14 17:39:48 UTC (rev 8343) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-06-14 20:24:02 UTC (rev 8344) @@ -20,6 +20,7 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import java.io.IOException; +import java.util.Locale; import org.apache.commons.lang3.math.NumberUtils; import org.xml.sax.helpers.AttributesImpl; @@ -240,11 +241,12 @@ */ @Override protected boolean isAttributeName(final String name) { - if ("maxlength".equals(name.toLowerCase())) { + final String nameLC = name.toLowerCase(Locale.EN... [truncated message content] |