From: <asa...@us...> - 2017-05-31 09:14:55
|
Revision: 14506 http://sourceforge.net/p/htmlunit/code/14506 Author: asashour Date: 2017-05-31 09:14:52 +0000 (Wed, 31 May 2017) Log Message: ----------- DocumentFragment fix Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentFragment.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentFragment.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentFragment.java 2017-05-31 08:43:17 UTC (rev 14505) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DocumentFragment.java 2017-05-31 09:14:52 UTC (rev 14506) @@ -17,7 +17,6 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; -import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE; import org.w3c.css.sac.CSSException; @@ -26,7 +25,6 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; -import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import net.sourceforge.htmlunit.corejs.javascript.Context; @@ -42,8 +40,6 @@ @JsxClass(domClass = DomDocumentFragment.class) public class DocumentFragment extends Node { - //TODO: seems that in IE, DocumentFragment extends HTMLDocument - /** * Creates an instance. */ @@ -52,55 +48,6 @@ } /** - * Creates a new HTML attribute with the specified name. - * - * @param attributeName the name of the attribute to create - * @return an attribute with the specified name - */ - @JsxFunction(IE) - public Object createAttribute(final String attributeName) { - return getDocument().createAttribute(attributeName); - } - - /** - * Returns HTML document. - * @return HTML document - */ - protected HTMLDocument getDocument() { - return (HTMLDocument) getDomNodeOrDie().getPage().getScriptableObject(); - } - - /** - * Creates a new Comment. - * @param comment the comment text - * @return the new Comment - */ - @JsxFunction(IE) - public Object createComment(final String comment) { - return getDocument().createComment(comment); - } - - /** - * Creates a new document fragment. - * @return a newly created document fragment - */ - @JsxFunction(IE) - public Object createDocumentFragment() { - return getDocument().createDocumentFragment(); - } - - /** - * Create a new DOM text node with the given data. - * - * @param newData the string value for the text node - * @return the new text node or NOT_FOUND if there is an error - */ - @JsxFunction(IE) - public Object createTextNode(final String newData) { - return getDocument().createTextNode(newData); - } - - /** * Retrieves all element nodes from descendants of the starting element node that match any selector * within the supplied selector strings. * The NodeList object returned by the querySelectorAll() method must be static, not live. Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-05-31 08:43:17 UTC (rev 14505) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-05-31 09:14:52 UTC (rev 14506) @@ -3178,4 +3178,45 @@ testString("document.createRange(), window.performance"); } + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "append(),appendChild(),ATTRIBUTE_NODE,baseURI,CDATA_SECTION_NODE,childElementCount,childNodes," + + "children,cloneNode(),COMMENT_NODE,compareDocumentPosition(),contains(),DOCUMENT_FRAGMENT_NODE," + + "DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS," + + "DOCUMENT_POSITION_DISCONNECTED,DOCUMENT_POSITION_FOLLOWING," + + "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,DOCUMENT_POSITION_PRECEDING,DOCUMENT_TYPE_NODE," + + "ELEMENT_NODE,ENTITY_NODE,ENTITY_REFERENCE_NODE,firstChild,firstElementChild,getElementById()," + + "getRootNode(),hasChildNodes(),insertBefore(),isConnected,isDefaultNamespace(),isEqualNode()," + + "isSameNode(),lastChild,lastElementChild,lookupNamespaceURI(),lookupPrefix(),nextSibling,nodeName," + + "nodeType,nodeValue,normalize(),NOTATION_NODE,ownerDocument,parentElement,parentNode,prepend()," + + "previousSibling,PROCESSING_INSTRUCTION_NODE,querySelector(),querySelectorAll(),removeChild()," + + "replaceChild(),TEXT_NODE,textContent", + FF = "addEventListener(),append(),appendChild(),ATTRIBUTE_NODE,baseURI,CDATA_SECTION_NODE," + + "childElementCount,childNodes,children,cloneNode(),COMMENT_NODE,compareDocumentPosition(),contains()," + + "dispatchEvent(),DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE,DOCUMENT_POSITION_CONTAINED_BY," + + "DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_DISCONNECTED,DOCUMENT_POSITION_FOLLOWING," + + "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,DOCUMENT_POSITION_PRECEDING,DOCUMENT_TYPE_NODE," + + "ELEMENT_NODE,ENTITY_NODE,ENTITY_REFERENCE_NODE,firstChild,firstElementChild,getElementById()," + + "hasChildNodes(),insertBefore(),isConnected,isDefaultNamespace(),isEqualNode(),isSameNode()," + + "lastChild,lastElementChild,lookupNamespaceURI(),lookupPrefix(),nextSibling,nodeName,nodeType," + + "nodeValue,normalize(),NOTATION_NODE,ownerDocument,parentElement,parentNode,prepend()," + + "previousSibling,PROCESSING_INSTRUCTION_NODE,querySelector(),querySelectorAll(),removeChild()," + + "removeEventListener(),replaceChild(),TEXT_NODE,textContent", + IE = "addEventListener(),appendChild(),ATTRIBUTE_NODE,attributes,CDATA_SECTION_NODE,childNodes,cloneNode()," + + "COMMENT_NODE,compareDocumentPosition(),dispatchEvent(),DOCUMENT_FRAGMENT_NODE,DOCUMENT_NODE," + + "DOCUMENT_POSITION_CONTAINED_BY,DOCUMENT_POSITION_CONTAINS,DOCUMENT_POSITION_DISCONNECTED," + + "DOCUMENT_POSITION_FOLLOWING,DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC,DOCUMENT_POSITION_PRECEDING," + + "DOCUMENT_TYPE_NODE,ELEMENT_NODE,ENTITY_NODE,ENTITY_REFERENCE_NODE,firstChild,hasAttributes()," + + "hasChildNodes(),insertBefore(),isDefaultNamespace(),isEqualNode(),isSameNode(),isSupported()," + + "lastChild,localName,lookupNamespaceURI(),lookupPrefix(),namespaceURI,nextSibling,nodeName,nodeType," + + "nodeValue,normalize(),NOTATION_NODE,ownerDocument,parentNode,prefix,previousSibling," + + "PROCESSING_INSTRUCTION_NODE,querySelector(),querySelectorAll(),removeChild(),removeEventListener()," + + "removeNode(),replaceChild(),replaceNode(),swapNode(),TEXT_NODE,textContent") + @NotYetImplemented + public void documentFragment() throws Exception { + testString("document.createDocumentFragment(), window.performance"); + } + } |