From: <rb...@us...> - 2014-03-08 09:47:42
|
Revision: 9160 http://sourceforge.net/p/htmlunit/code/9160 Author: rbri Date: 2014-03-08 09:47:36 +0000 (Sat, 08 Mar 2014) Log Message: ----------- type property now supported by ul and ol tag 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/HTMLListElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDirectoryElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/changes/changes.xml 2014-03-08 09:47:36 UTC (rev 9160) @@ -8,6 +8,9 @@ <body> <release version="2.15" date="???" description="Bugfixes"> + <action type="add" dev="rbri"> + JavaScript: type property now supported by ul and ol tag. + </action> <action type="fix" dev="rbri" issue="1581"> JavaScript: Fix handling of coordinate parameters when clicking on an image input. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -1373,6 +1373,10 @@ @BrowserFeature(@WebBrowser(value = IE, minVersion = 11)) JS_TREEWALKER_FILTER_FUNCTION_ONLY, + /** Setting the property align to arbitrary values is allowed. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) + JS_TYPE_ACCEPTS_ARBITRARY_VALUES, + /** Setting the property width/heigth to arbitrary values is allowed. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) JS_WIDTH_HEIGHT_ACCEPTS_ARBITRARY_VALUES, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLListElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLListElement.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLListElement.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLLIST_LIMIT_COMPACT_TO_BOOLEAN; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_TYPE_ACCEPTS_ARBITRARY_VALUES; import net.sourceforge.htmlunit.corejs.javascript.Context; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClasses; @@ -27,6 +28,7 @@ * @version $Revision$ * @author Daniel Gredler * @author Frank Danek + * @author Ronald Brill */ @JsxClasses( isJSObject = false @@ -67,4 +69,41 @@ return super.getAttribute(attributeName, flags); } + /** + * Returns the value of the "type" property. + * @return the value of the "type" property + */ + protected String getType() { + final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_TYPE_ACCEPTS_ARBITRARY_VALUES); + + final String type = getDomNodeOrDie().getAttribute("type"); + if (acceptArbitraryValues + || "1".equals(type) + || "a".equals(type) + || "A".equals(type) + || "i".equals(type) + || "I".equals(type)) { + return type; + } + return ""; + } + + /** + * Sets the value of the "type" property. + * @param type the value of the "type" property + */ + protected void setType(final String type) { + final boolean acceptArbitraryValues = getBrowserVersion().hasFeature(JS_TYPE_ACCEPTS_ARBITRARY_VALUES); + if (acceptArbitraryValues + || "1".equals(type) + || "a".equals(type) + || "A".equals(type) + || "i".equals(type) + || "I".equals(type)) { + getDomNodeOrDie().setAttribute("type", type); + return; + } + + throw Context.reportRuntimeError("Cannot set the type property to invalid value: '" + type + "'"); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElement.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElement.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -16,14 +16,36 @@ import com.gargoylesoftware.htmlunit.html.HtmlOrderedList; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; /** * The JavaScript object "HTMLOListElement". * * @version $Revision$ * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass(domClass = HtmlOrderedList.class) public class HTMLOListElement extends HTMLListElement { + /** + * Returns the value of the <tt>type</tt> attribute. + * + * @return the value of the <tt>type</tt> attribute + */ + @JsxGetter + public String getType() { + return super.getType(); + } + + /** + * Sets the value of the <tt>type</tt> attribute. + * + * @param type the value of the <tt>type</tt> attribute + */ + @JsxSetter + public void setType(final String type) { + super.setType(type); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElement.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElement.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -21,6 +21,8 @@ import com.gargoylesoftware.htmlunit.html.HtmlUnorderedList; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClasses; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; /** @@ -30,11 +32,27 @@ * @author Ahmed Ashour * @author Ronald Brill */ -@JsxClasses ({ - @JsxClass(domClass = HtmlDirectory.class, browsers = { @WebBrowser(value = IE, maxVersion = 9) }), - @JsxClass(domClass = HtmlUnorderedList.class), - @JsxClass(domClass = HtmlMenu.class, browsers = { @WebBrowser(value = IE, maxVersion = 9) }) -}) +@JsxClasses({ + @JsxClass(domClass = HtmlDirectory.class, browsers = { @WebBrowser(value = IE, maxVersion = 9) }), + @JsxClass(domClass = HtmlUnorderedList.class), + @JsxClass(domClass = HtmlMenu.class, browsers = { @WebBrowser(value = IE, maxVersion = 9) }) }) public class HTMLUListElement extends HTMLListElement { + /** + * Returns the value of the <tt>type</tt> attribute. + * @return the value of the <tt>type</tt> attribute + */ + @JsxGetter + public String getType() { + return super.getType(); + } + + /** + * Sets the value of the <tt>type</tt> attribute. + * @param type the value of the <tt>type</tt> attribute + */ + @JsxSetter + public void setType(final String type) { + super.setType(type); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDirectoryElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDirectoryElementTest.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDirectoryElementTest.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF; + import org.junit.Test; import org.junit.runner.RunWith; import org.openqa.selenium.By; @@ -118,7 +120,7 @@ "null", "", "blah", "A", "1", "a", "A", "i", "I", "u" }, IE8 = { "", "", "", "A", "", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }, IE11 = { "", "", "", "A", "null", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }) - @NotYetImplemented + @NotYetImplemented(FF) public void type() throws Exception { final String html = "<html>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElementTest.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLOListElementTest.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -23,7 +23,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; import com.gargoylesoftware.htmlunit.html.HtmlOrderedList; @@ -117,7 +116,6 @@ @Alerts(DEFAULT = { "", "", "blah", "A", "null", "", "blah", "A", "1", "a", "A", "i", "I", "u" }, IE8 = { "", "", "", "A", "", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }, IE11 = { "", "", "", "A", "null", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }) - @NotYetImplemented public void type() throws Exception { final String html = "<html>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java 2014-03-07 19:05:20 UTC (rev 9159) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLUListElementTest.java 2014-03-08 09:47:36 UTC (rev 9160) @@ -23,7 +23,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; import com.gargoylesoftware.htmlunit.html.HtmlUnorderedList; @@ -118,7 +117,6 @@ @Alerts(DEFAULT = { "", "", "blah", "A", "null", "", "blah", "A", "1", "a", "A", "i", "I", "u" }, IE8 = { "", "", "", "A", "", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }, IE11 = { "", "", "", "A", "null", "", "blah", "A", "1", "a", "A", "i", "I", "exception", "I" }) - @NotYetImplemented public void type() throws Exception { final String html = "<html>\n" |