From: <rb...@us...> - 2013-05-26 15:56:51
|
Revision: 8308 http://sourceforge.net/p/htmlunit/code/8308 Author: rbri Date: 2013-05-26 15:56:47 +0000 (Sun, 26 May 2013) Log Message: ----------- Basefont support removed from Firefox after 3.6. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/changes/changes.xml 2013-05-26 15:56:47 UTC (rev 8308) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="rbri"> + Basefont support removed from Firefox after 3.6. + </action> + <action type="fix" dev="rbri"> Adjust the window.outherHeight for the newer FF versions. </action> <action type="fix" dev="rbri" issue="1488"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -538,8 +538,11 @@ @BrowserFeature(@WebBrowser(value = IE, minVersion = 7)) HTMLABBREVIATED, - /** Should {@link com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement#isEndTagForbidden} - * return <code>true</code>. */ + /** Supports basefont. */ + @BrowserFeature({ @WebBrowser(IE), @WebBrowser(value = FF, maxVersion = 3.6f) }) + HTMLBASEFONT_SUPPORTED, + + /** Should {@link com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement#isEndTagForbidden}. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLBASEFONT_END_TAG_FORBIDDEN, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -16,6 +16,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CANVAS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTML5_TAGS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_SUPPORTED; import java.util.Arrays; import java.util.LinkedHashMap; @@ -180,7 +181,12 @@ element = new HtmlBase(namespaceURI, qualifiedName, page, attributeMap); } else if (tagName.equals(HtmlBaseFont.TAG_NAME)) { - element = new HtmlBaseFont(namespaceURI, qualifiedName, page, attributeMap); + if (page.getWebClient().getBrowserVersion().hasFeature(HTMLBASEFONT_SUPPORTED)) { + element = new HtmlBaseFont(namespaceURI, qualifiedName, page, attributeMap); + } + else { + element = new HtmlSpan(namespaceURI, qualifiedName, page, attributeMap); + } } else if (tagName.equals(HtmlBidirectionalOverride.TAG_NAME)) { element = new HtmlBidirectionalOverride(namespaceURI, qualifiedName, page, attributeMap); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlBaseFont.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -42,6 +42,9 @@ HtmlBaseFont(final String namespaceURI, final String qualifiedName, final SgmlPage page, final Map<String, DomAttr> attributes) { super(namespaceURI, qualifiedName, page, attributes); + if (ATTRIBUTE_NOT_DEFINED == getSizeAttribute()) { + setAttribute("size", "3"); + } } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java 2013-05-26 15:05:39 UTC (rev 8307) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElement.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -15,12 +15,15 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLBASEFONT_END_TAG_FORBIDDEN; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import net.sourceforge.htmlunit.corejs.javascript.Context; import com.gargoylesoftware.htmlunit.html.HtmlBaseFont; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; /** * The JavaScript object "HTMLBaseFontElement". @@ -28,7 +31,7 @@ * @version $Revision$ * @author Ahmed Ashour */ -@JsxClass(domClasses = HtmlBaseFont.class) +@JsxClass(domClasses = HtmlBaseFont.class, browsers = { @WebBrowser(IE), @WebBrowser(value = FF, maxVersion = 3.6f) }) public class HTMLBaseFontElement extends HTMLElement { /** Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java 2013-05-26 15:56:47 UTC (rev 8308) @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.javascript.host.html; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link HTMLBaseFontElement}. + * @version $Revision:$ + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HTMLBaseFontElementTest extends WebDriverTestCase { + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented(Browser.FF3_6) + @Alerts(DEFAULT = { "[object HTMLSpanElement]", "undefined", "undefined", "undefined" }, + FF3_6 = { "[object HTMLBaseFontElement]", "", "-1", "" }, + IE = { "[object]", "", "3", "" }) + public void defaults() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base);\n" + + " alert(base.face);\n" + + " alert(base.size);\n" + + " alert(base.color);\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17 }) + @Alerts(DEFAULT = { "undefined", "42" }, + FF3_6 = { "4", "42" }, + IE = { "4", "42" }) + public void size() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='4' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.size);\n" + + " try {\n" + + " base.size=42;\n" + + " alert(base.size);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17 }) + @Alerts(DEFAULT = { "undefined", "helvetica" }, + FF3_6 = { "swiss", "helvetica" }, + IE = { "swiss", "helvetica" }) + public void face() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='5' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.face);\n" + + " try {\n" + + " base.face='helvetica';\n" + + " alert(base.face);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } + /** + * @throws Exception if an error occurs + */ + @Test + @NotYetImplemented({ Browser.FF10, Browser.FF17, Browser.IE }) + @Alerts(DEFAULT = { "undefined", "blue" }, + FF3_6 = { "red", "blue" }, + IE = { "#ff0000", "#0000ff" }) + public void color() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <basefont id='base' color='red' face='swiss' size='4' />\n" + + " <script>\n" + + " function test() {\n" + + " var base = document.getElementById('base');\n" + + " alert(base.color);\n" + + " try {\n" + + " base.color='blue';\n" + + " alert(base.color);\n" + + " } catch(e) {\n" + + " alert('exception');\n" + + " }\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'>foo</body>\n" + + "</html>"; + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBaseFontElementTest.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |