From: <asa...@us...> - 2012-11-09 11:12:27
|
Revision: 7705 http://sourceforge.net/p/htmlunit/code/7705 Author: asashour Date: 2012-11-09 11:12:24 +0000 (Fri, 09 Nov 2012) Log Message: ----------- JS host classes: move "dom" to a separate package Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMException.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementation.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMStringMap.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMExceptionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementationTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMParserTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenListTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html Removed Paths: ------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMException.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementation.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenList.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMExceptionTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementationTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParserTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenListTest.java 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 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -38,10 +38,6 @@ import com.gargoylesoftware.htmlunit.javascript.host.ClipboardData; import com.gargoylesoftware.htmlunit.javascript.host.Comment; import com.gargoylesoftware.htmlunit.javascript.host.Console; -import com.gargoylesoftware.htmlunit.javascript.host.DOMException; -import com.gargoylesoftware.htmlunit.javascript.host.DOMImplementation; -import com.gargoylesoftware.htmlunit.javascript.host.DOMParser; -import com.gargoylesoftware.htmlunit.javascript.host.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.Document; import com.gargoylesoftware.htmlunit.javascript.host.DocumentFragment; import com.gargoylesoftware.htmlunit.javascript.host.DocumentType; @@ -117,6 +113,10 @@ import com.gargoylesoftware.htmlunit.javascript.host.css.CSSValue; import com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration; import com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMImplementation; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMParser; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.geo.Coordinates; import com.gargoylesoftware.htmlunit.javascript.host.geo.Geolocation; import com.gargoylesoftware.htmlunit.javascript.host.geo.Position; Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMException.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMException.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMException.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; -import net.sourceforge.htmlunit.corejs.javascript.Context; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; -import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; - -/** - * Exception for DOM manipulations. - * - * @see <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187"> - * DOM-Level-2-Core</a> - * @version $Revision$ - * @author Marc Guillemot - */ -@JsxClass(browsers = @WebBrowser(FF)) -public class DOMException extends SimpleScriptable { - /** If the specified range of text does not fit into a DOMString. */ - @JsxConstant - public static final short DOMSTRING_SIZE_ERR = org.w3c.dom.DOMException.DOMSTRING_SIZE_ERR; - /** If any node is inserted somewhere it doesn't belong. */ - @JsxConstant - public static final short HIERARCHY_REQUEST_ERR = org.w3c.dom.DOMException.HIERARCHY_REQUEST_ERR; - /** If index or size is negative, or greater than the allowed value. */ - @JsxConstant - public static final short INDEX_SIZE_ERR = org.w3c.dom.DOMException.INDEX_SIZE_ERR; - /** If an attempt is made to add an attribute that is already in use elsewhere. */ - @JsxConstant - public static final short INUSE_ATTRIBUTE_ERR = org.w3c.dom.DOMException.INUSE_ATTRIBUTE_ERR; - /** If a parameter or an operation is not supported by the underlying object. */ - @JsxConstant - public static final short INVALID_ACCESS_ERR = org.w3c.dom.DOMException.INVALID_ACCESS_ERR; - /** If an invalid or illegal character is specified, such as in a name. */ - @JsxConstant - public static final short INVALID_CHARACTER_ERR = org.w3c.dom.DOMException.INVALID_CHARACTER_ERR; - /** If an attempt is made to modify the type of the underlying object. */ - @JsxConstant - public static final short INVALID_MODIFICATION_ERR = org.w3c.dom.DOMException.INVALID_MODIFICATION_ERR; - /** If an attempt is made to use an object that is not, or is no longer, usable. */ - @JsxConstant - public static final short INVALID_STATE_ERR = org.w3c.dom.DOMException.INVALID_STATE_ERR; - /** If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. */ - @JsxConstant - public static final short NAMESPACE_ERR = org.w3c.dom.DOMException.NAMESPACE_ERR; - /** If data is specified for a node which does not support data. */ - @JsxConstant - public static final short NO_DATA_ALLOWED_ERR = org.w3c.dom.DOMException.NO_DATA_ALLOWED_ERR; - /** If an attempt is made to modify an object where modifications are not allowed. */ - @JsxConstant - public static final short NO_MODIFICATION_ALLOWED_ERR = org.w3c.dom.DOMException.NO_MODIFICATION_ALLOWED_ERR; - /** If an attempt is made to reference a node in a context where it does not exist. */ - @JsxConstant - public static final short NOT_FOUND_ERR = org.w3c.dom.DOMException.NOT_FOUND_ERR; - /** If the implementation does not support the requested type of object or operation. */ - @JsxConstant - public static final short NOT_SUPPORTED_ERR = org.w3c.dom.DOMException.NOT_SUPPORTED_ERR; - /** If an invalid or illegal string is specified. */ - @JsxConstant - public static final short SYNTAX_ERR = org.w3c.dom.DOMException.SYNTAX_ERR; - /** If a node is used in a different document than the one that created it (that doesn't support it). */ - @JsxConstant - public static final short WRONG_DOCUMENT_ERR = org.w3c.dom.DOMException.WRONG_DOCUMENT_ERR; - - private final short code_; - private final String message_; - private int lineNumber_; - private String fileName_; - - /** - * Default constructor used to build the prototype. - */ - public DOMException() { - code_ = -1; - message_ = null; - } - - /** - * Constructor. - * @param message the exception message - * @param errorCode the error code - */ - public DOMException(final String message, final short errorCode) { - code_ = errorCode; - message_ = message; - } - - /** - * Gets the exception code. - * @return the exception code - */ - @JsxGetter - public Object getCode() { - if (code_ == -1) { - return Context.getUndefinedValue(); - } - return code_; - } - - /** - * Gets the exception message. - * @return the exception message - */ - @JsxGetter - public Object getMessage() { - if (message_ == null) { - return Context.getUndefinedValue(); - } - return message_; - } - - /** - * Gets the line at which the exception occurred. - * @return the line of the exception - */ - @JsxGetter - public Object getLineNumber() { - if (lineNumber_ == -1) { - return Context.getUndefinedValue(); - } - return lineNumber_; - } - - /** - * Gets the name of the in which the exception occurred. - * @return the name of the source file - */ - @JsxGetter - public Object getFilename() { - if (fileName_ == null) { - return Context.getUndefinedValue(); - } - return fileName_; - } - - /** - * Sets the location in JavaScript source where this exception occurred. - * @param fileName the name of the source file - * @param lineNumber the line number - */ - public void setLocation(final String fileName, final int lineNumber) { - fileName_ = fileName; - lineNumber_ = lineNumber; - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementation.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementation.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementation.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_35; -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; -import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; -import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument; -import com.gargoylesoftware.htmlunit.xml.XmlPage; - -/** - * A JavaScript object for DOMImplementation. - * - * @version $Revision$ - * @author Ahmed Ashour - * - * @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-102161490"> - * W3C Dom Level 1</a> - */ -@JsxClass -public class DOMImplementation extends SimpleScriptable { - - /** - * Test if the DOM implementation implements a specific feature. - * @param feature the name of the feature to test (case-insensitive) - * @param version the version number of the feature to test - * @return true if the feature is implemented in the specified version, false otherwise - */ - @JsxFunction - public boolean hasFeature(final String feature, final String version) { - if (getBrowserVersion().hasFeature(GENERATED_35)) { - if ("HTML".equals(feature) && "1.0".equals(version)) { - return true; - } - } - else { - if ("HTML".equals(feature) && ("1.0".equals(version) || "2.0".equals(version))) { - return true; - } - else if ("XML".equals(feature) && ("1.0".equals(version) || "2.0".equals(version))) { - return true; - } - else if ("CSS2".equals(feature) && "2.0".equals(version)) { - return true; - } - else if ("XPath".equals(feature) && "3.0".equals(version)) { - return true; - } - //TODO: other features. - } - return false; - } - - /** - * Creates an {@link XMLDocument}. - * - * @param namespaceURI the URI that identifies an XML namespace - * @param qualifiedName the qualified name of the document to instantiate - * @param doctype the document types of the document - * @return the newly created {@link XMLDocument} - */ - //TODO: change doctype type to "DocType" - @JsxFunction(@WebBrowser(FF)) - public XMLDocument createDocument(final String namespaceURI, final String qualifiedName, - final Object doctype) { - final XMLDocument document = new XMLDocument(getWindow().getWebWindow()); - document.setParentScope(getParentScope()); - document.setPrototype(getPrototype(document.getClass())); - if (qualifiedName != null && !qualifiedName.isEmpty()) { - final XmlPage page = document.getDomNodeOrDie(); - page.appendChild(page.createXmlElementNS(namespaceURI, qualifiedName)); - } - return document; - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParser.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParser.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -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.configuration.WebBrowser; -import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument; - -/** - * A JavaScript object for DOMParser. - * - * @version $Revision$ - * @author Ahmed Ashour - * - * @see <a href="http://www.xulplanet.com/references/objref/DOMParser.html">XUL Planet</a> - */ -@JsxClass(browsers = @WebBrowser(FF)) -public class DOMParser extends SimpleScriptable { - - /** - * JavaScript constructor. - */ - @JsxConstructor - public void jsConstructor() { - // Empty. - } - - /** - * The string passed in is parsed into a DOM document. - * @param str the UTF16 string to be parsed - * @param contentType the content type of the string - - * either <tt>text/xml</tt>, <tt>application/xml</tt>, or <tt>application/xhtml+xml</tt>. Must not be NULL. - * @return the generated document - */ - @JsxFunction - public XMLDocument parseFromString(final String str, final String contentType) { - final XMLDocument document = new XMLDocument(); - document.setParentScope(getParentScope()); - document.setPrototype(getPrototype(XMLDocument.class)); - document.loadXML(str); - return document; - } -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; - -/** - * A JavaScript object for DOMStringMap. - * - * @version $Revision$ - * @author Ahmed Ashour - */ -@JsxClass -public final class DOMStringMap extends SimpleScriptable { - - /** - * Creates an instance. JavaScript objects must have a default constructor. - */ - public DOMStringMap() { - } - - /** - * Creates an instance. - * @param node the node which contains the underlying string - */ - public DOMStringMap(final Node node) { - setDomNode(node.getDomNodeOrDie(), false); - setParentScope(node.getParentScope()); - setPrototype(getPrototype(getClass())); - } - -} Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenList.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenList.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.gargoylesoftware.htmlunit.html.DomAttr; -import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; -import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; - -/** - * A JavaScript object for DOMTokenList. - * - * @version $Revision$ - * @author Ahmed Ashour - */ -@JsxClass -public final class DOMTokenList extends SimpleScriptable { - - private String attributeName_; - - /** - * Creates an instance. JavaScript objects must have a default constructor. - */ - public DOMTokenList() { - } - - /** - * Creates an instance. - * @param node the node which contains the underlying string - * @param attributeName the attribute name of the DomElement of the specified node - */ - public DOMTokenList(final Node node, final String attributeName) { - setDomNode(node.getDomNodeOrDie(), false); - setParentScope(node.getParentScope()); - setPrototype(getPrototype(getClass())); - attributeName_ = attributeName; - } - - /** - * Returns the length property. - * @return the length - */ - @JsxGetter - public int getLength() { - final String value = getDefaultValue(null); - return value.split(" ").length; - } - - /** - * {@inheritDoc} - */ - @Override - public String getDefaultValue(final Class<?> hint) { - final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); - if (attr != null) { - final String value = attr.getValue(); - return value; - } - return ""; - } - - /** - * Adds the specified token to the underlying string. - * @param token the token to add - */ - @JsxFunction - public void add(final String token) { - if (!contains(token)) { - final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); - attr.setValue(attr.getValue() + ' ' + token); - } - } - - /** - * Removes the specified token from the underlying string. - * @param token the token to remove - */ - @JsxFunction - public void remove(final String token) { - if (contains(token)) { - final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); - if (attr != null) { - final List<String> values = new ArrayList<String>(Arrays.asList(attr.getValue().split(" "))); - values.remove(token); - final StringBuilder builder = new StringBuilder(); - for (int i = 0; i < values.size(); i++) { - builder.append(values.get(i)); - if (i < values.size() - 1) { - builder.append(' '); - } - } - attr.setValue(builder.toString()); - } - } - } - - /** - * Toggle the token, by adding or removing. - * @param token the token to add or remove - * @return whether the string now contains the token or not - */ - @JsxFunction - public boolean toggle(final String token) { - if (contains(token)) { - remove(token); - return false; - } - add(token); - return true; - } - - /** - * Checks if the specified token is contained in the underlying string. - * @param token the token to add - * @return true if the underlying string contains token, otherwise false - */ - @JsxFunction - public boolean contains(final String token) { - final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); - if (attr != null) { - final List<String> values = Arrays.asList(attr.getValue().split(" ")); - return values.contains(token); - } - return false; - } - - /** - * Returns the item at the specified index. - * @param index the index of the item - * @return the item - */ - @JsxFunction - public Object item(final int index) { - final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); - if (attr != null) { - final List<String> values = Arrays.asList(attr.getValue().split(" ")); - if (index < values.size()) { - return values.get(index); - } - } - return null; - } -} Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -51,6 +51,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMImplementation; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement; import com.gargoylesoftware.htmlunit.xml.XmlUtil; 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-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -36,6 +36,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; import com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -56,6 +56,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMException; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLHtmlElement; import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLSerializer; import com.gargoylesoftware.htmlunit.xml.XmlPage; Copied: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMException.java (from rev 7691, trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMException.java) =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMException.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMException.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,162 @@ +/* + * Copyright (c) 2002-2012 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.dom; + +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; +import net.sourceforge.htmlunit.corejs.javascript.Context; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; + +/** + * Exception for DOM manipulations. + * + * @see <a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-17189187"> + * DOM-Level-2-Core</a> + * @version $Revision$ + * @author Marc Guillemot + */ +@JsxClass(browsers = @WebBrowser(FF)) +public class DOMException extends SimpleScriptable { + /** If the specified range of text does not fit into a DOMString. */ + @JsxConstant + public static final short DOMSTRING_SIZE_ERR = org.w3c.dom.DOMException.DOMSTRING_SIZE_ERR; + /** If any node is inserted somewhere it doesn't belong. */ + @JsxConstant + public static final short HIERARCHY_REQUEST_ERR = org.w3c.dom.DOMException.HIERARCHY_REQUEST_ERR; + /** If index or size is negative, or greater than the allowed value. */ + @JsxConstant + public static final short INDEX_SIZE_ERR = org.w3c.dom.DOMException.INDEX_SIZE_ERR; + /** If an attempt is made to add an attribute that is already in use elsewhere. */ + @JsxConstant + public static final short INUSE_ATTRIBUTE_ERR = org.w3c.dom.DOMException.INUSE_ATTRIBUTE_ERR; + /** If a parameter or an operation is not supported by the underlying object. */ + @JsxConstant + public static final short INVALID_ACCESS_ERR = org.w3c.dom.DOMException.INVALID_ACCESS_ERR; + /** If an invalid or illegal character is specified, such as in a name. */ + @JsxConstant + public static final short INVALID_CHARACTER_ERR = org.w3c.dom.DOMException.INVALID_CHARACTER_ERR; + /** If an attempt is made to modify the type of the underlying object. */ + @JsxConstant + public static final short INVALID_MODIFICATION_ERR = org.w3c.dom.DOMException.INVALID_MODIFICATION_ERR; + /** If an attempt is made to use an object that is not, or is no longer, usable. */ + @JsxConstant + public static final short INVALID_STATE_ERR = org.w3c.dom.DOMException.INVALID_STATE_ERR; + /** If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. */ + @JsxConstant + public static final short NAMESPACE_ERR = org.w3c.dom.DOMException.NAMESPACE_ERR; + /** If data is specified for a node which does not support data. */ + @JsxConstant + public static final short NO_DATA_ALLOWED_ERR = org.w3c.dom.DOMException.NO_DATA_ALLOWED_ERR; + /** If an attempt is made to modify an object where modifications are not allowed. */ + @JsxConstant + public static final short NO_MODIFICATION_ALLOWED_ERR = org.w3c.dom.DOMException.NO_MODIFICATION_ALLOWED_ERR; + /** If an attempt is made to reference a node in a context where it does not exist. */ + @JsxConstant + public static final short NOT_FOUND_ERR = org.w3c.dom.DOMException.NOT_FOUND_ERR; + /** If the implementation does not support the requested type of object or operation. */ + @JsxConstant + public static final short NOT_SUPPORTED_ERR = org.w3c.dom.DOMException.NOT_SUPPORTED_ERR; + /** If an invalid or illegal string is specified. */ + @JsxConstant + public static final short SYNTAX_ERR = org.w3c.dom.DOMException.SYNTAX_ERR; + /** If a node is used in a different document than the one that created it (that doesn't support it). */ + @JsxConstant + public static final short WRONG_DOCUMENT_ERR = org.w3c.dom.DOMException.WRONG_DOCUMENT_ERR; + + private final short code_; + private final String message_; + private int lineNumber_; + private String fileName_; + + /** + * Default constructor used to build the prototype. + */ + public DOMException() { + code_ = -1; + message_ = null; + } + + /** + * Constructor. + * @param message the exception message + * @param errorCode the error code + */ + public DOMException(final String message, final short errorCode) { + code_ = errorCode; + message_ = message; + } + + /** + * Gets the exception code. + * @return the exception code + */ + @JsxGetter + public Object getCode() { + if (code_ == -1) { + return Context.getUndefinedValue(); + } + return code_; + } + + /** + * Gets the exception message. + * @return the exception message + */ + @JsxGetter + public Object getMessage() { + if (message_ == null) { + return Context.getUndefinedValue(); + } + return message_; + } + + /** + * Gets the line at which the exception occurred. + * @return the line of the exception + */ + @JsxGetter + public Object getLineNumber() { + if (lineNumber_ == -1) { + return Context.getUndefinedValue(); + } + return lineNumber_; + } + + /** + * Gets the name of the in which the exception occurred. + * @return the name of the source file + */ + @JsxGetter + public Object getFilename() { + if (fileName_ == null) { + return Context.getUndefinedValue(); + } + return fileName_; + } + + /** + * Sets the location in JavaScript source where this exception occurred. + * @param fileName the name of the source file + * @param lineNumber the line number + */ + public void setLocation(final String fileName, final int lineNumber) { + fileName_ = fileName; + lineNumber_ = lineNumber; + } +} Copied: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementation.java (from rev 7691, trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementation.java) =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementation.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMImplementation.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2002-2012 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.dom; + +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_35; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument; +import com.gargoylesoftware.htmlunit.xml.XmlPage; + +/** + * A JavaScript object for DOMImplementation. + * + * @version $Revision$ + * @author Ahmed Ashour + * + * @see <a href="http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/level-one-core.html#ID-102161490"> + * W3C Dom Level 1</a> + */ +@JsxClass +public class DOMImplementation extends SimpleScriptable { + + /** + * Test if the DOM implementation implements a specific feature. + * @param feature the name of the feature to test (case-insensitive) + * @param version the version number of the feature to test + * @return true if the feature is implemented in the specified version, false otherwise + */ + @JsxFunction + public boolean hasFeature(final String feature, final String version) { + if (getBrowserVersion().hasFeature(GENERATED_35)) { + if ("HTML".equals(feature) && "1.0".equals(version)) { + return true; + } + } + else { + if ("HTML".equals(feature) && ("1.0".equals(version) || "2.0".equals(version))) { + return true; + } + else if ("XML".equals(feature) && ("1.0".equals(version) || "2.0".equals(version))) { + return true; + } + else if ("CSS2".equals(feature) && "2.0".equals(version)) { + return true; + } + else if ("XPath".equals(feature) && "3.0".equals(version)) { + return true; + } + //TODO: other features. + } + return false; + } + + /** + * Creates an {@link XMLDocument}. + * + * @param namespaceURI the URI that identifies an XML namespace + * @param qualifiedName the qualified name of the document to instantiate + * @param doctype the document types of the document + * @return the newly created {@link XMLDocument} + */ + //TODO: change doctype type to "DocType" + @JsxFunction(@WebBrowser(FF)) + public XMLDocument createDocument(final String namespaceURI, final String qualifiedName, + final Object doctype) { + final XMLDocument document = new XMLDocument(getWindow().getWebWindow()); + document.setParentScope(getParentScope()); + document.setPrototype(getPrototype(document.getClass())); + if (qualifiedName != null && !qualifiedName.isEmpty()) { + final XmlPage page = document.getDomNodeOrDie(); + page.appendChild(page.createXmlElementNS(namespaceURI, qualifiedName)); + } + return document; + } +} Copied: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMParser.java (from rev 7691, trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMParser.java) =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMParser.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMParser.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2002-2012 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.dom; + +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +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.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument; + +/** + * A JavaScript object for DOMParser. + * + * @version $Revision$ + * @author Ahmed Ashour + * + * @see <a href="http://www.xulplanet.com/references/objref/DOMParser.html">XUL Planet</a> + */ +@JsxClass(browsers = @WebBrowser(FF)) +public class DOMParser extends SimpleScriptable { + + /** + * JavaScript constructor. + */ + @JsxConstructor + public void jsConstructor() { + // Empty. + } + + /** + * The string passed in is parsed into a DOM document. + * @param str the UTF16 string to be parsed + * @param contentType the content type of the string - + * either <tt>text/xml</tt>, <tt>application/xml</tt>, or <tt>application/xhtml+xml</tt>. Must not be NULL. + * @return the generated document + */ + @JsxFunction + public XMLDocument parseFromString(final String str, final String contentType) { + final XMLDocument document = new XMLDocument(); + document.setParentScope(getParentScope()); + document.setPrototype(getPrototype(XMLDocument.class)); + document.loadXML(str); + return document; + } +} Copied: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMStringMap.java (from rev 7704, trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java) =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMStringMap.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMStringMap.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2002-2012 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.dom; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.host.Node; + +/** + * A JavaScript object for DOMStringMap. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@JsxClass +public final class DOMStringMap extends SimpleScriptable { + + /** + * Creates an instance. JavaScript objects must have a default constructor. + */ + public DOMStringMap() { + } + + /** + * Creates an instance. + * @param node the node which contains the underlying string + */ + public DOMStringMap(final Node node) { + setDomNode(node.getDomNodeOrDie(), false); + setParentScope(node.getParentScope()); + setPrototype(getPrototype(getClass())); + } + +} Copied: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java (from rev 7691, trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMTokenList.java) =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMTokenList.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,161 @@ +/* + * Copyright (c) 2002-2012 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.dom; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.gargoylesoftware.htmlunit.html.DomAttr; +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.host.Node; + +/** + * A JavaScript object for DOMTokenList. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@JsxClass +public final class DOMTokenList extends SimpleScriptable { + + private String attributeName_; + + /** + * Creates an instance. JavaScript objects must have a default constructor. + */ + public DOMTokenList() { + } + + /** + * Creates an instance. + * @param node the node which contains the underlying string + * @param attributeName the attribute name of the DomElement of the specified node + */ + public DOMTokenList(final Node node, final String attributeName) { + setDomNode(node.getDomNodeOrDie(), false); + setParentScope(node.getParentScope()); + setPrototype(getPrototype(getClass())); + attributeName_ = attributeName; + } + + /** + * Returns the length property. + * @return the length + */ + @JsxGetter + public int getLength() { + final String value = getDefaultValue(null); + return value.split(" ").length; + } + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultValue(final Class<?> hint) { + final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); + if (attr != null) { + final String value = attr.getValue(); + return value; + } + return ""; + } + + /** + * Adds the specified token to the underlying string. + * @param token the token to add + */ + @JsxFunction + public void add(final String token) { + if (!contains(token)) { + final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); + attr.setValue(attr.getValue() + ' ' + token); + } + } + + /** + * Removes the specified token from the underlying string. + * @param token the token to remove + */ + @JsxFunction + public void remove(final String token) { + if (contains(token)) { + final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); + if (attr != null) { + final List<String> values = new ArrayList<String>(Arrays.asList(attr.getValue().split(" "))); + values.remove(token); + final StringBuilder builder = new StringBuilder(); + for (int i = 0; i < values.size(); i++) { + builder.append(values.get(i)); + if (i < values.size() - 1) { + builder.append(' '); + } + } + attr.setValue(builder.toString()); + } + } + } + + /** + * Toggle the token, by adding or removing. + * @param token the token to add or remove + * @return whether the string now contains the token or not + */ + @JsxFunction + public boolean toggle(final String token) { + if (contains(token)) { + remove(token); + return false; + } + add(token); + return true; + } + + /** + * Checks if the specified token is contained in the underlying string. + * @param token the token to add + * @return true if the underlying string contains token, otherwise false + */ + @JsxFunction + public boolean contains(final String token) { + final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); + if (attr != null) { + final List<String> values = Arrays.asList(attr.getValue().split(" ")); + return values.contains(token); + } + return false; + } + + /** + * Returns the item at the specified index. + * @param index the index of the item + * @return the item + */ + @JsxFunction + public Object item(final int index) { + final DomAttr attr = (DomAttr) getDomNodeOrDie().getAttributes().getNamedItem(attributeName_); + if (attr != null) { + final List<String> values = Arrays.asList(attr.getValue().split(" ")); + if (index < values.size()) { + return values.get(index); + } + } + return null; + } +} Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html 2012-11-09 11:12:24 UTC (rev 7705) @@ -0,0 +1,5 @@ +<html><head></head> +<body> +Implementations of the DOM JavaScript host objects - users of HtmlUnit shouldn't +need anything in this package. +</body></html> Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/package.html ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -101,8 +101,6 @@ import com.gargoylesoftware.htmlunit.javascript.host.Attr; import com.gargoylesoftware.htmlunit.javascript.host.BoxObject; import com.gargoylesoftware.htmlunit.javascript.host.ClientRect; -import com.gargoylesoftware.htmlunit.javascript.host.DOMStringMap; -import com.gargoylesoftware.htmlunit.javascript.host.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.Element; import com.gargoylesoftware.htmlunit.javascript.host.Event; import com.gargoylesoftware.htmlunit.javascript.host.EventHandler; @@ -114,6 +112,8 @@ import com.gargoylesoftware.htmlunit.javascript.host.Window; import com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration; import com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMStringMap; +import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList; /** * The JavaScript object "HTMLElement" which is the base class for all HTML Deleted: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMExceptionTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMExceptionTest.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMExceptionTest.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; -import com.gargoylesoftware.htmlunit.WebDriverTestCase; - -/** - * Tests for {@link DOMException}. - * - * @version $Revision$ - * @author Marc Guillemot - */ -@RunWith(BrowserRunner.class) -public class DOMExceptionTest extends WebDriverTestCase { - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(FF = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15" }, - IE = "exception") - public void constants() throws Exception { - final String html = "<html><head>\n" - + "<script>\n" - + " var properties = ['INDEX_SIZE_ERR', 'DOMSTRING_SIZE_ERR', 'HIERARCHY_REQUEST_ERR'," - + " 'WRONG_DOCUMENT_ERR', 'INVALID_CHARACTER_ERR', 'NO_DATA_ALLOWED_ERR', 'NO_MODIFICATION_ALLOWED_ERR'," - + " 'NOT_FOUND_ERR', 'NOT_SUPPORTED_ERR', 'INUSE_ATTRIBUTE_ERR', 'INVALID_STATE_ERR', 'SYNTAX_ERR'," - + " 'INVALID_MODIFICATION_ERR', 'NAMESPACE_ERR', 'INVALID_ACCESS_ERR'];\n" - + " try {\n" - + " for (var i=0; i<properties.length; ++i) {\n" - + " alert(DOMException[properties[i]]);\n" - + " }\n" - + " } catch(e) { alert('exception');}\n" - + "</script></head>\n" - + "<body></body></html>"; - - loadPageWithAlerts2(html); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(FF = { "undefined", "undefined", "undefined", "undefined" }, - IE = "exception") - public void properties() throws Exception { - final String html = "<html><head>\n" - + "<script>\n" - + " try {\n" - + " alert(DOMException.code);\n" - + " alert(DOMException.filename);\n" - + " alert(DOMException.lineNumber);\n" - + " alert(DOMException.message);\n" - + " } catch(e) { alert('exception');}\n" - + "</script></head>\n" - + "<body></body></html>"; - - loadPageWithAlerts2(html); - } - - /** - * Test exception throw by an illegal DOM appendChild. - * @throws Exception if the test fails - */ - @Test - @Alerts(FF = { "3", "Node cannot be inserted at the specified point in the hierarchy", - "6", "§§URL§§", "HIERARCHY_REQUEST_ERR: 3", "1" }, - IE = { "1" }) - public void appendChild_illegal_node() throws Exception { - final String html = "<html><head><title>foo</title><script>\n" - + "function test() {\n" - + " var htmlNode = document.documentElement;\n" - + " var body = document.body;\n" - + " try {\n" - + " body.appendChild(htmlNode);\n" - + " } catch(e) {\n" - + " alert(e.code);\n" - + " alert(e.message);\n" - + " alert(e.lineNumber);\n" - + " alert(e.filename);\n" - + " alert('HIERARCHY_REQUEST_ERR: ' + e.HIERARCHY_REQUEST_ERR);\n" - + " };\n" - + " alert(body.childNodes.length);\n" - + "}\n" - + "</script></head><body onload='test()'><span>hi</span></body></html>"; - - loadPageWithAlerts2(html); - } -} Deleted: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementationTest.java 2012-11-09 11:07:39 UTC (rev 7704) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/DOMImplementationTest.java 2012-11-09 11:12:24 UTC (rev 7705) @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2002-2012 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; - -import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF; - -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.Browsers; -import com.gargoylesoftware.htmlunit.SimpleWebTestCase; - -/** - * Tests for {@link DOMImplementation}. - * - * @version $Revision$ - * @author Ahmed Ashour - * @author Marc Guillemot - */ -@RunWith(BrowserRunner.class) -public class DOMImplementationTest extends SimpleWebTestCase { - - /** - * @throws Exception if the test fails - */ - @Test - @Alerts(FF = { "HTML 1.0: true", "HTML 2.0: true", "HTML 3.0: false" }, - IE = { "HTML 1.0: true", "HTML 2.0: false", "HTML 3.0: false" }) - public void hasFeatu... [truncated message content] |