From: <rb...@us...> - 2013-10-13 11:27:28
|
Revision: 8653 http://sourceforge.net/p/htmlunit/code/8653 Author: rbri Date: 2013-10-13 11:27:24 +0000 (Sun, 13 Oct 2013) Log Message: ----------- some more HTMLElementClasses added to come closer to the modern browsers Modified Paths: -------------- 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/HTMLBlockQuoteElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDelElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInsElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlModificationTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElementTest.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionDescriptionElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionTermElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElementTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -722,6 +722,11 @@ @BrowserFeature(@WebBrowser(IE)) JS_ATTR_FIRST_LAST_CHILD_RETURNS_NULL, + /** Indicates that HTMLBlockElements returning 'HTMLElement' + * as class name. */ + @BrowserFeature(@WebBrowser(FF)) + JS_BLOCK_COMMON_CLASS_NAME, + /** Indicates that the getBoundingClientRect adds an offset of 2. */ @BrowserFeature(@WebBrowser(IE)) JS_BOUNDING_CLIENT_RECT_OFFSET_TWO, @@ -785,6 +790,11 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) JS_DEFINE_GETTER, + /** Indicates that HTMLDefinition...Elements returning 'HTMLElement' + * as class name. */ + @BrowserFeature(@WebBrowser(FF)) + JS_DEFINITION_COMMON_CLASS_NAME, + /** Javascript doctyp.entities returns an empty string (IE). */ @BrowserFeature(@WebBrowser(IE)) JS_DOCTYPE_ENTITIES_EMPTY_STRING, @@ -993,6 +1003,11 @@ @BrowserFeature({ @WebBrowser(value = IE, minVersion = 8), @WebBrowser(FF), @WebBrowser(CHROME) }) JS_LOCATION_HASH_IS_DECODED, + /** Indicates that HTMLModElements returning 'HTMLPhraseElement' + * as class name. */ + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 8)) + JS_MOD_PHRASE_CLASS_NAME, + /** * Indicates if the String representation of a native function begins and ends with a \n. */ @@ -1033,6 +1048,11 @@ @BrowserFeature(@WebBrowser(IE)) JS_PARENT_PROTO_PROPERTIES, + /** Indicates that HTMLPhraseElements returning 'HTMLElement' + * as class name. */ + @BrowserFeature(@WebBrowser(FF)) + JS_PHRASE_COMMON_CLASS_NAME, + /** Indicates that the prefix property returns an empty string if no prefix defined. */ @BrowserFeature(@WebBrowser(IE)) JS_PREFIX_RETURNS_EMPTY_WHEN_UNDEFINED, @@ -1041,6 +1061,11 @@ @BrowserFeature(@WebBrowser(value = FF, maxVersion = 3.6f)) JS_QUERYCOMMAND_SUPPORTED_ONLY_DESIGNMODE, + /** Indicates that HTMLBlockQuoteElement returning 'HTMLBlockElement' + * as class name. */ + @BrowserFeature(@WebBrowser(IE)) + JS_QUOTE_CLASS_NAMEBLOCK, + /** Javascript script.text(...) reexecutes the script (IE). */ @BrowserFeature(@WebBrowser(IE)) JS_SCRIPT_ALWAYS_REEXECUTE_ON_SET_TEXT, 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 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -130,6 +130,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBRElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBaseFontElement; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBlockElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBlockQuoteElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBodyElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLButtonElement; @@ -137,6 +138,8 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollectionTags; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDListElement; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDefinitionDescriptionElement; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDefinitionTermElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDelElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDirectoryElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement; @@ -175,6 +178,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLOptionsCollection; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLParagraphElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLParamElement; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLPhraseElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLPreElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLProgressElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement; @@ -296,8 +300,11 @@ FormChild.class, FormField.class, Geolocation.class, History.class, HTMLAnchorElement.class, HTMLAppletElement.class, HTMLAreaElement.class, HTMLAudioElement.class, HTMLBRElement.class, HTMLBaseElement.class, HTMLBaseFontElement.class, HTMLBGSoundElement.class, + HTMLBlockElement.class, HTMLBlockQuoteElement.class, HTMLBodyElement.class, HTMLButtonElement.class, HTMLCanvasElement.class, - HTMLCollection.class, HTMLCollectionTags.class, HTMLDListElement.class, + HTMLCollection.class, HTMLCollectionTags.class, + HTMLDefinitionDescriptionElement.class, HTMLDefinitionTermElement.class, + HTMLDListElement.class, HTMLDelElement.class, HTMLDirectoryElement.class, HTMLDivElement.class, HTMLDocument.class, HTMLElement.class, HTMLEmbedElement.class, HTMLFieldSetElement.class, HTMLFontElement.class, HTMLFormElement.class, HTMLFrameElement.class, HTMLFrameSetElement.class, @@ -308,6 +315,7 @@ HTMLMediaElement.class, HTMLMenuElement.class, HTMLMetaElement.class, HTMLMeterElement.class, HTMLOListElement.class, HTMLObjectElement.class, HTMLOptGroupElement.class, HTMLOptionElement.class, HTMLOptionsCollection.class, HTMLParagraphElement.class, HTMLParamElement.class, + HTMLPhraseElement.class, HTMLPreElement.class, HTMLProgressElement.class, HTMLScriptElement.class, HTMLSelectElement.class, HTMLSourceElement.class, HTMLSpacerElement.class, HTMLSpanElement.class, HTMLStyleElement.class, HTMLTableCaptionElement.class, HTMLTableCellElement.class, HTMLTableColElement.class, Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockElement.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -0,0 +1,99 @@ +/* + * 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 static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_BLOCK_COMMON_CLASS_NAME; + +import com.gargoylesoftware.htmlunit.html.DomNode; +import com.gargoylesoftware.htmlunit.html.HtmlCenter; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject; + +/** + * The JavaScript object "HTMLBlockElement". + * + * @version $Revision$ + * @author Ronald Brill + */ +@JsxClass(domClasses = { HtmlCenter.class }) +public class HTMLBlockElement extends HTMLElement { + + /** + * Sets the DOM node that corresponds to this JavaScript object. + * @param domNode the DOM node + */ + @Override + public void setDomNode(final DomNode domNode) { + super.setDomNode(domNode); + + if (domNode instanceof HtmlCenter) { + ActiveXObject.addProperty(this, "cite", true, true); + } + } + + /** + * Returns the value of the "cite" property. + * @return the value of the "cite" property + */ + public String getCite() { + final String cite = getDomNodeOrDie().getAttribute("cite"); + return cite; + } + + /** + * Returns the value of the "cite" property. + * @param cite the value + */ + public void setCite(final String cite) { + getDomNodeOrDie().setAttribute("cite", cite); + } + + /** + * Returns the value of the "dateTime" property. + * @return the value of the "dateTime" property + */ + public String getDateTime() { + final String dateTime = getDomNodeOrDie().getAttribute("datetime"); + return dateTime; + } + + /** + * Returns the value of the "dateTime" property. + * @param dateTime the value + */ + public void setDateTime(final String dateTime) { + getDomNodeOrDie().setAttribute("datetime", dateTime); + } + + /** + * Returns whether the end tag is forbidden or not. + * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a> + * @return whether the end tag is forbidden or not + */ + protected boolean isEndTagForbidden() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_BLOCK_COMMON_CLASS_NAME)) { + return "HTMLElement"; + } + return super.getClassName(); + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockElement.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 Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockQuoteElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockQuoteElement.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBlockQuoteElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_QUOTE_CLASS_NAMEBLOCK; + import com.gargoylesoftware.htmlunit.html.HtmlBlockQuote; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; @@ -34,6 +36,9 @@ */ @Override public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_QUOTE_CLASS_NAMEBLOCK)) { + return "HTMLBlockElement"; + } return "HTMLQuoteElement"; } Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionDescriptionElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionDescriptionElement.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionDescriptionElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -0,0 +1,84 @@ +/* + * 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 static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DEFINITION_COMMON_CLASS_NAME; + +import com.gargoylesoftware.htmlunit.html.HtmlDefinitionDescription; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; + +/** + * The JavaScript object "HTMLDefinitionDescriptionElement". + * + * @version $Revision$ + * @author Ronald Brill + */ +@JsxClass(domClasses = { HtmlDefinitionDescription.class }) +public class HTMLDefinitionDescriptionElement extends HTMLElement { + + /** + * Returns the value of the "cite" property. + * @return the value of the "cite" property + */ + public String getCite() { + final String cite = getDomNodeOrDie().getAttribute("cite"); + return cite; + } + + /** + * Returns the value of the "cite" property. + * @param cite the value + */ + public void setCite(final String cite) { + getDomNodeOrDie().setAttribute("cite", cite); + } + + /** + * Returns the value of the "dateTime" property. + * @return the value of the "dateTime" property + */ + public String getDateTime() { + final String dateTime = getDomNodeOrDie().getAttribute("datetime"); + return dateTime; + } + + /** + * Returns the value of the "dateTime" property. + * @param dateTime the value + */ + public void setDateTime(final String dateTime) { + getDomNodeOrDie().setAttribute("datetime", dateTime); + } + + /** + * Returns whether the end tag is forbidden or not. + * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a> + * @return whether the end tag is forbidden or not + */ + protected boolean isEndTagForbidden() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_DEFINITION_COMMON_CLASS_NAME)) { + return "HTMLElement"; + } + return "HTMLDDElement"; + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionDescriptionElement.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 Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionTermElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionTermElement.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionTermElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -0,0 +1,84 @@ +/* + * 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 static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DEFINITION_COMMON_CLASS_NAME; + +import com.gargoylesoftware.htmlunit.html.HtmlDefinitionTerm; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; + +/** + * The JavaScript object "HTMLDefinitionTermElement". + * + * @version $Revision$ + * @author Ronald Brill + */ +@JsxClass(domClasses = { HtmlDefinitionTerm.class }) +public class HTMLDefinitionTermElement extends HTMLElement { + + /** + * Returns the value of the "cite" property. + * @return the value of the "cite" property + */ + public String getCite() { + final String cite = getDomNodeOrDie().getAttribute("cite"); + return cite; + } + + /** + * Returns the value of the "cite" property. + * @param cite the value + */ + public void setCite(final String cite) { + getDomNodeOrDie().setAttribute("cite", cite); + } + + /** + * Returns the value of the "dateTime" property. + * @return the value of the "dateTime" property + */ + public String getDateTime() { + final String dateTime = getDomNodeOrDie().getAttribute("datetime"); + return dateTime; + } + + /** + * Returns the value of the "dateTime" property. + * @param dateTime the value + */ + public void setDateTime(final String dateTime) { + getDomNodeOrDie().setAttribute("datetime", dateTime); + } + + /** + * Returns whether the end tag is forbidden or not. + * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a> + * @return whether the end tag is forbidden or not + */ + protected boolean isEndTagForbidden() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_DEFINITION_COMMON_CLASS_NAME)) { + return "HTMLElement"; + } + return "HTMLDTElement"; + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDefinitionTermElement.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 Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDelElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDelElement.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDelElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_MOD_PHRASE_CLASS_NAME; + import com.gargoylesoftware.htmlunit.html.HtmlDeletedText; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; @@ -75,4 +77,15 @@ public String getDefaultStyleDisplay() { return "inline"; } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_MOD_PHRASE_CLASS_NAME)) { + return "HTMLPhraseElement"; + } + return "HTMLModElement"; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInsElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInsElement.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInsElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -14,6 +14,8 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_MOD_PHRASE_CLASS_NAME; + import com.gargoylesoftware.htmlunit.html.HtmlInsertedText; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; @@ -75,4 +77,15 @@ public String getDefaultStyleDisplay() { return "inline"; } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_MOD_PHRASE_CLASS_NAME)) { + return "HTMLPhraseElement"; + } + return "HTMLModElement"; + } } Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -0,0 +1,174 @@ +/* + * 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 static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLABBREVIATED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_PHRASE_COMMON_CLASS_NAME; + +import com.gargoylesoftware.htmlunit.html.DomNode; +import com.gargoylesoftware.htmlunit.html.HtmlAbbreviated; +import com.gargoylesoftware.htmlunit.html.HtmlAcronym; +import com.gargoylesoftware.htmlunit.html.HtmlBidirectionalOverride; +import com.gargoylesoftware.htmlunit.html.HtmlBig; +import com.gargoylesoftware.htmlunit.html.HtmlBlink; +import com.gargoylesoftware.htmlunit.html.HtmlBold; +import com.gargoylesoftware.htmlunit.html.HtmlCitation; +import com.gargoylesoftware.htmlunit.html.HtmlCode; +import com.gargoylesoftware.htmlunit.html.HtmlDefinition; +import com.gargoylesoftware.htmlunit.html.HtmlEmphasis; +import com.gargoylesoftware.htmlunit.html.HtmlItalic; +import com.gargoylesoftware.htmlunit.html.HtmlKeyboard; +import com.gargoylesoftware.htmlunit.html.HtmlNoBreak; +import com.gargoylesoftware.htmlunit.html.HtmlS; +import com.gargoylesoftware.htmlunit.html.HtmlSample; +import com.gargoylesoftware.htmlunit.html.HtmlSmall; +import com.gargoylesoftware.htmlunit.html.HtmlStrike; +import com.gargoylesoftware.htmlunit.html.HtmlStrong; +import com.gargoylesoftware.htmlunit.html.HtmlSubscript; +import com.gargoylesoftware.htmlunit.html.HtmlSuperscript; +import com.gargoylesoftware.htmlunit.html.HtmlTeletype; +import com.gargoylesoftware.htmlunit.html.HtmlUnderlined; +import com.gargoylesoftware.htmlunit.html.HtmlVariable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject; + +/** + * The JavaScript object "HTMLSpanElement". + * + * @version $Revision$ + * @author Ahmed Ashour + * @author Daniel Gredler + * @author Ronald Brill + */ +@JsxClass(domClasses = { + HtmlAbbreviated.class, + HtmlAcronym.class, + HtmlBidirectionalOverride.class, HtmlBig.class, HtmlBlink.class, HtmlBold.class, + HtmlCitation.class, HtmlCode.class, + HtmlDefinition.class, + HtmlEmphasis.class, + HtmlItalic.class, + HtmlKeyboard.class, + HtmlNoBreak.class, + HtmlS.class, HtmlSample.class, HtmlSmall.class, HtmlStrike.class, + HtmlSubscript.class, HtmlSuperscript.class, HtmlStrong.class, + HtmlTeletype.class, + HtmlUnderlined.class, + HtmlVariable.class, + }) +public class HTMLPhraseElement extends HTMLElement { + private boolean endTagForbidden_; + + /** + * Sets the DOM node that corresponds to this JavaScript object. + * @param domNode the DOM node + */ + @Override + public void setDomNode(final DomNode domNode) { + super.setDomNode(domNode); + + if ((domNode instanceof HtmlAbbreviated && getBrowserVersion().hasFeature(HTMLABBREVIATED)) + || domNode instanceof HtmlAcronym + || domNode instanceof HtmlBidirectionalOverride + || domNode instanceof HtmlBig + || domNode instanceof HtmlBlink + || domNode instanceof HtmlBold + || domNode instanceof HtmlCitation + || domNode instanceof HtmlCode + || domNode instanceof HtmlDefinition + || domNode instanceof HtmlEmphasis + || domNode instanceof HtmlItalic + || domNode instanceof HtmlKeyboard + || domNode instanceof HtmlNoBreak + || domNode instanceof HtmlS + || domNode instanceof HtmlSample + || domNode instanceof HtmlSmall + || domNode instanceof HtmlStrong + || domNode instanceof HtmlStrike + || domNode instanceof HtmlSubscript + || domNode instanceof HtmlSuperscript + || domNode instanceof HtmlTeletype + || domNode instanceof HtmlUnderlined + || domNode instanceof HtmlVariable + ) { + ActiveXObject.addProperty(this, "cite", true, true); + ActiveXObject.addProperty(this, "dateTime", true, true); + return; + } + } + + /** + * Returns the value of the "cite" property. + * @return the value of the "cite" property + */ + public String getCite() { + final String cite = getDomNodeOrDie().getAttribute("cite"); + return cite; + } + + /** + * Returns the value of the "cite" property. + * @param cite the value + */ + public void setCite(final String cite) { + getDomNodeOrDie().setAttribute("cite", cite); + } + + /** + * Returns the value of the "dateTime" property. + * @return the value of the "dateTime" property + */ + public String getDateTime() { + final String dateTime = getDomNodeOrDie().getAttribute("datetime"); + return dateTime; + } + + /** + * Returns the value of the "dateTime" property. + * @param dateTime the value + */ + public void setDateTime(final String dateTime) { + getDomNodeOrDie().setAttribute("datetime", dateTime); + } + + /** + * Returns whether the end tag is forbidden or not. + * @see <a href="http://www.w3.org/TR/html4/index/elements.html">HTML 4 specs</a> + * @return whether the end tag is forbidden or not + */ + protected boolean isEndTagForbidden() { + return endTagForbidden_; + } + + /** + * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br/> + * {@inheritDoc} + */ + @Override + public String getDefaultStyleDisplay() { + return "inline"; + } + + /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null && getBrowserVersion().hasFeature(JS_PHRASE_COMMON_CLASS_NAME)) { + return "HTMLElement"; + } + return super.getClassName(); + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElement.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 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 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElement.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -15,42 +15,15 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_90; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLABBREVIATED; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.html.DomNode; -import com.gargoylesoftware.htmlunit.html.HtmlAbbreviated; -import com.gargoylesoftware.htmlunit.html.HtmlAcronym; import com.gargoylesoftware.htmlunit.html.HtmlAddress; -import com.gargoylesoftware.htmlunit.html.HtmlBidirectionalOverride; -import com.gargoylesoftware.htmlunit.html.HtmlBig; -import com.gargoylesoftware.htmlunit.html.HtmlBlink; -import com.gargoylesoftware.htmlunit.html.HtmlBold; -import com.gargoylesoftware.htmlunit.html.HtmlCenter; -import com.gargoylesoftware.htmlunit.html.HtmlCitation; -import com.gargoylesoftware.htmlunit.html.HtmlCode; -import com.gargoylesoftware.htmlunit.html.HtmlDefinition; -import com.gargoylesoftware.htmlunit.html.HtmlDefinitionDescription; -import com.gargoylesoftware.htmlunit.html.HtmlDefinitionTerm; -import com.gargoylesoftware.htmlunit.html.HtmlEmphasis; import com.gargoylesoftware.htmlunit.html.HtmlExample; -import com.gargoylesoftware.htmlunit.html.HtmlItalic; -import com.gargoylesoftware.htmlunit.html.HtmlKeyboard; import com.gargoylesoftware.htmlunit.html.HtmlListing; import com.gargoylesoftware.htmlunit.html.HtmlMultiColumn; -import com.gargoylesoftware.htmlunit.html.HtmlNoBreak; import com.gargoylesoftware.htmlunit.html.HtmlPlainText; -import com.gargoylesoftware.htmlunit.html.HtmlS; -import com.gargoylesoftware.htmlunit.html.HtmlSample; -import com.gargoylesoftware.htmlunit.html.HtmlSmall; import com.gargoylesoftware.htmlunit.html.HtmlSpan; -import com.gargoylesoftware.htmlunit.html.HtmlStrike; -import com.gargoylesoftware.htmlunit.html.HtmlStrong; -import com.gargoylesoftware.htmlunit.html.HtmlSubscript; -import com.gargoylesoftware.htmlunit.html.HtmlSuperscript; -import com.gargoylesoftware.htmlunit.html.HtmlTeletype; -import com.gargoylesoftware.htmlunit.html.HtmlUnderlined; -import com.gargoylesoftware.htmlunit.html.HtmlVariable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject; @@ -62,13 +35,12 @@ * @author Daniel Gredler * @author Ronald Brill */ -@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, - HtmlMultiColumn.class, HtmlNoBreak.class, HtmlPlainText.class, HtmlS.class, HtmlSample.class, - HtmlSmall.class, HtmlSpan.class, HtmlStrike.class, HtmlStrong.class, HtmlSubscript.class, - HtmlSuperscript.class, HtmlTeletype.class, HtmlUnderlined.class, HtmlVariable.class, HtmlExample.class }) +@JsxClass(domClasses = { + HtmlAddress.class, + HtmlListing.class, + HtmlMultiColumn.class, HtmlPlainText.class, + HtmlSpan.class, + HtmlExample.class }) public class HTMLSpanElement extends HTMLElement { private boolean endTagForbidden_; @@ -88,36 +60,7 @@ return; } - if ((domNode instanceof HtmlAbbreviated && browser.hasFeature(HTMLABBREVIATED)) - || domNode instanceof HtmlAcronym - || domNode instanceof HtmlBidirectionalOverride - || domNode instanceof HtmlBig - || domNode instanceof HtmlBold - || domNode instanceof HtmlBlink - || domNode instanceof HtmlCitation - || domNode instanceof HtmlCode - || domNode instanceof HtmlDefinition - || domNode instanceof HtmlEmphasis - || domNode instanceof HtmlItalic - || domNode instanceof HtmlKeyboard - || domNode instanceof HtmlNoBreak - || domNode instanceof HtmlS - || domNode instanceof HtmlSample - || domNode instanceof HtmlSmall - || domNode instanceof HtmlStrike - || domNode instanceof HtmlStrong - || domNode instanceof HtmlSubscript - || domNode instanceof HtmlSuperscript - || domNode instanceof HtmlTeletype - || domNode instanceof HtmlUnderlined - || domNode instanceof HtmlVariable) { - ActiveXObject.addProperty(this, "cite", true, true); - ActiveXObject.addProperty(this, "dateTime", true, true); - return; - } - if (domNode instanceof HtmlAddress - || domNode instanceof HtmlCenter || domNode instanceof HtmlExample || domNode instanceof HtmlListing || domNode instanceof HtmlPlainText) { @@ -186,9 +129,7 @@ public String getDefaultStyleDisplay() { final String tagName = getTagName(); if ("ADDRESS".equals(tagName) - || "CENTER".equals(tagName) - || "DD".equals(tagName) - || "DT".equals(tagName)) { + || "CENTER".equals(tagName)) { return super.getDefaultStyleDisplay(); } return "inline"; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlModificationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlModificationTest.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlModificationTest.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -34,7 +34,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(FF = { "[object HTMLInsElement]", "[object HTMLDelElement]" }, IE = { "[object]", "[object]" }) + @Alerts(FF = { "[object HTMLModElement]", "[object HTMLModElement]" }, IE = { "[object]", "[object]" }) public void simpleScriptable() throws Exception { final String html = "<html><head>\n" + "<script>\n" Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElementTest.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -0,0 +1,62 @@ +/* + * 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; + +/** + * Unit tests for {@link HTMLPhraseElement}. + * + * @version $Revision$ + * @author ronald Brill + */ +@RunWith(BrowserRunner.class) +public class HTMLPhraseElementTest extends WebDriverTestCase { + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(FF = {"[object HTMLElement] undefined", "[object HTMLElement] undefined" }, + IE = {"[object] ", "[object] " }, + IE10 = {"[object HTMLPhraseElement] ", "[object HTMLPhraseElement] undefined" }) + @NotYetImplemented(Browser.FF) + public void cite() throws Exception { + final String html = + "<html>\n" + + " <head>\n" + + " <script>\n" + + " function test() {\n" + + " debug(document.createElement('abbr'));\n" + + " debug(document.createElement('big'));\n" + + " }\n" + + " function debug(e) {\n" + + " alert(e + ' ' + e.cite);\n" + + " }\n" + + " </script>\n" + + " </head>\n" + + " <body onload='test()'></body>\n" + + "</html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLPhraseElementTest.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 Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElementTest.java 2013-10-11 13:09:11 UTC (rev 8652) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLSpanElementTest.java 2013-10-13 11:27:24 UTC (rev 8653) @@ -14,14 +14,11 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; -import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF17; - 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.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -69,17 +66,15 @@ * @throws Exception if an error occurs */ @Test - @Alerts(FF = {"[object HTMLElement] undefined", "[object HTMLSpanElement] undefined" }, - IE = {"[object] ", "[object] undefined" }, - IE10 = {"[object HTMLPhraseElement] ", "[object HTMLSpanElement] undefined" }) - @NotYetImplemented(FF17) + @Alerts(FF = "[object HTMLSpanElement] undefined" , + IE = "[object] undefined", + IE10 = "[object HTMLSpanElement] undefined") public void cite() throws Exception { final String html = "<html>\n" + " <head>\n" + " <script>\n" + " function test() {\n" - + " debug(document.createElement('abbr'));\n" + " debug(document.createElement('span'));\n" + " }\n" + " function debug(e) {\n" |