From: <rb...@us...> - 2013-05-27 10:05:26
|
Revision: 8312 http://sourceforge.net/p/htmlunit/code/8312 Author: rbri Date: 2013-05-27 10:05:23 +0000 (Mon, 27 May 2013) Log Message: ----------- various hacks at the airport; feature naming, test fix, some NYI tests implemented Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -384,10 +384,6 @@ /** Was originally .isIE(). */ @BrowserFeature(@WebBrowser(IE)) - GENERATED_44, - - /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) GENERATED_45, /** Was originally .isIE(). */ @@ -752,6 +748,14 @@ @BrowserFeature(@WebBrowser(IE)) JS_BOUNDING_CLIENT_RECT_OFFSET_TWO, + /** Trying to change the type of a button element throws an exception (IE). */ + @BrowserFeature(@WebBrowser(IE)) + JS_BUTTON_SET_TYPE_THROWS_EXCEPTION, + + /** IE uses the content of a button tag as value instead of the attribute. */ + @BrowserFeature(@WebBrowser(IE)) + JS_BUTTON_USE_CONTENT_AS_VALUE, + /** Indicates that the browser emulates the char attribute. */ @BrowserFeature(@WebBrowser(IE)) JS_CHAR_EMULATED, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLButtonElement.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -14,7 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_44; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_BUTTON_SET_TYPE_THROWS_EXCEPTION; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_BUTTON_USE_CONTENT_AS_VALUE; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import java.io.IOException; @@ -36,6 +37,7 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> * @author Marc Guillemot * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass(domClasses = HtmlButton.class) public class HTMLButtonElement extends FormField { @@ -48,7 +50,7 @@ */ @JsxSetter public void setType(final String newType) { - if (getBrowserVersion().hasFeature(GENERATED_44)) { + if (getBrowserVersion().hasFeature(JS_BUTTON_SET_TYPE_THROWS_EXCEPTION)) { throw Context.reportRuntimeError("Object doesn't support this action"); } getDomNodeOrDie().setAttribute("type", newType); @@ -64,6 +66,30 @@ } /** + * {@inheritDoc} + */ + @Override + @JsxGetter + public String getValue() { + if (getBrowserVersion().hasFeature(JS_BUTTON_USE_CONTENT_AS_VALUE)) { + return getText(); + } + return super.getValue(); + } + + /** + * {@inheritDoc} + */ + @Override + @JsxSetter + public void setValue(final String newValue) { + if (getBrowserVersion().hasFeature(JS_BUTTON_USE_CONTENT_AS_VALUE)) { + setInnerText(newValue); + } + super.setValue(newValue); + } + + /** * {@inheritDoc} Overridden to modify browser configurations. */ @Override Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFontTest.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -34,7 +34,9 @@ * @throws Exception if the test fails */ @Test - @Alerts(FF = "[object HTMLBaseFontElement]", IE = "[object]") + @Alerts(DEFAULT = "[object HTMLSpanElement]", + FF3_6 = "[object HTMLBaseFontElement]", + IE = "[object]") public void simpleScriptable() throws Exception { final String html = "<html><head>\n" + "<script>\n" @@ -47,6 +49,8 @@ + "</body></html>"; final HtmlPage page = loadPageWithAlerts(html); - assertTrue(HtmlBaseFont.class.isInstance(page.getHtmlElementById("myId"))); + if (getBrowserVersion().isIE()) { + assertTrue(HtmlBaseFont.class.isInstance(page.getHtmlElementById("myId"))); + } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -21,8 +21,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; -import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -68,7 +66,6 @@ @Test @Alerts(DEFAULT = { "-undefined", "-", "-" }, IE = { "OK-undefined", "-", "-" }) - @NotYetImplemented(Browser.IE) public void defaultValues() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -137,7 +134,6 @@ "newValue-newDefault", "newValue-newDefault" }, IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void resetByClick() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -179,7 +175,6 @@ "newValue-newDefault", "newValue-newDefault" }, IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void resetByJS() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" @@ -218,7 +213,6 @@ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }, IE8 = { "OK-undefined", "OK-default", "newValue-default", "newValue-newDefault" }) - @NotYetImplemented(Browser.IE) public void defaultValue() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlIsIndex2Test.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -49,10 +49,12 @@ + " alert(document.getElementById('myId'));\n" + " }\n" + "</script>\n" - + "</head><body onload='test()'>\n" - + "<form id='form1' method='post'>\n" - + "<isindex id='myId' prompt='enterSomeText'></isindex>\n" - + "</form></body></html>"; + + "</head>\n" + + "<body onload='test()'>\n" + + " <form id='form1' method='post'>\n" + + " <isindex id='myId' prompt='enterSomeText'></isindex>\n" + + " </form>\n" + + "</body></html>"; final WebDriver driver = loadPageWithAlerts2(html); if (driver instanceof HtmlUnitDriver) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java 2013-05-26 20:12:57 UTC (rev 8311) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DocumentFragmentTest.java 2013-05-27 10:05:23 UTC (rev 8312) @@ -48,16 +48,16 @@ IE = "exception") public void getComputedStyleOnChild() throws Exception { final String html = "<html><head><style>\n" - + "body > div { background-color: green#FF0000; }\n" + + " body > div { background-color: green#FF0000; }\n" + "</style></head>\n" + "<body>\n" + "<script>\n" - + "try {\n" - + " var frag = document.createDocumentFragment();\n" - + " var d = document.createElement('div');\n" - + " frag.appendChild(d);\n" - + " alert(window.getComputedStyle(d, null));\n" - + "} catch (e) { alert('exception'); }\n" + + " try {\n" + + " var frag = document.createDocumentFragment();\n" + + " var d = document.createElement('div');\n" + + " frag.appendChild(d);\n" + + " alert(window.getComputedStyle(d, null));\n" + + " } catch (e) { alert('exception'); }\n" + "</script>\n" + "</body>\n" + "</html>"; |