From: <asa...@us...> - 2012-11-25 14:38:53
|
Revision: 7769 http://sourceforge.net/p/htmlunit/code/7769 Author: asashour Date: 2012-11-25 14:38:51 +0000 (Sun, 25 Nov 2012) Log Message: ----------- JavaScript: fix the return value of element.getAttribute() in standards mode (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/Element.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-25 13:33:33 UTC (rev 7768) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-25 14:38:51 UTC (rev 7769) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> <action type="fix" dev="asashour"> + 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). </action> <action type="fix" dev="mguillem"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-11-25 13:33:33 UTC (rev 7768) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2012-11-25 14:38:51 UTC (rev 7769) @@ -873,9 +873,9 @@ @BrowserFeature(@WebBrowser(FF)) JS_FUNCTION_TOSOURCE, - /** Indicates that the getAttribute method supports ie style flags. */ + /** Indicates that the getAttribute method supports IE style flags, only in quirks mode . */ @BrowserFeature(@WebBrowser(IE)) - JS_GET_ATTRIBUTE_SUPPORTS_FLAGS, + JS_GET_ATTRIBUTE_SUPPORTS_FLAGS_IN_QUIRKS_MODE, /** Javascript function getBackgroundColor of computed styles returns the color as rgb. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2012-11-25 13:33:33 UTC (rev 7768) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2012-11-25 14:38:51 UTC (rev 7769) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_37; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_ATTRIBUTE_SUPPORTS_FLAGS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_ATTRIBUTE_SUPPORTS_FLAGS_IN_QUIRKS_MODE; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; @@ -27,9 +27,11 @@ import net.sourceforge.htmlunit.corejs.javascript.Scriptable; +import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.html.DomAttr; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.DomNode; +import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.javascript.NamedNodeMap; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; @@ -139,7 +141,9 @@ @JsxFunction public Object getAttribute(String attributeName, final Integer flags) { attributeName = fixAttributeName(attributeName); - final boolean supportsFlags = getBrowserVersion().hasFeature(JS_GET_ATTRIBUTE_SUPPORTS_FLAGS); + final Page page = getDomNodeOrDie().getPage(); + final boolean supportsFlags = getBrowserVersion().hasFeature(JS_GET_ATTRIBUTE_SUPPORTS_FLAGS_IN_QUIRKS_MODE) + && page instanceof HtmlPage && ((HtmlPage) page).isQuirksMode(); Object value; if (supportsFlags && flags != null && flags == 2 && "style".equalsIgnoreCase(attributeName)) { 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-25 13:33:33 UTC (rev 7768) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2012-11-25 14:38:51 UTC (rev 7769) @@ -2665,7 +2665,6 @@ */ @Test @Alerts({ "null", "", "null", "undefined" }) - @NotYetImplemented(IE) public void getAttribute2_standards() 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-25 13:33:33 UTC (rev 7768) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2012-11-25 14:38:51 UTC (rev 7769) @@ -1457,7 +1457,6 @@ @Alerts(FF3_6 = "attributes: attr(String) (0, 46, 46)", FF10 = "attributes: attr(String) in XML Files (0, 3, 3)", CHROME = "attributes: attr(String) in XML Files (0, 3, 3)", IE = "attributes: attr(String) (0, 46, 46)") - @NotYetImplemented(IE) public void test_139() throws Exception { runTest(139); } @@ -1503,7 +1502,6 @@ FF10 = "attributes: attr(jquery_method) (0, 9, 9)", CHROME = "attributes: attr(jquery_method) (0, 9, 9)", IE = "attributes: attr(String, Object) (0, 81, 81)") - @NotYetImplemented(IE) public void test_143() throws Exception { runTest(143); } @@ -1562,7 +1560,6 @@ FF10 = "attributes: removeAttr(String) in XML (0, 7, 7)", CHROME = "attributes: removeAttr(String) in XML (0, 7, 7)", IE = "attributes: removeAttr(String) (0, 12, 12)") - @NotYetImplemented(IE) public void test_148() throws Exception { runTest(148); } @@ -1588,7 +1585,6 @@ FF10 = "attributes: prop(String, Object) (0, 31, 31)", CHROME = "attributes: prop(String, Object) (0, 31, 31)", IE = "attributes: removeAttr(Multi String, variable space width) (0, 8, 8)") - @NotYetImplemented(IE) public void test_150() throws Exception { runTest(150); } |