From: <asa...@us...> - 2012-11-26 08:22:55
|
Revision: 7773 http://sourceforge.net/p/htmlunit/code/7773 Author: asashour Date: 2012-11-26 08:22:49 +0000 (Mon, 26 Nov 2012) Log Message: ----------- JavaScript: XML: element.removeAttribute() is case-sensitive, thanks to jQuery. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-26 08:22:49 UTC (rev 7773) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + JavaScript: XML: element.removeAttribute() is case-sensitive. + </action> <action type="fix" dev="asashour" issue="1464"> Correctly handle local file URL if it is in a separate driver (Windows). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomElement.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -226,8 +226,11 @@ * Removes an attribute specified by name from this element. * @param attributeName the attribute attributeName */ - public void removeAttribute(final String attributeName) { - attributes_.remove(attributeName.toLowerCase()); + public void removeAttribute(String attributeName) { + if (this instanceof HtmlElement) { + attributeName = attributeName.toLowerCase(); + } + attributes_.remove(attributeName); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ElementTest.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -1076,4 +1076,45 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "ab", "ab" }) + public void removeAttribute_case_sensitive() throws Exception { + final String html = "<html>\n" + + " <head>\n" + + " <script>\n" + + " function test() {\n" + + " var request;\n" + + " if (window.XMLHttpRequest)\n" + + " request = new XMLHttpRequest();\n" + + " else if (window.ActiveXObject)\n" + + " request = new ActiveXObject('Microsoft.XMLHTTP');\n" + + " request.open('GET', 'foo.xml', false);\n" + + " request.send('');\n" + + " var doc = request.responseXML;\n" + + " var e = doc.getElementsByTagName('title')[0];\n" + + " alert(e.getAttribute('normal'));\n" + + " e.removeAttribute('Normal');\n" + + " alert(e.getAttribute('normal'));\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>\n" + + " </body>\n" + + "</html>"; + + final String xml + = "<books>\n" + + " <book>\n" + + " <title normal=\"ab\">Immortality</title>\n" + + " <author>John Smith</author>\n" + + " </book>\n" + + "</books>"; + + getMockWebConnection().setDefaultResponse(xml, "text/xml"); + loadPageWithAlerts2(html); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 06:52:33 UTC (rev 7772) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 08:22:49 UTC (rev 7773) @@ -1411,7 +1411,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF3_6 = "queue: .promise(obj) (0, 2, 2)", FF10 = "queue: delay() can be stopped (2, 3, 5)", + @Alerts(FF3_6 = "queue: .promise(obj) (0, 2, 2)", FF10 = "queue: delay() can be stopped (0, 3, 3)", CHROME = "queue: delay() can be stopped (0, 3, 3)", IE = "queue: .promise(obj) (0, 2, 2)") public void test_135() throws Exception { runTest(135); @@ -1572,7 +1572,6 @@ FF10 = "attributes: removeAttr(Multi String, variable space width) (0, 8, 8)", CHROME = "attributes: removeAttr(Multi String, variable space width) (0, 8, 8)", IE = "attributes: removeAttr(String) in XML (0, 7, 7)") - @NotYetImplemented public void test_149() throws Exception { runTest(149); } |
From: <asa...@us...> - 2012-11-26 10:25:39
|
Revision: 7776 http://sourceforge.net/p/htmlunit/code/7776 Author: asashour Date: 2012-11-26 10:25:36 +0000 (Mon, 26 Nov 2012) Log Message: ----------- JavaScript: correct select.value after enclosing form.reset(), thanks to jQuery. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlOption.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSelect.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FormChild.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-26 10:25:36 UTC (rev 7776) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="asashour"> + JavaScript: correct select.value after enclosing form.reset(). + </action> + <action type="fix" dev="asashour"> JavaScript: XML: element.removeAttribute() is case-sensitive. </action> <action type="fix" dev="asashour" issue="1464"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlOption.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlOption.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlOption.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -127,7 +127,7 @@ /** * Gets the enclosing select of this option. - * @return <code>null</code> if no select is found (for instance malformed html) + * @return <code>null</code> if no select is found (for instance malformed HTML) */ public HtmlSelect getEnclosingSelect() { return (HtmlSelect) getEnclosingElement("select"); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSelect.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSelect.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlSelect.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -365,6 +365,7 @@ for (final HtmlOption option : getOptions()) { option.reset(); } + onAllChildrenAddedToPage(false); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FormChild.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FormChild.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/FormChild.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -30,13 +30,6 @@ public class FormChild extends HTMLElement { /** - * Creates an instance. - */ - public FormChild() { - // Empty. - } - - /** * Returns the value of the JavaScript <tt>form</tt> attribute. * * @return the value of the JavaScript <tt>form</tt> attribute 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 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFormElement.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -76,13 +76,6 @@ private HTMLCollection elements_; // has to be a member to have equality (==) working /** - * Creates an instance. A default constructor is required for all JavaScript objects. - */ - public HTMLFormElement() { - // Empty. - } - - /** * {@inheritDoc} */ @Override Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElement.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElement.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -51,12 +51,6 @@ private HTMLOptionsCollection optionsArray_; /** - * Creates an instance. - */ - public HTMLSelectElement() { - } - - /** * Initialize the object. * */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -48,7 +48,7 @@ */ @Test @Alerts({ "3", "1" }) - public void testGetSelectedIndex() throws Exception { + public void getSelectedIndex() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -73,7 +73,7 @@ */ @Test @Alerts({ "3", "1", "3", "2" }) - public void testSetSelectedIndex() throws Exception { + public void setSelectedIndex() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -109,7 +109,7 @@ */ @Test @Alerts("0") - public void testSelectedIndex2() throws Exception { + public void selectedIndex2() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + " function test() {\n" + " var oSelect = document.getElementById('main');\n" @@ -133,7 +133,7 @@ @Test @Alerts(FF = { "-1", "2", "-1", "-1" }, IE = { "-1", "2", "-1", "-1" }) - public void testSetSelectedIndexInvalidValue() throws Exception { + public void setSelectedIndexInvalidValue() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -166,7 +166,7 @@ */ @Test @Alerts({ "value1", "One", "value2", "Two", "value3", "Three" }) - public void testGetOptions() throws Exception { + public void getOptions() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -194,7 +194,7 @@ */ @Test @Alerts({ "value1", "One", "value2", "Two", "value3", "Three" }) - public void testGetOptionLabel() throws Exception { + public void getOptionLabel() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -222,7 +222,7 @@ */ @Test @Alerts({ "false", "true", "true", "false" }) - public void testGetOptionSelected() throws Exception { + public void getOptionSelected() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -252,7 +252,7 @@ */ @Test @Alerts("true") - public void testGetOptionByIndex() throws Exception { + public void getOptionByIndex() throws Exception { final String html = "<html><head><title>first</title><script language='JavaScript'>\n" //+ "//<!--" @@ -275,7 +275,7 @@ */ @Test @Alerts("One") - public void testGetOptionByOptionIndex() throws Exception { + public void getOptionByOptionIndex() throws Exception { final String html = "<html><head><title>first</title><script language='JavaScript'>\n" //+ "//<!--" @@ -302,7 +302,7 @@ */ @Test @Alerts({ "4", "Four", "value4" }) - public void testAddOption() throws Exception { + public void addOption() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -331,7 +331,7 @@ */ @Test @Alerts({ "1", "true", "4", "Four", "value4", "true", "3", "false" }) - public void testAddOptionSelected() throws Exception { + public void addOptionSelected() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -370,7 +370,7 @@ @Test @Alerts({ "4", "Four", "value4" }) @Browsers(FF) - public void testAddOptionWithAddMethod_FF() throws Exception { + public void addOptionWithAddMethod_FF() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -401,7 +401,7 @@ @Test @Alerts(FF3_6 = "exception", DEFAULT = { "4", "Four", "value4", "Three b", "value3b" }) - public void testAddOptionWithAddMethod_IE() throws Exception { + public void addOptionWithAddMethod_IE() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -436,7 +436,7 @@ @Test @Alerts(IE = { "0", "exception" }, FF = { "0", "test", "testValue" }) - public void testAddOptionTooEmptySelectWithAddMethod_IE() throws Exception { + public void addOptionTooEmptySelectWithAddMethod_IE() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -466,7 +466,7 @@ @Test @Alerts(FF3_6 = { "0", "exception" }, DEFAULT = { "0", "1" }) - public void testAddWith1Arg() throws Exception { + public void addWith1Arg() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -495,7 +495,7 @@ */ @Test @Alerts({ "2", "Three", "value3" }) - public void testRemoveOption() throws Exception { + public void removeOption() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -523,7 +523,7 @@ */ @Test @Alerts({ "2", "Three", "value3" }) - public void testRemoveOptionWithRemoveMethod() throws Exception { + public void removeOptionWithRemoveMethod() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -583,7 +583,7 @@ */ @Test @Alerts("0") - public void testClearOptions() throws Exception { + public void clearOptions() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -611,7 +611,7 @@ */ @Test @Alerts({ "1", "2", "", "", "foo", "fooValue" }) - public void testIncreaseOptionsSettingLength() throws Exception { + public void increaseOptionsSettingLength() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -643,7 +643,7 @@ */ @Test @Alerts({ "One", "value1" }) - public void testOptionArrayHasItemMethod() throws Exception { + public void optionArrayHasItemMethod() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -708,7 +708,7 @@ */ @Test @Alerts({ "0", "1" }) - public void testSetValue() throws Exception { + public void setValue() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" @@ -734,7 +734,7 @@ */ @Test @Alerts(FF = "exception", IE = { "2-2", "1-1", "2-2", "0-0", "2-2", "1-1" }) - public void testOptionsDelegateToSelect() throws Exception { + public void optionsDelegateToSelect() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -773,7 +773,7 @@ */ @Test @Alerts({ "2", "b", "3", "c" }) - public void testOptionsArrayAdd() throws Exception { + public void optionsArrayAdd() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -808,7 +808,7 @@ */ @Test @Alerts("-1") - public void testSelectedIndex() throws Exception { + public void selectedIndex() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -830,45 +830,45 @@ * @throws Exception if the test fails */ @Test - public void testDefaultSelectedValue_SizeNegativeOne() throws Exception { - testDefaultSelectedValue("-1", false, new String[] {"0", "true", "false", "false", "0"}); - testDefaultSelectedValue("-1", true, new String[] {"0", "false", "false", "false", "-1"}); + public void defaultSelectedValue_SizeNegativeOne() throws Exception { + defaultSelectedValue("-1", false, new String[] {"0", "true", "false", "false", "0"}); + defaultSelectedValue("-1", true, new String[] {"0", "false", "false", "false", "-1"}); } /** * @throws Exception if the test fails */ @Test - public void testDefaultSelectedValue_SizeZero() throws Exception { - testDefaultSelectedValue("0", false, new String[] {"0", "true", "false", "false", "0"}); - testDefaultSelectedValue("0", true, new String[] {"0", "false", "false", "false", "-1"}); + public void defaultSelectedValue_SizeZero() throws Exception { + defaultSelectedValue("0", false, new String[] {"0", "true", "false", "false", "0"}); + defaultSelectedValue("0", true, new String[] {"0", "false", "false", "false", "-1"}); } /** * @throws Exception if the test fails */ @Test - public void testDefaultSelectedValue_SizeOne() throws Exception { - testDefaultSelectedValue("1", false, new String[] {"1", "true", "false", "false", "0"}); - testDefaultSelectedValue("1", true, new String[] {"1", "false", "false", "false", "-1"}); + public void defaultSelectedValue_SizeOne() throws Exception { + defaultSelectedValue("1", false, new String[] {"1", "true", "false", "false", "0"}); + defaultSelectedValue("1", true, new String[] {"1", "false", "false", "false", "-1"}); } /** * @throws Exception if the test fails */ @Test - public void testDefaultSelectedValue_SizeTwo() throws Exception { - testDefaultSelectedValue("2", false, "2", "false", "false", "false", "-1"); - testDefaultSelectedValue("2", true, "2", "false", "false", "false", "-1"); + public void defaultSelectedValue_SizeTwo() throws Exception { + defaultSelectedValue("2", false, "2", "false", "false", "false", "-1"); + defaultSelectedValue("2", true, "2", "false", "false", "false", "-1"); } /** * @throws Exception if the test fails */ @Test - public void testDefaultSelectedValue_SizeInvalid() throws Exception { - testDefaultSelectedValue("x", false, "0", "true", "false", "false", "0"); - testDefaultSelectedValue("x", true, "0", "false", "false", "false", "-1"); + public void defaultSelectedValue_SizeInvalid() throws Exception { + defaultSelectedValue("x", false, "0", "true", "false", "false", "0"); + defaultSelectedValue("x", true, "0", "false", "false", "false", "-1"); } /** @@ -879,7 +879,7 @@ * @param expected the expected alerts * @throws Exception if the test fails */ - private void testDefaultSelectedValue(final String size, final boolean multiple, final String... expected) + private void defaultSelectedValue(final String size, final boolean multiple, final String... expected) throws Exception { setExpectedAlerts(expected); @@ -916,7 +916,7 @@ */ @Test @Alerts("5") - public void testSize() throws Exception { + public void size() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + " function test() {\n" + " var select = document.getElementById('mySelect');\n" @@ -934,7 +934,7 @@ */ @Test @Alerts({ "true", "false", "false" }) - public void testMultiple() throws Exception { + public void multiple() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function doTest() {\n" + " alert(document.f['s1'].multiple);\n" @@ -1158,4 +1158,34 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "One", "Two", "One" }) + public void valueAfterReset() throws Exception { + final String html = + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var form = document.getElementById('myForm');\n" + + " var select = document.getElementById('mySelect');\n" + + " alert(select.value);\n" + + " select.options[1].selected = true;\n" + + " alert(select.value);\n" + + " form.reset();\n" + + " alert(select.value);\n" + + " }\n" + + "</script>\n" + + "<body onload='test()'>\n" + + "<form id='myForm' name='myForm'>\n" + + " <select id='mySelect'>\n" + + " <option>One</option>\n" + + " <option>Two</option>\n" + + " </select>\n" + + "</form>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 08:54:42 UTC (rev 7775) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 10:25:36 UTC (rev 7776) @@ -1695,7 +1695,6 @@ FF10 = "attributes: addClass(String) (0, 9, 9)", CHROME = "attributes: val(select) after form.reset() (Bug #2551) (0, 3, 3)", IE = "attributes: val(select) after form.reset() (Bug #2551) (0, 3, 3)") - @NotYetImplemented public void test_160() throws Exception { runTest(160); } |
From: <asa...@us...> - 2012-11-26 12:38:22
|
Revision: 7778 http://sourceforge.net/p/htmlunit/code/7778 Author: asashour Date: 2012-11-26 12:38:16 +0000 (Mon, 26 Nov 2012) Log Message: ----------- JavaScript: correctly process null function handlers, thanks to jQuery 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/Window.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-26 12:38:16 UTC (rev 7778) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="asashour"> + JavaScript: correctly process null function handlers. + </action> + <action type="fix" dev="asashour"> JavaScript: correct select.value after enclosing form.reset(). </action> <action type="fix" dev="asashour"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-11-26 12:38:16 UTC (rev 7778) @@ -278,10 +278,6 @@ /** Was originally .isIE(). */ @BrowserFeature(@WebBrowser(IE)) - GENERATED_129, - - /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) GENERATED_13, /** Was originally .isIE(). */ @@ -889,6 +885,10 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) JS_GET_ELEMENT_BY_ID_CASE_SENSITIVE, + /** Indicates that not defined function handler should be 'undefined', or 'null'. */ + @BrowserFeature(@WebBrowser(value = FF, maxVersion = 3.6f)) + JS_HANDLER_UNDEFINED, + /** Indicates that objects with prototype property available in window scope; Firefox does this. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) JS_HAS_OBJECT_WITH_PROTOTYPE_PROPERTY_IN_WINDOW_SCOPE, 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 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2012-11-26 12:38:16 UTC (rev 7778) @@ -14,9 +14,9 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_129; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_133; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_EVENT_HANDLER_AS_PROPERTY_DONT_RECEIVE_EVENT; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_HANDLER_UNDEFINED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_CHANGE_OPENER_NOT_ALLOWED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_FRAMES_ACCESSIBLE_BY_ID; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_IS_NOT_A_FUNCTION; @@ -1241,14 +1241,14 @@ private Object getHandlerForJavaScript(final String eventName) { Object handler = getEventListenersContainer().getEventHandlerProp(eventName); - if (handler == null && !getBrowserVersion().hasFeature(GENERATED_129)) { + if (handler == null && getBrowserVersion().hasFeature(JS_HANDLER_UNDEFINED)) { handler = Scriptable.NOT_FOUND; } return handler; } private void setHandlerForJavaScript(final String eventName, final Object handler) { - if (handler instanceof Function) { + if (handler instanceof Function || handler == null) { getEventListenersContainer().setEventHandlerProp(eventName, handler); } // Otherwise, fail silently. 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 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2012-11-26 12:38:16 UTC (rev 7778) @@ -884,4 +884,30 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "null", "function", "null" }, FF3_6 = { "undefined", "function", "null" }) + @NotYetImplemented(FF3_6) + public void onbeforeunload() throws Exception { + final String html = + "<html><head><title>First</title>\n" + + "<script>\n" + + "function test() {\n" + + " alert(window.onbeforeunload);\n" + + " var handle = function () {};\n" + + " window.onbeforeunload = handle;\n" + + " alert(typeof window.onbeforeunload);\n" + + " window.onbeforeunload = null;\n" + + " alert(window.onbeforeunload);\n" + + " \n" + + "}\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSelectElementTest.java 2012-11-26 12:38:16 UTC (rev 7778) @@ -1180,11 +1180,12 @@ + "<body onload='test()'>\n" + "<form id='myForm' name='myForm'>\n" + " <select id='mySelect'>\n" - + " <option>One</option>\n" - + " <option>Two</option>\n" + + " <option value='One'>One</option>\n" + + " <option value='Two'>Two</option>\n" + " </select>\n" + "</form>\n" + "</body></html>"; + loadPageWithAlerts2(html); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 10:41:57 UTC (rev 7777) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-26 12:38:16 UTC (rev 7778) @@ -2364,7 +2364,6 @@ + "(0, 3, 3)", IE = "event: on(beforeunload) creates/deletes window property instead of adding/removing event listener " + "(0, 3, 3)") - @NotYetImplemented public void test_217() throws Exception { runTest(217); } |
From: <asa...@us...> - 2012-11-27 08:43:08
|
Revision: 7784 http://sourceforge.net/p/htmlunit/code/7784 Author: asashour Date: 2012-11-27 08:43:05 +0000 (Tue, 27 Nov 2012) Log Message: ----------- JavaScript: properties of Array.prototype should be defined in standards mode (IE), thanks to jQuery. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-27 07:10:33 UTC (rev 7783) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-27 08:43:05 UTC (rev 7784) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="asashour"> + JavaScript: properties of Array.prototype should be defined in standards mode (IE). + </action> + <action type="fix" dev="asashour"> JavaScript: correctly process null function handlers. </action> <action type="fix" dev="asashour"> @@ -24,7 +27,7 @@ JavaScript: fix the return value of element.getAttribute() in standards mode (IE). </action> <action type="fix" dev="asashour"> - JavaScript: element.set/getAttribute() should fix the name (e.g. "className") only in Quirks mode (IE). + JavaScript: element.set/getAttribute() should fix the name (e.g. "className") only in quirks mode (IE). </action> <action type="fix" dev="mguillem"> Cookies: use 1970 as two digits year start for the expiration date. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2012-11-27 07:10:33 UTC (rev 7783) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2012-11-27 08:43:05 UTC (rev 7784) @@ -41,6 +41,7 @@ import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.Script; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; @@ -184,6 +185,10 @@ @Override public void initialize() throws IOException, FailingHttpStatusCodeException { final WebWindow enclosingWindow = getEnclosingWindow(); + if (isQuirksMode()) { + removePrototypeProperties((Scriptable) enclosingWindow.getScriptObject(), "Array", + "every", "filter", "forEach", "indexOf", "lastIndexOf", "map", "reduce", "reduceRight", "some"); + } final boolean isAboutBlank = getUrl() == WebClient.URL_ABOUT_BLANK; if (isAboutBlank) { // a frame contains first a faked "about:blank" before its real content specified by src gets loaded @@ -257,6 +262,20 @@ } /** + * Removes prototype properties. + * @param scope the scope + * @param className the class for which properties should be removed + * @param properties the properties to remove + */ + private void removePrototypeProperties(final Scriptable scope, final String className, + final String... properties) { + final ScriptableObject prototype = (ScriptableObject) ScriptableObject.getClassPrototype(scope, className); + for (final String property : properties) { + prototype.delete(property); + } + } + + /** * Adds an action that should be executed once the page has been loaded. * @param action the action */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-11-27 07:10:33 UTC (rev 7783) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-11-27 08:43:05 UTC (rev 7784) @@ -301,8 +301,6 @@ if (!browserVersion.hasFeature(JS_DEFINE_GETTER)) { removePrototypeProperties(window, "Object", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__"); - removePrototypeProperties(window, "Array", "every", "filter", "forEach", "indexOf", "lastIndexOf", "map", - "reduce", "reduceRight", "some"); } // only FF has toSource @@ -356,12 +354,13 @@ /** * Removes prototype properties. - * @param window the scope + * @param scope the scope * @param className the class for which properties should be removed * @param properties the properties to remove */ - private void removePrototypeProperties(final Window window, final String className, final String... properties) { - final ScriptableObject prototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, className); + private void removePrototypeProperties(final Scriptable scope, final String className, + final String... properties) { + final ScriptableObject prototype = (ScriptableObject) ScriptableObject.getClassPrototype(scope, className); for (final String property : properties) { prototype.delete(property); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java 2012-11-27 07:10:33 UTC (rev 7783) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java 2012-11-27 08:43:05 UTC (rev 7784) @@ -25,6 +25,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner.Browsers; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; /** * Tests for {@link HTMLCollection}. @@ -273,4 +274,48 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = { "undefined", "undefined", "undefined", "undefined" }, + DEFAULT = { "function", "function", "function", "function" }) + public void array_prototype() throws Exception { + final String html = "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(typeof Object.prototype.__defineGetter__);\n" + + " alert(typeof Object.prototype.__lookupGetter__);\n" + + " alert(typeof Array.prototype.indexOf);\n" + + " alert(typeof Array.prototype.map);\n" + + " }\n" + + "</script></head>\n" + + "<body onload='test()'></body>\n" + + "</html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = { "undefined", "undefined", "function", "function" }, + DEFAULT = { "function", "function", "function", "function" }) + public void array_prototype_standards() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(typeof Object.prototype.__defineGetter__);\n" + + " alert(typeof Object.prototype.__lookupGetter__);\n" + + " alert(typeof Array.prototype.indexOf);\n" + + " alert(typeof Array.prototype.map);\n" + + " }\n" + + "</script></head>\n" + + "<body onload='test()'></body>\n" + + "</html>"; + + loadPageWithAlerts2(html); + } + } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-27 07:10:33 UTC (rev 7783) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-27 08:43:05 UTC (rev 7784) @@ -3057,7 +3057,6 @@ @Test @Alerts(FF3_6 = "traversing: not(Array) (0, 2, 2)", FF10 = "traversing: not(jQuery) (0, 1, 1)", CHROME = "traversing: not(Array) (0, 2, 2)", IE = "traversing: not(Array) (0, 2, 2)") - @NotYetImplemented(IE) public void test_279() throws Exception { runTest(279); } |
From: <asa...@us...> - 2012-11-28 05:47:52
|
Revision: 7788 http://sourceforge.net/p/htmlunit/code/7788 Author: asashour Date: 2012-11-28 05:47:47 +0000 (Wed, 28 Nov 2012) Log Message: ----------- JavaScript: fix handling relations of document type comment with <html> element (IE), thanks to jQuery Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentTypeTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-27 15:06:14 UTC (rev 7787) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-28 05:47:47 UTC (rev 7788) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="asashour"> + JavaScript: fix handling relations of document type comment with <html> element (IE). + </action> + <action type="fix" dev="asashour"> JavaScript: properties of Array.prototype should be defined in standards mode (IE). </action> <action type="fix" dev="asashour"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-11-27 15:06:14 UTC (rev 7787) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-11-28 05:47:47 UTC (rev 7788) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.DOCTYPE_IS_COMMENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_3; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCONDITIONAL_COMMENTS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLIFRAME_IGNORE_SELFCLOSING; @@ -782,7 +783,16 @@ public void startDTD(final String name, final String publicId, final String systemId) { final DomDocumentType type = new DomDocumentType(page_, name, publicId, systemId); page_.setDocumentType(type); - page_.appendChild(type); + + final Node child; + if (page_.getWebClient().getBrowserVersion().hasFeature(DOCTYPE_IS_COMMENT)) { + child = new DomComment(page_, "DOCTYPE " + name + " PUBLIC \"" + + publicId + "\" \"" + systemId + '"'); + } + else { + child = type; + } + page_.appendChild(child); } /** {@inheritDoc} */ 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 2012-11-27 15:06:14 UTC (rev 7787) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2012-11-28 05:47:47 UTC (rev 7788) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.DOCTYPE_IS_COMMENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EXECCOMMAND_THROWS_ON_WRONG_COMMAND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_160; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_161; @@ -84,8 +83,6 @@ import com.gargoylesoftware.htmlunit.WebResponse; import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.html.BaseFrameElement; -import com.gargoylesoftware.htmlunit.html.DomComment; -import com.gargoylesoftware.htmlunit.html.DomDocumentType; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.html.FrameWindow; @@ -1911,12 +1908,6 @@ */ @Override public SimpleScriptable makeScriptableFor(final DomNode domNode) { - if (domNode instanceof DomDocumentType && getBrowserVersion().hasFeature(DOCTYPE_IS_COMMENT)) { - final DomDocumentType docType = (DomDocumentType) domNode; - final DomComment comment = new DomComment(getHtmlPage(), "DOCTYPE " + docType.getName() + " PUBLIC \"" - + docType.getPublicId() + "\" \"" + docType.getSystemId() + '"'); - return super.makeScriptableFor(comment); - } return super.makeScriptableFor(domNode); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentTypeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentTypeTest.java 2012-11-27 15:06:14 UTC (rev 7787) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentTypeTest.java 2012-11-28 05:47:47 UTC (rev 7788) @@ -15,7 +15,6 @@ package com.gargoylesoftware.htmlunit.javascript.host; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF3_6; -import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE; import org.junit.Test; import org.junit.runner.RunWith; @@ -129,7 +128,6 @@ @Test @Alerts(IE6 = "string", IE7 = "string", IE8 = "string", FF3_6 = { }, DEFAULT = "undefined") - @NotYetImplemented(IE) public void html_previousSibling() throws Exception { final String html = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" + " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n" @@ -139,7 +137,7 @@ + " <script>\n" + " function test() {\n" + " if (document.body.parentElement) {\n" - + " //.text is defined for Comment in IE" + + " //.text is defined for Comment in IE\n" + " alert(typeof document.body.parentElement.previousSibling.text);\n" + " }\n" + " }\n" @@ -155,10 +153,10 @@ * @throws Exception if the test fails */ @Test - @Alerts(IE6 = { "[object]", "[object]" }, IE7 = { "[object]", "[object]" }, - IE8 = { "[object]", "[object]" }, + @Alerts(IE6 = { "[object HTMLCommentElement]", "[object HTMLHtmlElement]" }, + IE7 = { "[object HTMLCommentElement]", "[object HTMLHtmlElement]" }, + IE8 = { "[object HTMLCommentElement]", "[object HTMLHtmlElement]" }, DEFAULT = { "[object DocumentType]", "[object HTMLHtmlElement]" }) - @NotYetImplemented(IE) public void document_children() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html>\n" + "<head>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-27 15:06:14 UTC (rev 7787) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-28 05:47:47 UTC (rev 7788) @@ -3275,7 +3275,6 @@ @Test @Alerts(FF3_6 = "manipulation: text() (0, 5, 5)", FF10 = "manipulation: text(undefined) (0, 1, 1)", CHROME = "manipulation: text() (0, 5, 5)", IE = "manipulation: text() (0, 5, 5)") - @NotYetImplemented(IE) public void test_300() throws Exception { runTest(300); } |
From: <asa...@us...> - 2012-11-28 18:21:59
|
Revision: 7799 http://sourceforge.net/p/htmlunit/code/7799 Author: asashour Date: 2012-11-28 18:21:56 +0000 (Wed, 28 Nov 2012) Log Message: ----------- Fixing build Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2012-11-28 14:45:10 UTC (rev 7798) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2012-11-28 18:21:56 UTC (rev 7799) @@ -43,7 +43,7 @@ */ class DefaultElementFactory implements ElementFactory { - /* + /* * Whenever you add a tag, please add corresponding test cases in the below: * There are few areas, where we iterate over all elements, you can search in the project for ("xmp") * For example HTMLParser2Test.childNodes_xmp Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-28 14:45:10 UTC (rev 7798) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-28 18:21:56 UTC (rev 7799) @@ -17,6 +17,8 @@ import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF3_6; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE; +import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE6; +import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE7; import static org.junit.Assert.fail; import org.eclipse.jetty.server.Server; @@ -4266,6 +4268,7 @@ FF10 = "css: internal ref to elem.runtimeStyle (bug #7608) (0, 1, 1)", CHROME = "css: :visible selector works properly on children with a hidden parent (bug #4512) (0, 1, 1)", IE = "css: jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095) (0, 4, 4)") + @NotYetImplemented(FF) public void test_385() throws Exception { runTest(385); } @@ -4354,6 +4357,7 @@ + "els, see #11311 (0, 1, 1)", CHROME = "css: can't get background-position in IE<9, see #10796 (0, 8, 8)", IE = "css: widows & orphans #8936 (0, 4, 4)") + @NotYetImplemented({ IE6, IE7 }) public void test_392() throws Exception { runTest(392); } |
From: <rb...@us...> - 2012-11-28 20:56:44
|
Revision: 7801 http://sourceforge.net/p/htmlunit/code/7801 Author: rbri Date: 2012-11-28 20:56:40 +0000 (Wed, 28 Nov 2012) Log Message: ----------- Fix URL manipulation (UrlUtils) for file url's containing drive letter. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/util/UrlUtilsTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-28 20:56:40 UTC (rev 7801) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="rbri"> + Fix URL manipulation (UrlUtils) for file url's containing drive letter. + </action> <action type="fix" dev="asashour"> JavaScript: fix handling relations of document type comment with <html> element (IE). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2012-11-28 20:56:40 UTC (rev 7801) @@ -390,9 +390,8 @@ hostname = host; port = -1; } - final URL url1 = UrlUtils.getUrlWithNewHost(getUrl(), hostname); - final URL url2 = UrlUtils.getUrlWithNewPort(url1, port); - setUrl(url2); + final URL url = UrlUtils.getUrlWithNewHostAndPort(getUrl(), hostname, port); + setUrl(url); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLAnchorElement.java 2012-11-28 20:56:40 UTC (rev 7801) @@ -44,6 +44,7 @@ * @author Ahmed Ashour * @author Sudhan Moghe * @author Daniel Gredler + * @author Ronald Brill */ @JsxClass(domClasses = HtmlAnchor.class) public class HTMLAnchorElement extends HTMLElement { @@ -277,9 +278,8 @@ hostname = host; port = -1; } - final URL url1 = UrlUtils.getUrlWithNewHost(getUrl(), hostname); - final URL url2 = UrlUtils.getUrlWithNewPort(url1, port); - setUrl(url2); + final URL url = UrlUtils.getUrlWithNewHostAndPort(getUrl(), hostname, port); + setUrl(url); } /** 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 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2012-11-28 20:56:40 UTC (rev 7801) @@ -800,7 +800,7 @@ final boolean file = "file".equals(protocol); if (file) { try { - url = UrlUtils.getUrlWithNewPort(UrlUtils.getUrlWithNewHost(url, "LOCAL_FILESYSTEM"), 0); + url = UrlUtils.getUrlWithNewHostAndPort(url, "LOCAL_FILESYSTEM", 0); } catch (final MalformedURLException e) { throw new RuntimeException(e); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/util/UrlUtils.java 2012-11-28 20:56:40 UTC (rev 7801) @@ -34,6 +34,7 @@ * @author Sudhan Moghe * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ public final class UrlUtils { private static final BitSet PATH_ALLOWED_CHARS = new BitSet(256); @@ -298,7 +299,7 @@ * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewProtocol(final URL u, final String newProtocol) throws MalformedURLException { - return createNewUrl(newProtocol, u.getHost(), u.getPort(), u.getPath(), u.getRef(), u.getQuery()); + return createNewUrl(newProtocol, u.getAuthority(), u.getPath(), u.getRef(), u.getQuery()); } /** @@ -308,11 +309,25 @@ * @return a new URL identical to the specified URL, except using the specified host * @throws MalformedURLException if there is a problem creating the new URL */ - public static URL getUrlWithNewHost(final URL u, final String newHost) throws MalformedURLException { + public static URL getUrlWithNewHost(final URL u, final String newHost) + throws MalformedURLException { return createNewUrl(u.getProtocol(), newHost, u.getPort(), u.getPath(), u.getRef(), u.getQuery()); } /** + * Creates and returns a new URL identical to the specified URL, except using the specified host. + * @param u the URL on which to base the returned URL + * @param newHost the new host to use in the returned URL + * @param newPort the new port to use in the returned URL + * @return a new URL identical to the specified URL, except using the specified host + * @throws MalformedURLException if there is a problem creating the new URL + */ + public static URL getUrlWithNewHostAndPort(final URL u, final String newHost, final int newPort) + throws MalformedURLException { + return createNewUrl(u.getProtocol(), newHost, newPort, u.getPath(), u.getRef(), u.getQuery()); + } + + /** * Creates and returns a new URL identical to the specified URL, except using the specified port. * @param u the URL on which to base the returned URL * @param newPort the new port to use in the returned URL @@ -331,7 +346,7 @@ * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewPath(final URL u, final String newPath) throws MalformedURLException { - return createNewUrl(u.getProtocol(), u.getHost(), u.getPort(), newPath, u.getRef(), u.getQuery()); + return createNewUrl(u.getProtocol(), u.getAuthority(), newPath, u.getRef(), u.getQuery()); } /** @@ -342,7 +357,7 @@ * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewRef(final URL u, final String newRef) throws MalformedURLException { - return createNewUrl(u.getProtocol(), u.getHost(), u.getPort(), u.getPath(), newRef, u.getQuery()); + return createNewUrl(u.getProtocol(), u.getAuthority(), u.getPath(), newRef, u.getQuery()); } /** @@ -353,7 +368,7 @@ * @throws MalformedURLException if there is a problem creating the new URL */ public static URL getUrlWithNewQuery(final URL u, final String newQuery) throws MalformedURLException { - return createNewUrl(u.getProtocol(), u.getHost(), u.getPort(), u.getPath(), u.getRef(), newQuery); + return createNewUrl(u.getProtocol(), u.getAuthority(), u.getPath(), u.getRef(), newQuery); } /** @@ -391,11 +406,65 @@ } s.append(ref); } + final URL url = new URL(s.toString()); return url; } /** + * Creates a new URL based on the specified fragments. + * @param protocol the protocol to use (may not be <tt>null</tt>) + * @param authority the authority to use (may not be <tt>null</tt>) + * @param path the path to use (may be <tt>null</tt> and may omit the initial <tt>'/'</tt>) + * @param ref the reference to use (may be <tt>null</tt> and must not include the <tt>'#'</tt>) + * @param query the query to use (may be <tt>null</tt> and must not include the <tt>'?'</tt>) + * @return a new URL based on the specified fragments + * @throws MalformedURLException if there is a problem creating the new URL + */ + private static URL createNewUrl(final String protocol, final String authority, + final String path, final String ref, final String query) throws MalformedURLException { + + // pre-compute length of StringBuffer + int len = protocol.length() + 1; + if (authority != null && authority.length() > 0) { + len += 2 + authority.length(); + } + if (path != null) { + len += path.length(); + } + if (query != null) { + len += 1 + query.length(); + } + if (ref != null) { + len += 1 + ref.length(); + } + + final StringBuffer s = new StringBuffer(len); + s.append(protocol); + s.append(":"); + if (authority != null && authority.length() > 0) { + s.append("//"); + s.append(authority); + } + if (path != null) { + s.append(path); + } + if (query != null) { + s.append('?'); + s.append(query); + } + if (ref != null) { + if (!((ref.length() > 0) && ('#' == ref.charAt(0)))) { + s.append("#"); + } + s.append(ref); + } + + final URL url = new URL(s.toString()); + return url; + } + + /** * Resolves a given relative URL against a base URL. See * <a href="http://www.faqs.org/rfcs/rfc1808.html">RFC1808</a> * Section 4 for more details. Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/util/UrlUtilsTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/util/UrlUtilsTest.java 2012-11-28 18:31:51 UTC (rev 7800) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/util/UrlUtilsTest.java 2012-11-28 20:56:40 UTC (rev 7801) @@ -28,6 +28,7 @@ * @author Martin Tamme * @author Sudhan Moghe * @author Ahmed Ashour + * @author Ronald Brill */ public class UrlUtilsTest extends SimpleWebTestCase { @@ -55,10 +56,26 @@ * @throws Exception if the test fails */ @Test + public void getUrlWithNewHostAndPort() throws Exception { + final URL a = new URL("http://my.home.com/index.html?query#ref"); + URL b = UrlUtils.getUrlWithNewHostAndPort(a, "your.home.com", 4711); + assertEquals("http://your.home.com:4711/index.html?query#ref", b.toExternalForm()); + + b = UrlUtils.getUrlWithNewHostAndPort(a, "your.home.com", -1); + assertEquals("http://your.home.com/index.html?query#ref", b.toExternalForm()); + } + + /** + * @throws Exception if the test fails + */ + @Test public void getUrlWithNewPort() throws Exception { final URL a = new URL("http://my.home.com/index.html?query#ref"); - final URL b = UrlUtils.getUrlWithNewPort(a, 8080); + URL b = UrlUtils.getUrlWithNewPort(a, 8080); assertEquals("http://my.home.com:8080/index.html?query#ref", b.toExternalForm()); + + b = UrlUtils.getUrlWithNewPort(a, -1); + assertEquals("http://my.home.com/index.html?query#ref", b.toExternalForm()); } /** @@ -76,17 +93,30 @@ */ @Test public void getUrlWithNewRef() throws Exception { - final URL a = new URL("http://my.home.com/index.html?query#ref"); - final URL b = UrlUtils.getUrlWithNewRef(a, "abc"); + URL a = new URL("http://my.home.com/index.html?query#ref"); + URL b = UrlUtils.getUrlWithNewRef(a, "abc"); assertEquals("http://my.home.com/index.html?query#abc", b.toExternalForm()); - final URL c = new URL("http://my.home.com/#ref"); - final URL d = UrlUtils.getUrlWithNewRef(c, "xyz"); - assertEquals("http://my.home.com/#xyz", d.toExternalForm()); + a = new URL("http://my.home.com/#ref"); + b = UrlUtils.getUrlWithNewRef(a, "xyz"); + assertEquals("http://my.home.com/#xyz", b.toExternalForm()); - final URL e = new URL("http://my.home.com#ref"); - final URL f = UrlUtils.getUrlWithNewRef(e, "xyz"); - assertEquals("http://my.home.com#xyz", f.toExternalForm()); + a = new URL("http://my.home.com#ref"); + b = UrlUtils.getUrlWithNewRef(a, "xyz"); + assertEquals("http://my.home.com#xyz", b.toExternalForm()); + + a = new URL("http://my.home.com"); + b = UrlUtils.getUrlWithNewRef(a, "xyz"); + assertEquals("http://my.home.com#xyz", b.toExternalForm()); + + a = new URL("http://my.home.com"); + b = UrlUtils.getUrlWithNewRef(a, null); + assertEquals("http://my.home.com", b.toExternalForm()); + + a = new URL("http://my.home.com"); + b = UrlUtils.getUrlWithNewRef(a, ""); + assertEquals("http://my.home.com#", b.toExternalForm()); + } /** @@ -94,9 +124,18 @@ */ @Test public void getUrlWithNewQuery() throws Exception { - final URL a = new URL("http://my.home.com/index.html?query#ref"); - final URL b = UrlUtils.getUrlWithNewQuery(a, "xyz"); + URL a = new URL("http://my.home.com/index.html?query#ref"); + URL b = UrlUtils.getUrlWithNewQuery(a, "xyz"); assertEquals("http://my.home.com/index.html?xyz#ref", b.toExternalForm()); + + // DOS + a = new URL("file://c:/index.html?query"); + b = UrlUtils.getUrlWithNewQuery(a, "xyz"); + assertEquals("file://c:/index.html?xyz", b.toExternalForm()); + // UNIX + a = new URL("file:///index.html?query"); + b = UrlUtils.getUrlWithNewQuery(a, "xyz"); + assertEquals("file:/index.html?xyz", b.toExternalForm()); } /** |
From: <asa...@us...> - 2012-11-29 06:24:21
|
Revision: 7803 http://sourceforge.net/p/htmlunit/code/7803 Author: asashour Date: 2012-11-29 06:24:12 +0000 (Thu, 29 Nov 2012) Log Message: ----------- JavaScript: HTMLElement.outerHTML to have lower cases for unknown elements (IE). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUnknownElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-29 05:54:49 UTC (rev 7802) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-29 06:24:12 UTC (rev 7803) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + JavaScript: HTMLElement.outerHTML to have lower cases for unknown elements (IE). + </action> + <action type="fix" dev="rbri"> Fix URL manipulation (UrlUtils) for file url's containing drive letter. </action> <action type="fix" dev="asashour"> 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 2012-11-29 05:54:49 UTC (rev 7802) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2012-11-29 06:24:12 UTC (rev 7803) @@ -907,9 +907,10 @@ } else if (html) { final HtmlElement element = (HtmlElement) node; + final HTMLElement scriptObject = (HTMLElement) node.getScriptObject(); final boolean isUpperCase = getBrowserVersion().hasFeature(HTMLELEMENT_OUTER_HTML_UPPER_CASE); String tag = element.getTagName(); - if (isUpperCase) { + if (isUpperCase && !scriptObject.isLowerCaseInOuterHtml()) { tag = tag.toUpperCase(); } buffer.append("<").append(tag); @@ -933,7 +934,7 @@ buffer.append(">"); // Add the children. printChildren(buffer, node, html); - if (!((HTMLElement) node.getScriptObject()).isEndTagForbidden()) { + if (!scriptObject.isEndTagForbidden()) { buffer.append("</").append(tag).append(">"); } } @@ -2835,4 +2836,13 @@ protected boolean isEndTagForbidden() { return false; } + + /** + * Returns whether the tag is lower case in .outerHTML/.innerHTML. + * It seems to be a feature for HTML5 elements for IE. + * @return whether the tag is lower case in .outerHTML/.innerHTML + */ + protected boolean isLowerCaseInOuterHtml() { + return false; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUnknownElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUnknownElement.java 2012-11-29 05:54:49 UTC (rev 7802) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUnknownElement.java 2012-11-29 06:24:12 UTC (rev 7803) @@ -33,13 +33,6 @@ public class HTMLUnknownElement extends HTMLElement { /** - * Creates an instance. - */ - public HTMLUnknownElement() { - // Empty. - } - - /** * Gets the JavaScript property "nodeName" for the current node. * @return the node name */ @@ -63,4 +56,11 @@ } return super.getClassName(); } + + /** + * {@inheritDoc} + */ + protected boolean isLowerCaseInOuterHtml() { + return true; + } } 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 2012-11-29 05:54:49 UTC (rev 7802) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2012-11-29 06:24:12 UTC (rev 7803) @@ -2761,7 +2761,6 @@ */ @Test @Alerts(DEFAULT = "<audio></audio>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_audio() throws Exception { loadPageWithAlerts2(outerHTML("audio")); } @@ -2873,7 +2872,6 @@ */ @Test @Alerts(DEFAULT = "<canvas></canvas>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_canvas() throws Exception { loadPageWithAlerts2(outerHTML("canvas")); } @@ -3390,7 +3388,6 @@ */ @Test @Alerts(DEFAULT = "<progress></progress>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_progress() throws Exception { loadPageWithAlerts2(outerHTML("progress")); } @@ -3445,7 +3442,6 @@ */ @Test @Alerts(DEFAULT = "<source>", IE = "<source></source>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_source() throws Exception { loadPageWithAlerts2(outerHTML("source")); } @@ -3655,7 +3651,6 @@ */ @Test @Alerts(DEFAULT = "<video></video>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_video() throws Exception { loadPageWithAlerts2(outerHTML("video")); } @@ -3683,6 +3678,15 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "<abcdefg></abcdefg>", FF3_6 = "undefined", FF10 = "undefined") + public void outerHTML_arbitrary() throws Exception { + loadPageWithAlerts2(outerHTML("abcdefg")); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(IE = { "DIV", "section", "<DIV></DIV>", "<section></section>" }, FF3_6 = { "DIV", "SECTION", "undefined", "undefined" }, FF10 = { "DIV", "SECTION", "undefined", "undefined" }, Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-29 05:54:49 UTC (rev 7802) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-29 06:24:12 UTC (rev 7803) @@ -3911,6 +3911,7 @@ @Test @Alerts(FF3_6 = "manipulation: detach() (0, 9, 9)", FF10 = "manipulation: empty() (0, 3, 3)", CHROME = "manipulation: detach() (0, 9, 9)", IE = "manipulation: detach() (0, 9, 9)") + @NotYetImplemented(IE) public void test_355() throws Exception { runTest(355); } @@ -4005,7 +4006,6 @@ FF10 = "manipulation: jQuery.fragments cache expectations (0, 10, 10)", CHROME = "manipulation: Cloned, detached HTML5 elems (#10667,10670) (0, 7, 7)", IE = "manipulation: Cloned, detached HTML5 elems (#10667,10670) (0, 7, 7)") - @NotYetImplemented(IE) public void test_363() throws Exception { runTest(363); } |
From: <asa...@us...> - 2012-11-29 07:18:56
|
Revision: 7804 http://sourceforge.net/p/htmlunit/code/7804 Author: asashour Date: 2012-11-29 07:18:51 +0000 (Thu, 29 Nov 2012) Log Message: ----------- JavaScript: initial support for HTMLBGSoundElement (IE). 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/configuration/JavaScriptConfiguration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBGSoundElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBackgroundSoundTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-29 07:18:51 UTC (rev 7804) @@ -8,7 +8,10 @@ <body> <release version="2.12" date="???" description="Bugfixes"> - <action type="fix" dev="rbri"> + <action type="add" dev="asashour"> + JavaScript: initial support for HTMLBGSoundElement (IE). + </action> + <action type="fix" dev="asashour"> JavaScript: HTMLElement.outerHTML to have lower cases for unknown elements (IE). </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 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -544,6 +544,10 @@ @BrowserFeature(@WebBrowser(value = IE, minVersion = 7)) HTMLABBREVIATED, + /** [object HTMLBGSoundElement]. */ + @BrowserFeature(@WebBrowser(IE)) + HTMLBGSOUND, + /** Indicates that comment nodes should be treated similar to elements, e.g. getElementsByTagName(). */ @BrowserFeature(@WebBrowser(IE)) HTMLCOLLECTION_COMMENT_IS_ELEMENT, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -125,6 +125,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAppletElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAreaElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAudioElement; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBGSoundElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBRElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement; @@ -288,7 +289,7 @@ Float32Array.class, Float64Array.class, FormChild.class, FormField.class, Geolocation.class, History.class, HTMLAnchorElement.class, HTMLAppletElement.class, HTMLAreaElement.class, HTMLAudioElement.class, - HTMLBRElement.class, HTMLBaseElement.class, HTMLBaseFontElement.class, + HTMLBRElement.class, HTMLBaseElement.class, HTMLBaseFontElement.class, HTMLBGSoundElement.class, HTMLBodyElement.class, HTMLButtonElement.class, HTMLCanvasElement.class, HTMLCollection.class, HTMLCollectionTags.class, HTMLDListElement.class, HTMLDelElement.class, HTMLDirectoryElement.class, HTMLDivElement.class, HTMLDocument.class, HTMLElement.class, HTMLEmbedElement.class, HTMLFieldSetElement.class, Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBGSoundElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBGSoundElement.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBGSoundElement.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2002-2012 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 static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBGSOUND; + +import com.gargoylesoftware.htmlunit.html.HtmlBackgroundSound; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; + +/** + * The JavaScript object "HTMLBGSoundElement". + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@JsxClass(domClasses = HtmlBackgroundSound.class) +public class HTMLBGSoundElement extends HTMLElement { + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && !getBrowserVersion().hasFeature(HTMLBGSOUND)) { + return "HTMLSpanElement"; + } + return super.getClassName(); + } + + /** + * {@inheritDoc} + */ + protected boolean isEndTagForbidden() { + return true; + } + +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBGSoundElement.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -22,7 +22,6 @@ import com.gargoylesoftware.htmlunit.html.HtmlAbbreviated; import com.gargoylesoftware.htmlunit.html.HtmlAcronym; import com.gargoylesoftware.htmlunit.html.HtmlAddress; -import com.gargoylesoftware.htmlunit.html.HtmlBackgroundSound; import com.gargoylesoftware.htmlunit.html.HtmlBidirectionalOverride; import com.gargoylesoftware.htmlunit.html.HtmlBig; import com.gargoylesoftware.htmlunit.html.HtmlBlink; @@ -62,7 +61,7 @@ * @author Ahmed Ashour * @author Daniel Gredler */ -@JsxClass(domClasses = { HtmlAbbreviated.class, HtmlAcronym.class, HtmlAddress.class, HtmlBackgroundSound.class, +@JsxClass(domClasses = { HtmlAbbreviated.class, HtmlAcronym.class, HtmlAddress.class, HtmlBidirectionalOverride.class, HtmlBig.class, HtmlBold.class, HtmlBlink.class, HtmlCenter.class, HtmlCitation.class, HtmlCode.class, HtmlDefinition.class, HtmlDefinitionDescription.class, HtmlDefinitionTerm.class, HtmlEmphasis.class, HtmlItalic.class, HtmlKeyboard.class, HtmlListing.class, Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBackgroundSoundTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBackgroundSoundTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBackgroundSoundTest.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2002-2012 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.SimpleWebTestCase; + +/** + * Tests for {@link HtmlBackgroundSound}. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@RunWith(BrowserRunner.class) +public class HtmlBackgroundSoundTest extends SimpleWebTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = "[object HTMLBGSoundElement]", FF = "[object HTMLSpanElement]", CHROME = "[object HTMLElement]") + public void simpleScriptable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(document.getElementById('myId'));\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + " <bgsound id='myId'/>\n" + + "</body></html>"; + + final HtmlPage page = loadPageWithAlerts(html); + assertTrue(HtmlBackgroundSound.class.isInstance(page.getHtmlElementById("myId"))); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBackgroundSoundTest.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -2770,7 +2770,6 @@ */ @Test @Alerts(DEFAULT = "<bgsound>", IE = "<BGSOUND>", FF3_6 = "undefined", FF10 = "undefined") - @NotYetImplemented(IE) public void outerHTML_bgsound() throws Exception { loadPageWithAlerts2(outerHTML("bgsound")); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-29 06:24:12 UTC (rev 7803) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-29 07:18:51 UTC (rev 7804) @@ -3911,7 +3911,6 @@ @Test @Alerts(FF3_6 = "manipulation: detach() (0, 9, 9)", FF10 = "manipulation: empty() (0, 3, 3)", CHROME = "manipulation: detach() (0, 9, 9)", IE = "manipulation: detach() (0, 9, 9)") - @NotYetImplemented(IE) public void test_355() throws Exception { runTest(355); } |
From: <mgu...@us...> - 2012-11-29 09:19:24
|
Revision: 7805 http://sourceforge.net/p/htmlunit/code/7805 Author: mguillem Date: 2012-11-29 09:19:18 +0000 (Thu, 29 Nov 2012) Log Message: ----------- Escape "%%" in query string to avoid IllegalArgumentException (note that FF doesn't escape "%%") Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient3Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-29 07:18:51 UTC (rev 7804) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-29 09:19:18 UTC (rev 7805) @@ -8,14 +8,17 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="mguillem"> + Escape "%%" in query string to avoid IllegalArgumentException. + </action> <action type="add" dev="asashour"> JavaScript: initial support for HTMLBGSoundElement (IE). </action> <action type="fix" dev="asashour"> - JavaScript: HTMLElement.outerHTML to have lower cases for unknown elements (IE). + JavaScript: HTMLElement.outerHTML use lower case for unknown elements (IE). </action> <action type="fix" dev="rbri"> - Fix URL manipulation (UrlUtils) for file url's containing drive letter. + Fix URL manipulation (UrlUtils) for file URLs containing drive letter. </action> <action type="fix" dev="asashour"> JavaScript: fix handling relations of document type comment with <html> element (IE). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-11-29 07:18:51 UTC (rev 7804) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-11-29 09:19:18 UTC (rev 7805) @@ -161,7 +161,7 @@ } catch (final URISyntaxException e) { throw new IOException("Unable to create URI from URL: " + url.toExternalForm() - + " (reason: " + e.getMessage() + ")"); + + " (reason: " + e.getMessage() + ")", e); } final HttpHost hostConfiguration = getHostConfiguration(request); setProxy(httpClient, request); @@ -247,7 +247,7 @@ // URIUtils.createURI is deprecated but as of httpclient-4.2.1, URIBuilder doesn't work here as it encodes path // what shouldn't happen here URI uri = URIUtils.createURI(url.getProtocol(), url.getHost(), url.getPort(), url.getPath(), - url.getQuery(), null); + escapeQuery(url.getQuery()), null); final HttpRequestBase httpMethod = buildHttpMethod(webRequest.getHttpMethod(), uri); if (!(httpMethod instanceof HttpEntityEnclosingRequest)) { // this is the case for GET as well as TRACE, DELETE, OPTIONS and HEAD @@ -382,6 +382,13 @@ return httpMethod; } + private String escapeQuery(final String query) { + if (query == null) { + return null; + } + return query.replace("%%", "%25%25"); + } + private Charset getCharset(final String charset, final List<NameValuePair> pairs) { for (final NameValuePair pair : pairs) { if (pair instanceof KeyDataPair) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient3Test.java 2012-11-29 07:18:51 UTC (rev 7804) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebClient3Test.java 2012-11-29 09:19:18 UTC (rev 7805) @@ -32,6 +32,7 @@ import org.openqa.selenium.htmlunit.HtmlUnitDriver; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.html.HtmlInlineFrame; import com.gargoylesoftware.htmlunit.util.NameValuePair; @@ -167,6 +168,42 @@ } /** + * Was causing a "java.net.URISyntaxException: Malformed escape pair" + * as of HtmlUnit-2.12-SNAPSHOT on Nov. 29, 2012. + * HtmlUnit now escapes the "%%" to "%25%25" to build a valid URL but FF doesn't care + * and sends the invalid "%%" sequence as it. + * This will be quite difficult to simulate FF here as HttpClient's HttpRequestBase + * uses URI and "%%" can't be part of the query string for a URI. + * @throws Exception if the test fails + */ + @Test + @NotYetImplemented + public void escapeRequestQuery2a() throws Exception { + getMockWebConnection().setDefaultResponse(""); + + final URL url = new URL(getDefaultUrl(), "foo.png?cb=%%RANDOM_NUMBER%%"); + loadPage2("", url); + + assertEquals(url, getMockWebConnection().getLastWebRequest().getUrl()); + } + + /** + * Was causing a "java.net.URISyntaxException: Malformed escape pair" + * as of HtmlUnit-2.12-SNAPSHOT on Nov. 29, 2012. + * This is a simplified version of {@link #escapeRequestQuery2a()} only testing + * that no exception is thrown. The request performed is not fully correct. + * This test can be removed once {@link #escapeRequestQuery2a()} runs correctly. + * @throws Exception if the test fails + */ + @Test + public void escapeRequestQuery2b() throws Exception { + getMockWebConnection().setDefaultResponse(""); + + final URL url = new URL(getDefaultUrl(), "foo.png?cb=%%RANDOM_NUMBER%%"); + loadPage2("", url); + } + + /** * Regression test for issue 3193004. * Ensure that the click returns once the target page has been loaded into the target window. * @throws Exception if an error occurs Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java 2012-11-29 07:18:51 UTC (rev 7804) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java 2012-11-29 09:19:18 UTC (rev 7805) @@ -421,7 +421,7 @@ private void doService(final HttpServletRequest request, final HttpServletResponse response) throws Exception { - final String url = request.getRequestURL().toString(); + String url = request.getRequestURL().toString(); if (LOG.isDebugEnabled()) { LOG.debug(request.getMethod() + " " + url); } @@ -440,6 +440,28 @@ Thread.sleep(ms); } + // copy parameters + final List<NameValuePair> requestParameters = new ArrayList<NameValuePair>(); + try { + for (final Enumeration<String> paramNames = request.getParameterNames(); + paramNames.hasMoreElements();) { + final String name = paramNames.nextElement(); + final String[] values = request.getParameterValues(name); + for (final String value : values) { + requestParameters.add(new NameValuePair(name, value)); + } + } + } + catch (final IllegalArgumentException e) { + // Jetty 8.1.7 throws it in getParameterNames for a query like "cb=%%RANDOM_NUMBER%%" + // => we should use a more low level test server + requestParameters.clear(); + final String query = request.getQueryString(); + if (query != null) { + url += "?" + query; + } + } + final URL requestedUrl = new URL(url); final WebRequest webRequest = new WebRequest(requestedUrl); webRequest.setHttpMethod(HttpMethod.valueOf(request.getMethod())); @@ -451,16 +473,6 @@ webRequest.setAdditionalHeader(headerName, headerValue); } - // copy parameters - final List<NameValuePair> requestParameters = new ArrayList<NameValuePair>(); - for (final Enumeration<String> paramNames = request.getParameterNames(); paramNames.hasMoreElements();) { - final String name = paramNames.nextElement(); - final String[] values = request.getParameterValues(name); - for (final String value : values) { - requestParameters.add(new NameValuePair(name, value)); - } - } - if ("PUT".equals(request.getMethod()) && request.getContentLength() > 0) { final byte[] buffer = new byte[request.getContentLength()]; request.getInputStream().readLine(buffer, 0, buffer.length); |
From: <asa...@us...> - 2012-11-29 21:08:54
|
Revision: 7807 http://sourceforge.net/p/htmlunit/code/7807 Author: asashour Date: 2012-11-29 21:08:48 +0000 (Thu, 29 Nov 2012) Log Message: ----------- - JavaScript: .outerHTML of "basefont", "col", "embed" and "wbr" have forbidden end tag. - JavaScript: HTMLElement.outerHTML use lower case for "spacer" and "multicol" elements (IE). 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/HTMLBaseFontElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLEmbedElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpacerElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLTableColElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLWBRElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-29 20:13:04 UTC (rev 7806) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-29 21:08:48 UTC (rev 7807) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + JavaScript: .outerHTML of "basefont", "col", "embed" and "wbr" have forbidden end tag (FF). + </action> <action type="fix" dev="mguillem"> Escape "%%" in query string to avoid IllegalArgumentException. </action> @@ -15,7 +18,7 @@ JavaScript: initial support for HTMLBGSoundElement (IE). </action> <action type="fix" dev="asashour"> - JavaScript: HTMLElement.outerHTML use lower case for unknown elements (IE). + JavaScript: HTMLElement.outerHTML use lower case |
From: <asa...@us...> - 2012-12-01 07:50:54
|
Revision: 7813 http://sourceforge.net/p/htmlunit/code/7813 Author: asashour Date: 2012-12-01 07:50:50 +0000 (Sat, 01 Dec 2012) Log Message: ----------- WebClient.closeAllWindows() to delete all temporary created big files. Issue 1344 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-01 07:50:50 UTC (rev 7813) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1344"> + WebClient.closeAllWindows() to delete all temporary created big files. + </action> <action type="fix" dev="asashour"> JavaScript: .outerHTML of "basefont", "col", "embed" and "wbr" have forbidden end tag (FF). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/HttpWebConnection.java 2012-12-01 07:50:50 UTC (rev 7813) @@ -133,6 +133,7 @@ private String virtualHost_; private final CookieSpecFactory htmlUnitCookieSpecFactory_; private final WebClientOptions usedOptions_ = new WebClientOptions(); + private List<File> temporaryFiles_; /** * Creates a new HTTP web connection instance. @@ -655,7 +656,7 @@ return new DownloadedContent.InMemory(new byte[] {}); } - return downloadContent(httpEntity.getContent()); + return downloadContent(this, httpEntity.getContent()); } /** @@ -665,6 +666,11 @@ * @throws IOException in case of read issues */ public static DownloadedContent downloadContent(final InputStream is) throws IOException { + return downloadContent(null, is); + } + + private static DownloadedContent downloadContent(final HttpWebConnection connection, final InputStream is) + throws IOException { if (is == null) { return new DownloadedContent.InMemory(new byte[] {}); } @@ -683,6 +689,12 @@ bos.writeTo(fos); // what we have already read IOUtils.copyLarge(is, fos); // what remains from the server response fos.close(); + if (connection != null) { + if (connection.temporaryFiles_ == null) { + connection.temporaryFiles_ = new ArrayList<File>(); + } + connection.temporaryFiles_.add(file); + } return new DownloadedContent.OnFile(file, true); } } @@ -726,6 +738,11 @@ httpClient_.getConnectionManager().shutdown(); httpClient_ = null; } + if (temporaryFiles_ != null) { + for (final File file : temporaryFiles_) { + file.delete(); + } + } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-12-01 06:27:27 UTC (rev 7812) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-12-01 07:50:50 UTC (rev 7813) @@ -5391,7 +5391,7 @@ // */ // @Test // @Alerts(FF3_6 = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", -// FF10 = "ajax: jQuery ajax - atom+xml (0, 1, 1)", CHROME = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", +//FF10 = "ajax: jQuery ajax - atom+xml (0, 1, 1)", CHROME = "ajax: jQuery ajax - failing cross-domain (0, 2, 2)", // IE = "ajax: jQuery.ajax - If-Modified-Since support (no cache) (0, 3, 3)") // @NotYetImplemented(FF) // public void test_480() throws Exception { |
From: <asa...@us...> - 2012-12-01 08:32:31
|
Revision: 7814 http://sourceforge.net/p/htmlunit/code/7814 Author: asashour Date: 2012-12-01 08:32:29 +0000 (Sat, 01 Dec 2012) Log Message: ----------- trivial: remove deprecation usage Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlScriptTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2012-12-01 07:50:50 UTC (rev 7813) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2012-12-01 08:32:29 UTC (rev 7814) @@ -529,7 +529,7 @@ * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span> * * <p>Throws a {@link FailingHttpStatusCodeException} if the request's status code indicates a request - * failure and {@link #isThrowExceptionOnFailingStatusCode()} returns <tt>true</tt>. + * failure and {@link WebClientOptions#isThrowExceptionOnFailingStatusCode()} returns <tt>true</tt>. * * @param webResponse the response which may trigger a {@link FailingHttpStatusCodeException} */ @@ -1496,7 +1496,7 @@ else if (status >= HttpStatus.SC_MOVED_PERMANENTLY && status <= HttpStatus.SC_TEMPORARY_REDIRECT && status != HttpStatus.SC_NOT_MODIFIED - && isRedirectEnabled()) { + && getOptions().isRedirectEnabled()) { final URL newUrl; String locationString = null; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlScriptTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlScriptTest.java 2012-12-01 07:50:50 UTC (rev 7813) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlScriptTest.java 2012-12-01 08:32:29 UTC (rev 7814) @@ -50,7 +50,7 @@ * results in a {@link FailingHttpStatusCodeException}, depending on how the client has been * configured. * - * @see WebClient#isThrowExceptionOnFailingStatusCode() + * @see com.gargoylesoftware.htmlunit.WebClientOptions#isThrowExceptionOnFailingStatusCode() * @throws Exception if an error occurs */ @Test |
From: <asa...@us...> - 2012-12-05 11:59:12
|
Revision: 7829 http://sourceforge.net/p/htmlunit/code/7829 Author: asashour Date: 2012-12-05 11:59:08 +0000 (Wed, 05 Dec 2012) Log Message: ----------- - Fix a potential ConcurrentModificationException, on calling WebClient.getWebWindows(). - Reason: Webclient.windows_, which is created by "Collections.synchronizedList()" must always be inside 'synchronized' Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-05 09:44:07 UTC (rev 7828) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-05 11:59:08 UTC (rev 7829) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + Fix a potential ConcurrentModificationException, on calling WebClient.getWebWindows(). + </action> <action type="fix" dev="asashour" issue="1344"> WebClient.closeAllWindows() to delete all temporary created big files. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2012-12-05 09:44:07 UTC (rev 7828) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2012-12-05 11:59:08 UTC (rev 7829) @@ -428,26 +428,28 @@ oldPage.cleanUp(); } Page newPage = null; - if (windows_.contains(webWindow) || getBrowserVersion().hasFeature(GENERATED_150)) { - newPage = pageCreator_.createPage(webResponse, webWindow); + synchronized (windows_) { + if (windows_.contains(webWindow) || getBrowserVersion().hasFeature(GENERATED_150)) { + newPage = pageCreator_.createPage(webResponse, webWindow); - if (windows_.contains(webWindow)) { - fireWindowContentChanged(new WebWindowEvent(webWindow, WebWindowEvent.CHANGE, oldPage, newPage)); + if (windows_.contains(webWindow)) { + fireWindowContentChanged(new WebWindowEvent(webWindow, WebWindowEvent.CHANGE, oldPage, newPage)); - // The page being loaded may already have been replaced by another page via JavaScript code. - if (webWindow.getEnclosedPage() == newPage) { - newPage.initialize(); - // hack: onload should be fired the same way for all type of pages - // here is a hack to handle non HTML pages - if (webWindow instanceof FrameWindow && !(newPage instanceof HtmlPage)) { - final FrameWindow fw = (FrameWindow) webWindow; - final BaseFrameElement frame = fw.getFrameElement(); - if (frame.hasEventHandlers("onload")) { - if (LOG.isDebugEnabled()) { - LOG.debug("Executing onload handler for " + frame); + // The page being loaded may already have been replaced by another page via JavaScript code. + if (webWindow.getEnclosedPage() == newPage) { + newPage.initialize(); + // hack: onload should be fired the same way for all type of pages + // here is a hack to handle non HTML pages + if (webWindow instanceof FrameWindow && !(newPage instanceof HtmlPage)) { + final FrameWindow fw = (FrameWindow) webWindow; + final BaseFrameElement frame = fw.getFrameElement(); + if (frame.hasEventHandlers("onload")) { + if (LOG.isDebugEnabled()) { + LOG.debug("Executing onload handler for " + frame); + } + final Event event = new Event(frame, Event.TYPE_LOAD); + ((Node) frame.getScriptObject()).executeEvent(event); } - final Event event = new Event(frame, Event.TYPE_LOAD); - ((Node) frame.getScriptObject()).executeEvent(event); } } } @@ -1154,9 +1156,11 @@ public WebWindow getWebWindowByName(final String name) throws WebWindowNotFoundException { WebAssert.notNull("name", name); - for (final WebWindow webWindow : windows_) { - if (webWindow.getName().equals(name)) { - return webWindow; + synchronized (windows_) { + for (final WebWindow webWindow : windows_) { + if (webWindow.getName().equals(name)) { + return webWindow; + } } } @@ -1207,7 +1211,9 @@ */ public void registerWebWindow(final WebWindow webWindow) { WebAssert.notNull("webWindow", webWindow); - windows_.add(webWindow); + synchronized (windows_) { + windows_.add(webWindow); + } } /** @@ -1219,7 +1225,9 @@ */ public void deregisterWebWindow(final WebWindow webWindow) { WebAssert.notNull("webWindow", webWindow); - windows_.remove(webWindow); + synchronized (windows_) { + windows_.remove(webWindow); + } fireWindowClosed(new WebWindowEvent(webWindow, WebWindowEvent.CLOSE, webWindow.getEnclosedPage(), null)); } @@ -1565,7 +1573,7 @@ * @see #getTopLevelWindows() */ public List<WebWindow> getWebWindows() { - return Collections.unmodifiableList(windows_); + return Collections.unmodifiableList(new ArrayList<WebWindow>(windows_)); } /** @@ -1995,18 +2003,20 @@ 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; - try { - window = i.next(); + synchronized (windows_) { + for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { + final WebWindow window; + try { + window = i.next(); + } + catch (final ConcurrentModificationException e) { + i = windows_.iterator(); + count = 0; + continue; + } + final long newTimeout = endTime - System.currentTimeMillis(); + count += window.getJobManager().waitForJobs(newTimeout); } - catch (final ConcurrentModificationException e) { - i = windows_.iterator(); - count = 0; - continue; - } - final long newTimeout = endTime - System.currentTimeMillis(); - count += window.getJobManager().waitForJobs(newTimeout); } if (count != getAggregateJobCount()) { final long newTimeout = endTime - System.currentTimeMillis(); @@ -2042,18 +2052,20 @@ 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; - try { - window = i.next(); + synchronized (windows_) { + for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { + final WebWindow window; + try { + window = i.next(); + } + catch (final ConcurrentModificationException e) { + i = windows_.iterator(); + count = 0; + continue; + } + final long newDelay = endTime - System.currentTimeMillis(); + count += window.getJobManager().waitForJobsStartingBefore(newDelay); } - catch (final ConcurrentModificationException e) { - i = windows_.iterator(); - count = 0; - continue; - } - final long newDelay = endTime - System.currentTimeMillis(); - count += window.getJobManager().waitForJobsStartingBefore(newDelay); } if (count != getAggregateJobCount()) { final long newDelay = endTime - System.currentTimeMillis(); @@ -2088,17 +2100,19 @@ */ private int getAggregateJobCount() { int count = 0; - for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { - final WebWindow window; - try { - window = i.next(); + synchronized (windows_) { + for (Iterator<WebWindow> i = windows_.iterator(); i.hasNext();) { + final WebWindow window; + try { + window = i.next(); + } + catch (final ConcurrentModificationException e) { + i = windows_.iterator(); + count = 0; + continue; + } + count += window.getJobManager().getJobCount(); } - catch (final ConcurrentModificationException e) { - i = windows_.iterator(); - count = 0; - continue; - } - count += window.getJobManager().getJobCount(); } return count; } |
From: <mgu...@us...> - 2012-12-05 13:26:14
|
Revision: 7831 http://sourceforge.net/p/htmlunit/code/7831 Author: mguillem Date: 2012-12-05 13:26:10 +0000 (Wed, 05 Dec 2012) Log Message: ----------- Add BrowserVersion.clone() Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/PluginConfiguration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-05 12:46:27 UTC (rev 7830) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-05 13:26:10 UTC (rev 7831) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="add" dev="mguillem"> + Add BrowserVersion.clone(). + </action> <action type="fix" dev="asashour"> Fix a potential ConcurrentModificationException, on calling WebClient.getWebWindows(). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-05 12:46:27 UTC (rev 7830) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-05 13:26:10 UTC (rev 7831) @@ -547,4 +547,32 @@ public String getNickname() { return nickname_; } + + /** + * Creates and return a copy of this object. Current instance and cloned + * object can be modified independently. + * @return a clone of this instance. + */ + @Override + protected BrowserVersion clone() { + final BrowserVersion clone = new BrowserVersion(getApplicationName(), getApplicationVersion(), + getUserAgent(), getBrowserVersionNumeric(), getNickname(), null); + + clone.setApplicationCodeName(getApplicationCodeName()); + clone.setApplicationMinorVersion(getApplicationMinorVersion()); + clone.setBrowserLanguage(getBrowserLanguage()); + clone.setCpuClass(getCpuClass()); + clone.setOnLine(isOnLine()); + clone.setPlatform(getPlatform()); + clone.setSystemLanguage(getSystemLanguage()); + clone.setUserLanguage(getUserLanguage()); + + for (final PluginConfiguration pluginConf : getPlugins()) { + clone.getPlugins().add(pluginConf.clone()); + } + + clone.features_.addAll(features_); + + return clone; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/PluginConfiguration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/PluginConfiguration.java 2012-12-05 12:46:27 UTC (rev 7830) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/PluginConfiguration.java 2012-12-05 13:26:10 UTC (rev 7831) @@ -99,6 +99,19 @@ } /** + * Creates and return a copy of this object. Current instance and cloned + * object can be modified independently. + * @return a clone of this instance. + */ + @Override + public PluginConfiguration clone() { + final PluginConfiguration clone = new PluginConfiguration(getName(), getDescription(), getFilename()); + clone.getMimeTypes().addAll(getMimeTypes()); + + return clone; + } + + /** * Holds information about a single mime type associated with a plugin. */ public static class MimeType implements Serializable { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java 2012-12-05 12:46:27 UTC (rev 7830) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java 2012-12-05 13:26:10 UTC (rev 7831) @@ -21,6 +21,7 @@ * * @version $Revision$ * @author Ahmed Ashour + * @author Marc Guillemot */ public class BrowserVersionTest extends SimpleWebTestCase { @@ -37,4 +38,18 @@ assertEquals(16.0f, BrowserVersion.CHROME_16.getBrowserVersionNumeric()); } + /** + * Test of {@link BrowserVersion#clone()}. + */ + @Test + public void testClone() { + final BrowserVersion ff = BrowserVersion.FIREFOX_3_6; + final BrowserVersion clone = ff.clone(); + + assertFalse(ff == clone); + assertEquals(ff, clone); + + clone.getPlugins().clear(); + assertFalse(ff.equals(clone)); + } } |
From: <asa...@us...> - 2012-12-07 03:57:15
|
Revision: 7833 http://sourceforge.net/p/htmlunit/code/7833 Author: asashour Date: 2012-12-07 03:57:12 +0000 (Fri, 07 Dec 2012) Log Message: ----------- JavaScript: fix Date.toLocaleDateString(). Issue 1467 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-06 07:07:21 UTC (rev 7832) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-07 03:57:12 UTC (rev 7833) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1467"> + JavaScript: fix Date.toLocaleDateString(). + </action> <action type="add" dev="mguillem"> Add BrowserVersion.clone(). </action> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-06 07:07:21 UTC (rev 7832) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-07 03:57:12 UTC (rev 7833) @@ -27,6 +27,7 @@ * * @version $Revision$ * @author Marc Guillemot + * @author Ahmed Ashour */ @RunWith(BrowserRunner.class) public class NativeDateTest extends WebDriverTestCase { @@ -127,4 +128,23 @@ return html; } + + /** + * Test for bug <a href="https://sourceforge.net/p/htmlunit/bugs/1467/">1467</a>. + * @throws Exception if the test fails + */ + @Test + @Alerts("Saturday, January 01, 2000") + public void toLocaleDateString() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " alert(new Date(2000, 0, 1).toLocaleDateString());\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + } |
From: <asa...@us...> - 2012-12-08 09:44:44
|
Revision: 7837 http://sourceforge.net/p/htmlunit/code/7837 Author: asashour Date: 2012-12-08 09:44:40 +0000 (Sat, 08 Dec 2012) Log Message: ----------- - BrowserVersion: deprecate INTERNET_EXPLORER_6 and INTERNET_EXPLORER_7 - Remove IE6/7 from default test run Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-08 09:39:29 UTC (rev 7836) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-08 09:44:40 UTC (rev 7837) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="update" dev="asashour"> + BrowserVersion: deprecate INTERNET_EXPLORER_6 and INTERNET_EXPLORER_7. + </action> <action type="fix" dev="asashour" issue="1467"> JavaScript: fix Date.toLocaleDateString(). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 09:39:29 UTC (rev 7836) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 09:44:40 UTC (rev 7837) @@ -122,12 +122,20 @@ "Mozilla/5.0 (Windows NT 6.1; rv:10.0.11) Gecko/20100101 Firefox/10.0.11", (float) 10.0, "FF10", null); - /** Internet Explorer 6. */ + /** + * Internet Explorer 6. + * @deprecated as of 2.12 + */ + @Deprecated public static final BrowserVersion INTERNET_EXPLORER_6 = new BrowserVersion( INTERNET_EXPLORER, "4.0 (compatible; MSIE 6.0b; Windows 98)", "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)", 6, "IE6", null); - /** Internet Explorer 7. */ + /** + * Internet Explorer 7. + * @deprecated as of 2.12 + */ + @Deprecated public static final BrowserVersion INTERNET_EXPLORER_7 = new BrowserVersion( INTERNET_EXPLORER, "4.0 (compatible; MSIE 7.0; Windows NT 5.1)", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)", 7, "IE7", null); @@ -146,7 +154,7 @@ 16, "Chrome16", null); /** The default browser version. */ - private static BrowserVersion DefaultBrowserVersion_ = INTERNET_EXPLORER_7; + private static BrowserVersion DefaultBrowserVersion_ = INTERNET_EXPLORER_8; /** Register plugins for the browser versions. */ static { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-08 09:39:29 UTC (rev 7836) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-08 09:44:40 UTC (rev 7837) @@ -73,10 +73,10 @@ if (/* browsers.contains("hu") ||*/ browsers.contains("hu-ff10")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.FIREFOX_10, false)); } - if (browsers.contains("hu") || browsers.contains("hu-ie6")) { + if (/*browsers.contains("hu") ||*/ browsers.contains("hu-ie6")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_6, false)); } - if (browsers.contains("hu") || browsers.contains("hu-ie7")) { + if (/*browsers.contains("hu") ||*/ browsers.contains("hu-ie7")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_7, false)); } if (browsers.contains("hu") || browsers.contains("hu-ie8")) { |
From: <asa...@us...> - 2012-12-08 09:48:12
|
Revision: 7838 http://sourceforge.net/p/htmlunit/code/7838 Author: asashour Date: 2012-12-08 09:48:10 +0000 (Sat, 08 Dec 2012) Log Message: ----------- IE8 is the default one now Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-08 09:44:40 UTC (rev 7837) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-08 09:48:10 UTC (rev 7838) @@ -9,7 +9,8 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="update" dev="asashour"> - BrowserVersion: deprecate INTERNET_EXPLORER_6 and INTERNET_EXPLORER_7. + BrowserVersion: deprecate INTERNET_EXPLORER_6 and INTERNET_EXPLORER_7, + and make INTERNET_EXPLORER_8 the default one. </action> <action type="fix" dev="asashour" issue="1467"> JavaScript: fix Date.toLocaleDateString(). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 09:44:40 UTC (rev 7837) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 09:48:10 UTC (rev 7838) @@ -272,7 +272,7 @@ /** * Returns the default browser version that is used whenever a specific version isn't specified. - * Defaults to {@link #INTERNET_EXPLORER_7}. + * Defaults to {@link #INTERNET_EXPLORER_8}. * @return the default browser version */ public static BrowserVersion getDefault() { |
From: <asa...@us...> - 2012-12-08 12:32:01
|
Revision: 7840 http://sourceforge.net/p/htmlunit/code/7840 Author: asashour Date: 2012-12-08 12:31:58 +0000 (Sat, 08 Dec 2012) Log Message: ----------- Date.toLocaleDateString() is not enumerable, thanks to Dojo Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-12-08 09:59:10 UTC (rev 7839) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-12-08 12:31:58 UTC (rev 7840) @@ -323,7 +323,7 @@ final ScriptableObject datePrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Date"); datePrototype.defineFunctionProperties(new String[] {"toLocaleDateString"}, - DateCustom.class, ScriptableObject.EMPTY); + DateCustom.class, ScriptableObject.DONTENUM); window.setPrototypes(prototypes); window.initialize(webWindow); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-08 09:59:10 UTC (rev 7839) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-08 12:31:58 UTC (rev 7840) @@ -147,4 +147,22 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if the test fails + */ + @Test + public void toLocaleDateString_enumerable() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " var date = new Date(2000, 0, 1);\n" + + " for (var x in date) {\n" + + " alert(x);\n" + + " }\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <asa...@us...> - 2012-12-08 14:05:57
|
Revision: 7841 http://sourceforge.net/p/htmlunit/code/7841 Author: asashour Date: 2012-12-08 14:05:52 +0000 (Sat, 08 Dec 2012) Log Message: ----------- BrowserVersion: add IE9/FF17, deprecate FF10 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionClassRunner.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-08 14:05:52 UTC (rev 7841) @@ -9,8 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="update" dev="asashour"> - BrowserVersion: deprecate INTERNET_EXPLORER_6 and INTERNET_EXPLORER_7, - and make INTERNET_EXPLORER_8 the default one. + BrowserVersion: deprecate INTERNET_EXPLORER_6, INTERNET_EXPLORER_7, FIREFOX_10, + and make INTERNET_EXPLORER_8 the default one. Add INTERNET_EXPLORER_9 and + FIREFOX_17. </action> <action type="fix" dev="asashour" issue="1467"> JavaScript: fix Date.toLocaleDateString(). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -116,12 +116,22 @@ "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28", (float) 3.6, "FF3.6", null); - /** Firefox Warning: experimental!!! */ + /** + * Firefox 10. Warning: experimental!!!. + * @deprecated as of 2.12 + */ + @Deprecated public static final BrowserVersion FIREFOX_10 = new BrowserVersion( NETSCAPE, "5.0 (Windows)", "Mozilla/5.0 (Windows NT 6.1; rv:10.0.11) Gecko/20100101 Firefox/10.0.11", (float) 10.0, "FF10", null); + /** Firefox 17 ESR. Work In Progress!!! */ + public static final BrowserVersion FIREFOX_17 = new BrowserVersion( + NETSCAPE, "5.0 (Windows)", + "Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0", + (float) 17.0, "FF17", null); + /** * Internet Explorer 6. * @deprecated as of 2.12 @@ -145,6 +155,11 @@ INTERNET_EXPLORER, "4.0 (compatible; MSIE 8.0; Windows NT 6.0)", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)", 8, "IE8", null); + /** Internet Explorer 9. Work In Progress!!! */ + public static final BrowserVersion INTERNET_EXPLORER_9 = new BrowserVersion( + INTERNET_EXPLORER, "5.0 (compatible; MSIE 9.0; Windows NT 6.1)", + "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)", 9, "IE9", null); + /** Chrome 16. Warning: highly experimental!!! */ public static final BrowserVersion CHROME_16 = new BrowserVersion( "Netscape", "5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7" @@ -161,9 +176,11 @@ INTERNET_EXPLORER_6.initDefaultFeatures(); INTERNET_EXPLORER_7.initDefaultFeatures(); INTERNET_EXPLORER_8.initDefaultFeatures(); + INTERNET_EXPLORER_9.initDefaultFeatures(); FIREFOX_3_6.initDefaultFeatures(); FIREFOX_10.initDefaultFeatures(); + FIREFOX_17.initDefaultFeatures(); final PluginConfiguration flash = new PluginConfiguration("Shockwave Flash", "Shockwave Flash 9.0 r31", "libflashplayer.so"); @@ -171,6 +188,7 @@ "Shockwave Flash", "swf")); FIREFOX_3_6.getPlugins().add(flash); FIREFOX_10.getPlugins().add(flash); + FIREFOX_17.getPlugins().add(flash); CHROME_16.initDefaultFeatures(); CHROME_16.setApplicationCodeName("Mozilla"); @@ -309,7 +327,7 @@ /** * Returns <tt>true</tt> if this <tt>BrowserVersion</tt> instance represents some - * version of Firefox like {@link #FIREFOX_3_6} or {@link #FIREFOX_10}. + * version of Firefox like {@link #FIREFOX_3_6} or {@link #FIREFOX_17}. * @return whether or not this version is a version of a Firefox browser */ public final boolean isFirefox() { 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 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/geo/Geolocation.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -150,7 +150,7 @@ LOG.info("Invoking URL: " + url); } - final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10); + final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_17); try { final Page page = webClient.getPage(url); final String content = page.getWebResponse().getContentAsString(); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -73,6 +73,9 @@ if (/* browsers.contains("hu") ||*/ browsers.contains("hu-ff10")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.FIREFOX_10, false)); } + if (/* browsers.contains("hu") ||*/ browsers.contains("hu-ff17")) { + runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.FIREFOX_17, false)); + } if (/*browsers.contains("hu") ||*/ browsers.contains("hu-ie6")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_6, false)); } @@ -82,6 +85,9 @@ if (browsers.contains("hu") || browsers.contains("hu-ie8")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_8, false)); } + if (/*browsers.contains("hu") ||*/ browsers.contains("hu-ie9")) { + runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_9, false)); + } // in a first time, chrome can be specified but is not integrated in the default run if (/*browsers.contains("hu") || */browsers.contains("hu-chrome16")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.CHROME_16, false)); @@ -168,6 +174,9 @@ /** Internet Explorer 8. */ IE8, + /** Internet Explorer 9. */ + IE9, + /** All versions of Firefox. */ FF, @@ -177,6 +186,9 @@ /** Firefox 10. */ FF10, + /** Firefox 17. */ + FF17, + /** * Not Browser-specific, it will run only once. Don't use this with other Browsers. * And don't call directly or indirectly {@link WebTestCase#getBrowserVersion()} @@ -223,6 +235,9 @@ /** Alerts for Internet Explorer 8. If not defined, {@link #IE()} is used. */ String[] IE8() default {EMPTY_DEFAULT }; + /** Alerts for Internet Explorer 9. If not defined, {@link #IE()} is used. */ + String[] IE9() default {EMPTY_DEFAULT }; + /** Alerts for any Firefox, it can be overridden by specific FF version. */ String[] FF() default {EMPTY_DEFAULT }; @@ -232,6 +247,9 @@ /** Alerts for Firefox 10. If not defined, {@link #FF()} is used. */ String[] FF10() default {EMPTY_DEFAULT }; + /** Alerts for Firefox 17. If not defined, {@link #FF()} is used. */ + String[] FF17() default {EMPTY_DEFAULT }; + /** Alerts for any Chrome If not defined, it can be overridden by a specific chrome version. */ String[] CHROME() default{EMPTY_DEFAULT }; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionClassRunner.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionClassRunner.java 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionClassRunner.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -78,12 +78,18 @@ else if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER_8) { expectedAlerts = firstDefined(alerts.IE8(), alerts.IE(), alerts.DEFAULT()); } + else if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER_9) { + expectedAlerts = firstDefined(alerts.IE9(), alerts.IE(), alerts.DEFAULT()); + } else if (browserVersion_ == BrowserVersion.FIREFOX_3_6) { expectedAlerts = firstDefined(alerts.FF3_6(), alerts.FF(), alerts.DEFAULT()); } else if (browserVersion_ == BrowserVersion.FIREFOX_10) { expectedAlerts = firstDefined(alerts.FF10(), alerts.FF(), alerts.DEFAULT()); } + else if (browserVersion_ == BrowserVersion.FIREFOX_17) { + expectedAlerts = firstDefined(alerts.FF17(), alerts.FF(), alerts.DEFAULT()); + } else if (browserVersion_ == BrowserVersion.CHROME_16) { expectedAlerts = firstDefined(alerts.CHROME16(), alerts.CHROME(), alerts.DEFAULT()); } @@ -240,6 +246,12 @@ } break; + case IE9: + if (browserVersion_ == BrowserVersion.INTERNET_EXPLORER_9) { + return true; + } + break; + case FF: if (browserVersion_.isFirefox()) { return true; @@ -258,6 +270,12 @@ } break; + case FF17: + if (browserVersion_ == BrowserVersion.FIREFOX_17) { + return true; + } + break; + case CHROME: if (browserVersion_.isChrome()) { return true; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -32,9 +32,11 @@ public void getBrowserVersionNumeric() { assertEquals(3.6f, BrowserVersion.FIREFOX_3_6.getBrowserVersionNumeric()); assertEquals(10.0f, BrowserVersion.FIREFOX_10.getBrowserVersionNumeric()); + assertEquals(17.0f, BrowserVersion.FIREFOX_17.getBrowserVersionNumeric()); assertEquals(6.0f, BrowserVersion.INTERNET_EXPLORER_6.getBrowserVersionNumeric()); assertEquals(7.0f, BrowserVersion.INTERNET_EXPLORER_7.getBrowserVersionNumeric()); assertEquals(8.0f, BrowserVersion.INTERNET_EXPLORER_8.getBrowserVersionNumeric()); + assertEquals(9.0f, BrowserVersion.INTERNET_EXPLORER_9.getBrowserVersionNumeric()); assertEquals(16.0f, BrowserVersion.CHROME_16.getBrowserVersionNumeric()); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java 2012-12-08 12:31:58 UTC (rev 7840) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java 2012-12-08 14:05:52 UTC (rev 7841) @@ -81,7 +81,7 @@ * The file should contain four properties: "browsers", "ff3.bin", "ff3.6.bin", and "chrome15.bin". * <ul> * <li>browsers: is a comma separated list contains any combination of "hu" (for HtmlUnit with all browser versions), - * "hu-ie6", "hu-ie7", "hu-ie8", "hu-ff3", "hu-ff3.6", + * "hu-ie6", "hu-ie7", "hu-ie8", "hu-ff3", "hu-ff3.6", "hu-ff17", * "ff3", "ff3.6", "ie6", "ie7", "ie8", "chrome16", which will be used to driver real browsers, * note that you can't define more than one IE as there is no standard way * to have multiple IEs on the same machine</li> @@ -106,6 +106,7 @@ private static List<String> BROWSERS_PROPERTIES_; private static String FF3_6_BIN_; private static String FF10_BIN_; + private static String FF17_BIN_; private static String CHROME16_BIN_; /** The driver cache. */ @@ -143,6 +144,7 @@ .replaceAll(" ", "").toLowerCase().split(",")); FF3_6_BIN_ = properties.getProperty("ff3.6.bin"); FF10_BIN_ = properties.getProperty("ff10.bin"); + FF17_BIN_ = properties.getProperty("ff17.bin"); CHROME16_BIN_ = properties.getProperty("chrome16.bin"); } } @@ -246,6 +248,9 @@ else if (getBrowserVersion() == BrowserVersion.FIREFOX_10) { ffBinary = FF10_BIN_; } + else if (getBrowserVersion() == BrowserVersion.FIREFOX_17) { + ffBinary = FF17_BIN_; + } if (ffBinary != null) { return new FirefoxDriver(new FirefoxBinary(new File(ffBinary)), new FirefoxProfile()); } |
From: <asa...@us...> - 2012-12-09 07:25:39
|
Revision: 7843 http://sourceforge.net/p/htmlunit/code/7843 Author: asashour Date: 2012-12-09 07:25:36 +0000 (Sun, 09 Dec 2012) Log Message: ----------- BrowserVersion: deprecated CHROME_16, and add CHROME Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionClassRunner.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserVersionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/WebDriverTestCase.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeFilterTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-08 16:51:50 UTC (rev 7842) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-09 07:25:36 UTC (rev 7843) @@ -9,9 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="update" dev="asashour"> - BrowserVersion: deprecate INTERNET_EXPLORER_6, INTERNET_EXPLORER_7, FIREFOX_10, - and make INTERNET_EXPLORER_8 the default one. Add INTERNET_EXPLORER_9 and - FIREFOX_17. + BrowserVersion: deprecate INTERNET_EXPLORER_6, INTERNET_EXPLORER_7, FIREFOX_10, CHROME_16, + and make INTERNET_EXPLORER_8 the default one. Add INTERNET_EXPLORER_9, + FIREFOX_17 and CHROME. </action> <action type="fix" dev="asashour" issue="1467"> JavaScript: fix Date.toLocaleDateString(). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-08 16:51:50 UTC (rev 7842) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2012-12-09 07:25:36 UTC (rev 7843) @@ -160,7 +160,11 @@ INTERNET_EXPLORER, "5.0 (compatible; MSIE 9.0; Windows NT 6.1)", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1)", 9, "IE9", null); - /** Chrome 16. Warning: highly experimental!!! */ + /** + * Chrome 16. + * @deprecated as of 2.12 + */ + @Deprecated public static final BrowserVersion CHROME_16 = new BrowserVersion( "Netscape", "5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7" + " (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7", @@ -168,6 +172,14 @@ + " (KHTML, like Gecko) Chrome/16.0.912.63 Safari/535.7", 16, "Chrome16", null); + /** Latest Chrome. Work In Progress!!! */ + public static final BrowserVersion CHROME = new BrowserVersion( + "Netscape", "5.0 (Windows NT 6.1) AppleWebKit/537.11" + + " (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11", + "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.11" + + " (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11", + 23, "Chrome", null); + /** The default browser version. */ private static BrowserVersion DefaultBrowserVersion_ = INTERNET_EXPLORER_8; @@ -195,6 +207,11 @@ CHROME_16.setPlatform("MacIntel"); CHROME_16.setCpuClass(null); CHROME_16.setBrowserLanguage("undefined"); + CHROME.initDefaultFeatures(); + CHROME.setApplicationCodeName("Mozilla"); + CHROME.setPlatform("MacIntel"); + CHROME.setCpuClass(null); + CHROME.setBrowserLanguage("undefined"); // there are other issues with Chrome; a different productSub, etc. } |
From: <asa...@us...> - 2012-12-09 08:07:14
|
Revision: 7844 http://sourceforge.net/p/htmlunit/code/7844 Author: asashour Date: 2012-12-09 08:07:09 +0000 (Sun, 09 Dec 2012) Log Message: ----------- - JavaScript: fix Date.toLocaleTimeString 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/JavaScriptEngine.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DateCustom.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-09 08:07:09 UTC (rev 7844) @@ -14,7 +14,7 @@ FIREFOX_17 and CHROME. </action> <action type="fix" dev="asashour" issue="1467"> - JavaScript: fix Date.toLocaleDateString(). + JavaScript: fix Date.toLocaleDateString() and .toLocaleTimeString(). </action> <action type="add" dev="mguillem"> Add BrowserVersion.clone(). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-12-09 08:07:09 UTC (rev 7844) @@ -760,6 +760,10 @@ @BrowserFeature(@WebBrowser(FF)) JS_CONSTRUCTOR, + /** Is Date.toLocaleTimeString() in 24-hour format. */ + @BrowserFeature(@WebBrowser(CHROME)) + JS_DATE_LOCATE_TIME_24, + /** */ @BrowserFeature(@WebBrowser(IE)) JS_DEFERRED, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java 2012-12-09 08:07:09 UTC (rev 7844) @@ -322,7 +322,7 @@ } final ScriptableObject datePrototype = (ScriptableObject) ScriptableObject.getClassPrototype(window, "Date"); - datePrototype.defineFunctionProperties(new String[] {"toLocaleDateString"}, + datePrototype.defineFunctionProperties(new String[] {"toLocaleDateString", "toLocaleTimeString"}, DateCustom.class, ScriptableObject.DONTENUM); window.setPrototypes(prototypes); window.initialize(webWindow); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DateCustom.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DateCustom.java 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DateCustom.java 2012-12-09 08:07:09 UTC (rev 7844) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DATE_LOCATE_TIME_24; + import java.lang.reflect.Field; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -50,20 +52,38 @@ if (LOCAL_DATE_FORMAT_ == null) { LOCAL_DATE_FORMAT_ = new SimpleDateFormat("EEEE, MMMM dd, yyyy", Locale.US); } - initDateField(thisObj); - try { - final double value = (Double) DATE_FIELD_.get(thisObj); - return LOCAL_DATE_FORMAT_.format(new Date((long) value)); + return LOCAL_DATE_FORMAT_.format(new Date(getDateValue(thisObj))); + } + + /** + * Converts a date to a string, returning the "time" portion using the current locale's conventions. + * @param context the JavaScript context + * @param thisObj the scriptable + * @param args the arguments passed into the method + * @param function the function + * @return converted string + */ + public static String toLocaleTimeString( + final Context context, final Scriptable thisObj, final Object[] args, final Function function) { + final String formatString; + if (((Window) thisObj.getParentScope()).getWebWindow().getWebClient().getBrowserVersion() + .hasFeature(JS_DATE_LOCATE_TIME_24)) { + formatString = "HH:mm:ss"; } - catch (final Exception e) { - throw Context.throwAsScriptRuntimeEx(e); + else { + formatString = "hh:mm:ss a"; } + final DateFormat format = new SimpleDateFormat(formatString, Locale.US); + return format.format(new Date(getDateValue(thisObj))); } - private static void initDateField(final Scriptable thisObj) { + private static long getDateValue(final Scriptable thisObj) { try { - DATE_FIELD_ = thisObj.getClass().getDeclaredField("date"); - DATE_FIELD_.setAccessible(true); + if (DATE_FIELD_ == null) { + DATE_FIELD_ = thisObj.getClass().getDeclaredField("date"); + DATE_FIELD_.setAccessible(true); + } + return ((Double) DATE_FIELD_.get(thisObj)).longValue(); } catch (final Exception e) { throw Context.throwAsScriptRuntimeEx(e); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/BrowserRunner.java 2012-12-09 08:07:09 UTC (rev 7844) @@ -88,7 +88,6 @@ if (/*browsers.contains("hu") ||*/ browsers.contains("hu-ie9")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_9, false)); } - // in a first time, chrome can be specified but is not integrated in the default run if (/*browsers.contains("hu") || */browsers.contains("hu-chrome")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.CHROME, false)); } @@ -100,6 +99,9 @@ if (browsers.contains("ff10")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.FIREFOX_10, true)); } + if (browsers.contains("ff17")) { + runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.FIREFOX_17, true)); + } if (browsers.contains("ie6")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_6, true)); } @@ -109,9 +111,12 @@ if (browsers.contains("ie8")) { runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_8, true)); } - if (browsers.contains("chrome16")) { - runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.CHROME_16, true)); + if (browsers.contains("ie9")) { + runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.INTERNET_EXPLORER_9, true)); } + if (browsers.contains("chrome")) { + runners_.add(new BrowserVersionClassRunner(klass, BrowserVersion.CHROME, true)); + } } } if (BrowserNoneClassRunner.containsTestMethods(klass)) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-09 07:25:36 UTC (rev 7843) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeDateTest.java 2012-12-09 08:07:09 UTC (rev 7844) @@ -151,7 +151,7 @@ * @throws Exception if the test fails */ @Test - public void toLocaleDateString_enumerable() throws Exception { + public void enumerable() throws Exception { final String html = "<html><head><title>foo</title><script>\n" + "function test() {\n" @@ -165,4 +165,22 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "12:00:00 AM", CHROME = "00:00:00") + public void toLocaleTimeString() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " alert(new Date(2000, 0, 1).toLocaleTimeString());\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + } |
From: <asa...@us...> - 2012-12-11 09:57:55
|
Revision: 7852 http://sourceforge.net/p/htmlunit/code/7852 Author: asashour Date: 2012-12-11 09:44:23 +0000 (Tue, 11 Dec 2012) Log Message: ----------- HtmlElement: deprecate getElementById() and hasHtmlElementWithId(). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DisabledElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNodeTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomTextTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndexTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-11 09:44:23 UTC (rev 7852) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="update" dev="asashour"> + HtmlElement: deprecate getElementById() and hasHtmlElementWithId(). + </action> + <action type="update" dev="asashour"> BrowserVersion: deprecate INTERNET_EXPLORER_6, INTERNET_EXPLORER_7, FIREFOX_10, CHROME_16, and make INTERNET_EXPLORER_8 the default one. Add INTERNET_EXPLORER_9, FIREFOX_17 and CHROME. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -649,7 +649,9 @@ * @param <E> the sub-element type * @return the element in this element's page with the specified ID * @exception ElementNotFoundException if no element has the specified ID + * @deprecated as of 2.12, please use {@link HtmlPage#getHtmlElementById(String)} */ + @Deprecated @SuppressWarnings("unchecked") public <E extends HtmlElement> E getElementById(final String id) throws ElementNotFoundException { return (E) ((HtmlPage) getPage()).getHtmlElementById(id); @@ -672,7 +674,9 @@ * * @param id the id to search for * @return <tt>true</tt> if there is an element in this element's page with the specified ID + * @deprecated as of 2.12, please use {@link HtmlPage#getElementById(String)} */ + @Deprecated public boolean hasHtmlElementWithId(final String id) { try { getElementById(id); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlLabel.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -128,7 +128,7 @@ final String elementId = getForAttribute(); if (!ATTRIBUTE_NOT_DEFINED.equals(elementId)) { try { - return getElementById(elementId); + return ((HtmlPage) getPage()).getHtmlElementById(elementId); } catch (final ElementNotFoundException e) { return null; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DisabledElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DisabledElementTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DisabledElementTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -125,7 +125,7 @@ final HtmlPage page = loadPage(BrowserVersion.FIREFOX_3_6, htmlContent, collectedAlerts); final HtmlForm form = page.getHtmlElementById("form1"); - final DisabledElement element = (DisabledElement) form.getElementById("element1"); + final DisabledElement element = (DisabledElement) page.getHtmlElementById("element1"); assertEquals(expectedIsDisabled, element.isDisabled()); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNodeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNodeTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomNodeTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -52,7 +52,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); Assert.assertTrue("Element should have attribute", node.hasAttributes()); } @@ -65,7 +65,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode parent = node.getParentNode(); Assert.assertFalse("Element should not have attribute", parent.hasAttributes()); } @@ -79,7 +79,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode child = node.getFirstChild(); Assert.assertFalse("Text should not have attribute", child.hasAttributes()); } @@ -93,7 +93,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode child = node.getFirstChild(); Assert.assertEquals("Text should not have a prefix", null, child.getPrefix()); } @@ -107,7 +107,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode child = node.getFirstChild(); Assert.assertEquals("Text should not have a prefix", null, child.getNamespaceURI()); } @@ -121,7 +121,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode child = node.getFirstChild(); Assert.assertEquals("Text should not have a prefix", null, child.getLocalName()); } @@ -135,7 +135,7 @@ final String content = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode child = node.getFirstChild(); child.setPrefix("bar"); // This does nothing. Assert.assertEquals("Text should not have a prefix", null, child.getPrefix()); @@ -154,7 +154,7 @@ + "</table></p></body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); node.removeAllChildren(); Assert.assertEquals("Did not remove all nodes", null, node.getFirstChild()); } @@ -169,7 +169,7 @@ + "<br><div id='tag'></div><br><div id='tag2'/></body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode previousSibling = node.getPreviousSibling(); final DomNode nextSibling = node.getNextSibling(); @@ -208,7 +208,7 @@ + "<br><div id='tag'/></body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute(null, "id", "id", null, "newElt"); @@ -247,7 +247,7 @@ + "<br><div><div id='tag'></div></div><br></body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode parent = node.getParentNode(); @@ -277,7 +277,7 @@ + "<br><div id='tag'></div><br></body></html>"; final HtmlPage page = loadPage(content); - final DomNode node = page.getDocumentElement().getElementById("tag"); + final DomNode node = page.getElementById("tag"); final DomNode previousSibling = node.getPreviousSibling(); final DomNode nextSibling = node.getNextSibling(); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomTextTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomTextTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/DomTextTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -183,7 +183,7 @@ + "<br><div id='tag'></div><br></body></html>"; final HtmlPage page = loadPage(html); - final DomNode divNode = page.getDocumentElement().getElementById("tag"); + final DomNode divNode = page.getElementById("tag"); final DomText node = new DomText(page, "test split"); divNode.insertBefore(node); @@ -217,7 +217,7 @@ + "<br><div id='tag'></div><br></body></html>"; final HtmlPage page = loadPage(content); - final DomNode divNode = page.getDocumentElement().getElementById("tag"); + final DomNode divNode = page.getElementById("tag"); final DomText firstNode = new DomText(page, "test split"); divNode.appendChild(firstNode); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlElementTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlElementTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -52,7 +52,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertTrue("Element should have attribute", node.hasAttribute("id")); } @@ -65,7 +65,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertFalse("Element should not have attribute", node.hasAttribute("foo")); } @@ -79,7 +79,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertTrue("Element should have attribute", node.hasAttributeNS("http://foobar", "foo")); } @@ -92,7 +92,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertFalse("Element should not have attribute", node.hasAttributeNS("http://foobar", "foo")); } @@ -105,7 +105,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertEquals("Element should have attribute", "tag", node.getAttribute("id")); } @@ -118,7 +118,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertEquals("Element should not have attribute", "", node.getAttribute("foo")); } @@ -132,7 +132,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertEquals("Element should have attribute", "bar", node.getAttributeNS("http://foobar", "foo")); } @@ -145,7 +145,7 @@ final String html = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); Assert.assertEquals("Element should not have attribute", "", node.getAttributeNS("http://foobar", "foo")); } @@ -159,7 +159,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("ns:foo".equals(attr.getName())) { Assert.assertEquals("Element should have a namespace URI", "http://foobar", attr.getNamespaceURI()); @@ -179,7 +179,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("id".equals(attr.getName())) { Assert.assertEquals("Element should not have a namespace URI", null, attr.getNamespaceURI()); @@ -199,7 +199,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("ns:foo".equals(attr.getName())) { Assert.assertEquals("Element should have a local name", "foo", attr.getLocalName()); @@ -219,7 +219,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("id".equals(attr.getName())) { // This is not standard, but to change it now would break backwards compatibility. @@ -240,7 +240,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("ns:foo".equals(attr.getName())) { Assert.assertEquals("Element should have a prefix", "ns", attr.getPrefix()); @@ -260,7 +260,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("id".equals(attr.getName())) { Assert.assertEquals("Element should not have a prefix", null, attr.getPrefix()); @@ -280,7 +280,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); for (final DomAttr attr : node.getAttributesMap().values()) { if ("ns:foo".equals(attr.getName())) { attr.setPrefix("other"); @@ -302,7 +302,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.setAttribute("id", "other"); Assert.assertEquals("Element should have attribute", "other", node.getAttribute("id")); } @@ -317,7 +317,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.setAttribute("foo", "other"); Assert.assertEquals("Element should have attribute", "other", node.getAttribute("foo")); } @@ -332,7 +332,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.setAttributeNS("http://foobar", "ns:foo", "other"); Assert.assertEquals("Element should have attribute", "other", node.getAttributeNS("http://foobar", "foo")); } @@ -347,7 +347,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.setAttributeNS("http://foobar", "ns:foo", "other"); Assert.assertEquals("Element should not have attribute", "other", node.getAttributeNS("http://foobar", "foo")); } @@ -362,7 +362,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.removeAttribute("id"); Assert.assertEquals("Element should not have removed attribute", "", node.getAttribute("id")); } @@ -377,7 +377,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.removeAttribute("foo"); Assert.assertEquals("Element should not have attribute", "", node.getAttribute("foo")); } @@ -392,7 +392,7 @@ = "<html><head></head><body xmlns:ns='http://foobar' id='tag' ns:foo='bar'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.removeAttributeNS("http://foobar", "foo"); Assert.assertEquals("Element should not have removed attribute", "", node.getAttributeNS("http://foobar", "foo")); @@ -408,7 +408,7 @@ = "<html><head></head><body id='tag'>text</body></html>"; final HtmlPage page = loadPage(html); - final HtmlElement node = page.getDocumentElement().getElementById("tag"); + final HtmlElement node = page.getHtmlElementById("tag"); node.removeAttributeNS("http://foobar", "foo"); Assert.assertEquals("Element should not have attribute", "", node.getAttributeNS("http://foobar", "foo")); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFileInputTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -120,7 +120,7 @@ final HtmlForm f = firstPage.getForms().get(0); final HtmlFileInput fileInput = f.getInputByName("image"); fileInput.setValueAttribute(fileURL); - f.getElementById("clickMe").click(); + firstPage.getHtmlElementById("clickMe").click(); final KeyDataPair pair = (KeyDataPair) webConnection.getLastParameters().get(0); assertNotNull(pair.getFile()); assertTrue(pair.getFile().length() != 0); @@ -299,8 +299,7 @@ client.setWebConnection(webConnection); final HtmlPage firstPage = client.getPage(URL_FIRST); - final HtmlForm f = firstPage.getForms().get(0); - f.getElementById("clickMe").click(); + firstPage.getHtmlElementById("clickMe").click(); final KeyDataPair pair = (KeyDataPair) webConnection.getLastParameters().get(0); assertEquals("image", pair.getName()); assertNull(pair.getFile()); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlFormTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -839,9 +839,9 @@ final HtmlForm form = page.getHtmlElementById("form1"); - Assert.assertEquals("First textarea with name 'ta1'", form.getElementById("ta1_1"), + Assert.assertEquals("First textarea with name 'ta1'", page.getElementById("ta1_1"), form.getTextAreaByName("ta1")); - Assert.assertEquals("First textarea with name 'ta2'", form.getElementById("ta2_1"), + Assert.assertEquals("First textarea with name 'ta2'", page.getElementById("ta2_1"), form.getTextAreaByName("ta2")); try { @@ -872,9 +872,9 @@ final HtmlForm form = page.getHtmlElementById("form1"); - Assert.assertEquals("First button with name 'b1'", form.getElementById("b1_1"), + Assert.assertEquals("First button with name 'b1'", page.getElementById("b1_1"), form.getButtonByName("b1")); - Assert.assertEquals("First button with name 'b2'", form.getElementById("b2_1"), + Assert.assertEquals("First button with name 'b2'", page.getElementById("b2_1"), form.getButtonByName("b2")); try { @@ -932,7 +932,7 @@ final MockWebConnection webConnection = getMockConnection(page); final HtmlPage secondPage = - (HtmlPage) page.getFormByName("form").getElementById("clickMe").click(); + (HtmlPage) page.getHtmlElementById("clickMe").click(); assertNotNull(secondPage); Assert.assertEquals("parameters", Collections.EMPTY_LIST, webConnection.getLastParameters()); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndexTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndexTest.java 2012-12-10 11:11:01 UTC (rev 7851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndexTest.java 2012-12-11 09:44:23 UTC (rev 7852) @@ -60,7 +60,7 @@ final HtmlIsIndex isInput = form.<HtmlIsIndex>getElementsByAttribute( "isindex", "prompt", "enterSomeText").get(0); isInput.setValue("Flintstone"); - final Page secondPage = form.getElementById("clickMe").click(); + final Page secondPage = page.getHtmlElementById("clickMe").click(); final List<NameValuePair> expectedParameters = new ArrayList<NameValuePair>(); expectedParameters.add(new NameValuePair("enterSomeText", "Flintstone")); |
From: <asa...@us...> - 2012-12-12 08:40:36
|
Revision: 7859 http://sourceforge.net/p/htmlunit/code/7859 Author: asashour Date: 2012-12-12 08:40:33 +0000 (Wed, 12 Dec 2012) Log Message: ----------- Fix when to remove the Array.prototype properties (IE). Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-12-12 07:38:10 UTC (rev 7858) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-12-12 08:40:33 UTC (rev 7859) @@ -20,6 +20,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLIFRAME_IGNORE_SELFCLOSING; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLPARSER_REMOVE_EMPTY_CONTENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.IGNORE_CONTENTS_OF_INNER_HEAD; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DEFINE_GETTER; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.PAGE_WAIT_LOAD_BEFORE_BODY; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.SVG; @@ -34,6 +35,9 @@ import java.util.Map; import java.util.Stack; +import net.sourceforge.htmlunit.corejs.javascript.Scriptable; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; + import org.apache.commons.lang3.StringUtils; import org.apache.xerces.parsers.AbstractSAXParser; import org.apache.xerces.util.DefaultErrorHandler; @@ -550,12 +554,33 @@ else if ("head".equals(tagLower)) { head_ = (HtmlElement) newElement; } - + else if ("html".equals(tagLower)) { + if (!page_.hasFeature(JS_DEFINE_GETTER) && page_.isQuirksMode()) { + removePrototypeProperties((Scriptable) page_.getEnclosingWindow().getScriptObject(), "Array", + "every", "filter", "forEach", "indexOf", "lastIndexOf", "map", "reduce", + "reduceRight", "some"); + } + } currentNode_ = newElement; stack_.push(currentNode_); } /** + * Removes prototype properties. + |
From: <asa...@us...> - 2012-12-12 10:13:48
|
Revision: 7860 http://sourceforge.net/p/htmlunit/code/7860 Author: asashour Date: 2012-12-12 10:13:44 +0000 (Wed, 12 Dec 2012) Log Message: ----------- JavaScript: fix the value of "(i in x)" for NodeList, HTMLCollection and CSSRuleList. Issue 1456 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NodeList.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleList.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeListTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleListTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/changes/changes.xml 2012-12-12 10:13:44 UTC (rev 7860) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="fix" dev="asashour" issue="1456 "> + JavaScript: fix the value of "(i in x)" for NodeList, HTMLCollection and CSSRuleList. + </action> <action type="update" dev="asashour"> HtmlElement: deprecate getElementById() and hasHtmlElementWithId(). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -579,7 +579,6 @@ } } - /** * Adds the new node to the right parent that is not necessary the currentNode in case * of malformed HTML code. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NodeList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NodeList.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/NodeList.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -416,6 +416,18 @@ * {@inheritDoc} */ @Override + public boolean has(final int index, final Scriptable start) { + final List<Object> elements = getElements(); + if (index >= 0 && index < elements.size()) { + return true; + } + return false; + } + + /** + * {@inheritDoc} + */ + @Override public boolean has(final String name, final Scriptable start) { // let's Rhino work normally if current instance is the prototype if (isPrototype()) { @@ -423,11 +435,7 @@ } try { - final int index = Integer.parseInt(name); - final List<Object> elements = getElements(); - if (index >= 0 && index < elements.size()) { - return true; - } + return has(Integer.parseInt(name), start); } catch (final NumberFormatException e) { // Ignore. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleList.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleList.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -109,6 +109,18 @@ } /** + * {@inheritDoc} + */ + @Override + public boolean has(final int index, final Scriptable start) { + final int length = getLength(); + if (index >= 0 && index < length) { + return true; + } + return false; + } + + /** * {@inheritDoc}. */ @Override @@ -117,11 +129,7 @@ return true; } try { - final int index = Integer.parseInt(name); - final int length = getLength(); - if (index >= 0 && index < length) { - return true; - } + return has(Integer.parseInt(name), start); } catch (final Exception e) { //ignore 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 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollection.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -15,7 +15,6 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_48; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_49; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_50; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_COMMENT_IS_ELEMENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCOLLECTION_IDENTICAL_IDS; @@ -347,43 +346,6 @@ } /** - * {@inheritDoc} - */ - @Override - public boolean has(final String name, final Scriptable start) { - // let's Rhino work normally if current instance is the prototype - if (isPrototype()) { - return super.has(name, start); - } - - try { - final int index = Integer.parseInt(name); - final List<Object> elements = getElements(); - if (index >= 0 && index < elements.size()) { - return true; - } - } - catch (final NumberFormatException e) { - // Ignore. - } - - if ("length".equals(name)) { - return true; - } - if (!getBrowserVersion().hasFeature(GENERATED_49)) { - final JavaScriptConfiguration jsConfig = getWindow().getWebWindow().getWebClient() - .getJavaScriptEngine().getJavaScriptConfiguration(); - for (final String functionName : jsConfig.getClassConfiguration(getClassName()).functionKeys()) { - if (name.equals(functionName)) { - return true; - } - } - return false; - } - return getWithPreemption(name) != NOT_FOUND; - } - - /** * {@inheritDoc}. */ @Override Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeListTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeListTest.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NodeListTest.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -49,4 +49,22 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception on test failure + */ + @Test + @Alerts("true") + public void has() throws Exception { + final String html = "<html><head><title>test</title>\n" + + "<script>\n" + + " function test(){\n" + + " alert(0 in document.body.parentNode.childNodes);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleListTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleListTest.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSRuleListTest.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -34,7 +34,7 @@ * @throws Exception on test failure */ @Test - @Alerts(FF = "[object CSSStyleRule]", + @Alerts(DEFAULT = "[object CSSStyleRule]", IE = "[object]") public void testRuleList() throws Exception { final String html = "<html><head><title>First</title>\n" @@ -82,4 +82,30 @@ + "</body></html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception on test failure + */ + @Test + @Alerts("true") + public void has() throws Exception { + final String html = "<html><head><title>First</title>\n" + + "<style>\n" + + " BODY { font-size: 1234px; }\n" + + "</style>\n" + + "<script>\n" + + " function test(){\n" + + " var rules;\n" + + " if (document.styleSheets[0].cssRules)\n" + + " rules = document.styleSheets[0].cssRules;\n" + + " else\n" + + " rules = document.styleSheets[0].rules;\n" + + " alert(0 in rules);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } + } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java 2012-12-12 08:40:33 UTC (rev 7859) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLCollectionTest.java 2012-12-12 10:13:44 UTC (rev 7860) @@ -318,4 +318,20 @@ loadPageWithAlerts2(html); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("true") + public void has() throws Exception { + final String html = "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " alert(0 in document.forms);\n" + + " }\n" + + "</script></head><body onload='test()'>\n" + + "<form name='myForm'></form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |