From: <rb...@us...> - 2013-11-02 19:13:51
|
Revision: 8724 http://sourceforge.net/p/htmlunit/code/8724 Author: rbri Date: 2013-11-02 19:13:46 +0000 (Sat, 02 Nov 2013) Log Message: ----------- add ie10 support (wip) [patch from frank danek] Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Event.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/KeyboardEvent.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/MouseEvent.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/UIEvent.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGAltGlyphElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGAnimateElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGAnimateMotionElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGAnimateTransformElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGForeignObjectElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGMpathElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGSetElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/svg/SvgElementFactory.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EnumeratorTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/EventTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/KeyboardEventTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/MouseEventTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/MutationEventTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Node2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Selection2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/TreeWalkerTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclarationTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLImageElementTest.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGViewElement.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -156,6 +156,22 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) EVENT_DOM_CONTENT_LOADED, + /** Supports DOM level 2 events. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) + EVENT_DOM_LEVEL_2, + + /** Supports DOM level 3 events. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) + EVENT_DOM_LEVEL_3, + + /** Supports vendor specific event type 'Events'. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) + EVENT_TYPE_EVENTS, + + /** Supports vendor specific event type 'KeyEvents'. */ + @BrowserFeature({ @WebBrowser(FF) }) + EVENT_TYPE_KEY_EVENTS, + /** Is setting 'focus' and 'blur' events of 'document', triggers the event for the descendants elements. */ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) EVENT_FOCUS_DOCUMENT_DESCENDANTS, @@ -224,8 +240,12 @@ @BrowserFeature(@WebBrowser(value = IE, maxVersion = 8)) FILEINPUT_EMPTY_DEFAULT_VALUE, + /** For new pages the focus points to the body node. */ + @BrowserFeature(@WebBrowser(value = IE, minVersion = 10)) + FOCUS_BODY_ELEMENT_AT_START, + /** For new pages the focus points to the html root node. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) FOCUS_HTML_ELEMENT_AT_START, /** Indicates if a form field is directly reachable by its new name once this has been changed. */ @@ -260,11 +280,7 @@ GENERATED_112, /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) - GENERATED_113, - - /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) GENERATED_116, /** Was originally .isIE(). */ @@ -320,10 +336,6 @@ GENERATED_21, /** Was originally .isIE(). */ - @BrowserFeature(@WebBrowser(IE)) - GENERATED_3, - - /** Was originally .isIE(). */ @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) GENERATED_37, @@ -598,6 +610,10 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) HTMLTEXTAREA_SET_DEFAULT_VALUE_UPDATES_VALUE, + /** Adds CData nodes as Comment elements to the DOM. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) + HTML_CDATA_AS_COMMENT, + /** Expand shorthand to 6-digit hex color codes. */ @BrowserFeature({ @WebBrowser(value = IE, maxVersion = 8) }) HTML_COLOR_EXPAND_SHORT_HEX, @@ -651,7 +667,7 @@ /** Top scope constants can be assign (and are not... constants). */ - @BrowserFeature({ @WebBrowser(value = FF, maxVersion = 3.6f), @WebBrowser(IE) }) + @BrowserFeature({ @WebBrowser(value = FF, maxVersion = 3.6f), @WebBrowser(value = IE, maxVersion = 9) }) JS_ALLOW_CONST_ASSIGNMENT, /** @@ -663,7 +679,7 @@ /** Indicates that the appendChild call create a DocumentFragment to be * the parentNode's parentNode if this was null. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_APPEND_CHILD_CREATE_DOCUMENT_FRAGMENT_PARENT, /** Indicates that the appendChild call throws no exception @@ -732,7 +748,7 @@ JS_CLIENT_LEFT_TOP_ZERO, /** Indicates that the cloneNode call copies all event listeners. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_CLONE_NODE_COPIES_EVENT_LISTENERS, /** Indicates that "constructor" property is defined, e.g. <tt>document.constructor</tt>. */ @@ -784,6 +800,10 @@ @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_DOCUMENT_APPEND_CHILD_SUPPORTED, + /** Document instead of HTMLDocument. */ + @BrowserFeature(@WebBrowser(value = IE, minVersion = 10)) + JS_DOCUMENT_CLASS_NAME, + /** Javascript function document.createElement can process html code. * e.g. document.createElement("<INPUT TYPE='RADIO' NAME='RADIOTEST' VALUE='First Choice'>") * @see "http://msdn.microsoft.com/en-us/library/ms536389%28v=VS.85%29.aspx" @@ -831,7 +851,7 @@ JS_ELEMENT_EXTENT_WITHOUT_PADDING, /** Indicates that 'exception' (technically NativeError) exposes "stack" property. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) JS_ERROR_STACK, /** Indicates that "eval" function should have access to the local function scope. */ @@ -851,9 +871,13 @@ JS_EVENT_HANDLER_AS_PROPERTY_DONT_RECEIVE_EVENT, /** Javascript event.keyCode returns undefined instead of zero if the keyCode is not set. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_EVENT_KEY_CODE_UNDEFINED, + /** Javascript event.keyCode and event.charCode distinguish between printable and not printable keys. */ + @BrowserFeature(@WebBrowser(FF)) + JS_EVENT_DISTINGUISH_PRINTABLE_KEY, + /** Do not send parameter in event handlers. */ @BrowserFeature(@WebBrowser(IE)) JS_EVENT_NO_PARAMETER, @@ -880,7 +904,8 @@ JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW, /** Indicates if Function.bind is available. */ - @BrowserFeature({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME), + @WebBrowser(value = IE, minVersion = 10) }) JS_FUNCTION_BIND, /** @@ -1001,7 +1026,7 @@ * for url 'http://localhost/something/#%C3%BC'.<br> * IE evaluates to #%C3%BC. */ - @BrowserFeature({ @WebBrowser(value = IE, minVersion = 8), @WebBrowser(FF), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(value = IE, minVersion = 8, maxVersion = 9), @WebBrowser(FF), @WebBrowser(CHROME) }) JS_LOCATION_HASH_IS_DECODED, /** @@ -1134,9 +1159,13 @@ /** When addressing an item in a stylesheet list, IE throws an exception for all * invalid indexes not only for negative ones like FF does. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_STYLESHEET_LIST_EXEPTION_FOR_ALL_INVALID_INDEXES, + /** Indicates if style.getAttribute supports a (second) flags argument. */ + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) + JS_STYLE_GET_ATTRIBUTE_SUPPORTS_FLAGS, + /** IE supports accessing unsupported style elements via getter * like val = elem.style.htmlunit;. */ @@ -1232,12 +1261,12 @@ @BrowserFeature({ @WebBrowser(IE) }) JS_WINDOW_FRAMES_ACCESSIBLE_BY_ID, - /** Window property not usable as function. */ - @BrowserFeature(@WebBrowser(IE)) - JS_WINDOW_IS_NOT_A_FUNCTION, + /** Window property usable as function. */ + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) + JS_WINDOW_IS_A_FUNCTION, /** Window.postMessage is synchronouse. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 9)) JS_WINDOW_POST_MESSAGE_SYNCHRONOUSE, /** Supports XML. */ @@ -1311,8 +1340,8 @@ @BrowserFeature(@WebBrowser(IE)) RESETINPUT_DEFAULT_VALUE_IF_VALUE_NOT_DEFINED, - /** Indicates that escaping in attrubute selectors is supported. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) + /** Indicates that escaping in attribute selectors is supported. */ + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) SELECTOR_ATTRIBUTE_ESCAPING, /** @@ -1336,14 +1365,21 @@ STORAGE_OBSOLETE, /** Indicates that string.trim() is supported. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) STRING_TRIM, /** Indicates that string.trimLeft() and .trimRight() are supported. */ - @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 9), @WebBrowser(CHROME) }) + @BrowserFeature({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 9, maxVersion = 9), @WebBrowser(CHROME) }) STRING_TRIM_LEFT_RIGHT, /** + * Indicates that the href property for a <link rel="stylesheet" type="text/css" href="" /> + * (href empty) is null. + */ + @BrowserFeature(@WebBrowser(value = IE, minVersion = 10)) + STYLESHEET_HREF_EMPTY_IS_NULL, + + /** * Indicates that the href property for a <link rel="stylesheet" type="text/css" href="..." /> * is the fully qualified URL. */ @@ -1366,6 +1402,10 @@ @BrowserFeature({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) SVG, + /** Indicates that unknown tags inside an SVG element are handled as DOM elements, not SVG elements. */ + @BrowserFeature(@WebBrowser(value = IE, minVersion = 10)) + SVG_UNKNOWN_ARE_DOM, + /** Throws an exception if the value for column span is less than one. */ @BrowserFeature(@WebBrowser(IE)) TABLE_COLUMN_SPAN_THROWS_EXCEPTION_IF_LESS_THAN_ONE, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DefaultElementFactory.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -43,6 +43,7 @@ * @author Ahmed Ashour * @author David K. Taylor * @author Ronald Brill + * @author Frank Danek */ class DefaultElementFactory implements ElementFactory { @@ -71,7 +72,7 @@ HtmlHeading6.TAG_NAME, HtmlHead.TAG_NAME, HtmlHorizontalRule.TAG_NAME, HtmlHtml.TAG_NAME, HtmlInlineFrame.TAG_NAME, HtmlInlineQuotation.TAG_NAME, - HtmlImage.TAG_NAME, HtmlInsertedText.TAG_NAME, HtmlIsIndex.TAG_NAME, + HtmlImage.TAG_NAME, HtmlImage.TAG_NAME2, HtmlInsertedText.TAG_NAME, HtmlIsIndex.TAG_NAME, HtmlItalic.TAG_NAME, HtmlKeyboard.TAG_NAME, HtmlLabel.TAG_NAME, HtmlLegend.TAG_NAME, HtmlListing.TAG_NAME, HtmlListItem.TAG_NAME, HtmlLink.TAG_NAME, HtmlMap.TAG_NAME, HtmlMarquee.TAG_NAME, @@ -308,7 +309,7 @@ else if (tagName.equals(HtmlHtml.TAG_NAME)) { element = new HtmlHtml(namespaceURI, qualifiedName, page, attributeMap); } - else if (tagName.equals(HtmlImage.TAG_NAME)) { + else if (tagName.equals(HtmlImage.TAG_NAME) || tagName.equals(HtmlImage.TAG_NAME2)) { element = new HtmlImage(namespaceURI, qualifiedName, page, attributeMap); } else if (tagName.equals(HtmlInlineFrame.TAG_NAME)) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.DOCTYPE_IS_COMMENT; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_3; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTML_CDATA_AS_COMMENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLCONDITIONAL_COMMENTS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLIFRAME_IGNORE_SELFCLOSING; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLPARSER_REMOVE_EMPTY_CONTENT; @@ -89,6 +89,7 @@ * @author Ethan Glasser-Camp * @author Sudhan Moghe * @author Ronald Brill + * @author Frank Danek */ public final class HTMLParser { @@ -814,7 +815,7 @@ handleCharacters(); final String data = new String(ch, start, length); if (!data.startsWith("[CDATA") - || !page_.hasFeature(GENERATED_3)) { + || page_.hasFeature(HTML_CDATA_AS_COMMENT)) { final DomComment comment = new DomComment(page_, data); currentNode_.appendChild(comment); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlImage.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -47,6 +47,7 @@ * @author Ahmed Ashour * @author <a href="mailto:knu...@gm...">Knut Johannes Dahle</a> * @author Ronald Brill + * @author Frank Danek */ public class HtmlImage extends HtmlElement { @@ -54,6 +55,8 @@ /** The HTML tag represented by this element. */ public static final String TAG_NAME = "img"; + /** Another HTML tag represented by this element. */ + public static final String TAG_NAME2 = "image"; private int lastClickX_; private int lastClickY_; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -18,6 +18,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_DOM_CONTENT_LOADED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONLOAD_FRAMESET_FIRST; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONLOAD_IFRAME_CREATED_BY_JAVASCRIPT; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FOCUS_BODY_ELEMENT_AT_START; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.FOCUS_HTML_ELEMENT_AT_START; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DEFERRED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_FRAME_RESOLVE_URL_WITH_PARENT_WINDOW; @@ -238,6 +239,9 @@ if (browserVersion.hasFeature(FOCUS_HTML_ELEMENT_AT_START)) { elementWithFocus_ = getDocumentElement(); } + else if (browserVersion.hasFeature(FOCUS_BODY_ELEMENT_AT_START)) { + elementWithFocus_ = getBody(); + } setReadyState(READY_STATE_COMPLETE); getDocumentElement().setReadyState(READY_STATE_COMPLETE); } 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-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -268,6 +268,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.svg.SVGTextPathElement; import com.gargoylesoftware.htmlunit.javascript.host.svg.SVGTitleElement; import com.gargoylesoftware.htmlunit.javascript.host.svg.SVGUseElement; +import com.gargoylesoftware.htmlunit.javascript.host.svg.SVGViewElement; import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLAttr; import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDOMParseError; import com.gargoylesoftware.htmlunit.javascript.host.xml.XMLDocument; @@ -282,6 +283,7 @@ * @author Chris Erskine * @author Ahmed Ashour * @author Ronald Brill + * @author Frank Danek */ public final class JavaScriptConfiguration { @@ -356,7 +358,8 @@ SVGSVGElement.class, SVGScriptElement.class, SVGSetElement.class, SVGStopElement.class, SVGStyleElement.class, SVGSwitchElement.class, SVGSymbolElement.class, SVGTSpanElement.class, SVGTextElement.class, SVGTextPathElement.class, - SVGTitleElement.class, SVGUseElement.class, Screen.class, Selection.class, SimpleArray.class, + SVGTitleElement.class, SVGUseElement.class, SVGViewElement.class, + Screen.class, Selection.class, SimpleArray.class, StaticNodeList.class, Storage.class, StyleSheetList.class, Text.class, TextRange.class, TreeWalker.class, UIEvent.class, Uint16Array.class, Uint32Array.class, Uint8Array.class, Uint8ClampedArray.class, WebSocket.class, Window.class, XMLAttr.class, XMLDocument.class, XMLDOMParseError.class, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Event.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Event.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Event.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -129,16 +129,20 @@ /** The message event type, triggered by postMessage. */ public static final String TYPE_MESSAGE = "message"; + /** No event phase. */ + @JsxConstant(@WebBrowser(FF)) + public static final short NONE = 0; + /** The first event phase: the capturing phase. */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short CAPTURING_PHASE = 1; /** The second event phase: at the event target. */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short AT_TARGET = 2; /** The third (and final) event phase: the bubbling phase. */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short BUBBLING_PHASE = 3; /** Constant. */ @@ -147,10 +151,6 @@ /** Constant. */ @JsxConstant(@WebBrowser(FF)) - public static final int ALT_MASK = 0x1; - - /** Constant. */ - @JsxConstant(@WebBrowser(FF)) public static final int BACK = 0x20000000; /** Constant. */ @@ -167,10 +167,6 @@ /** Constant. */ @JsxConstant(@WebBrowser(FF)) - public static final int CONTROL_MASK = 0x2; - - /** Constant. */ - @JsxConstant(@WebBrowser(FF)) public static final int DBLCLICK = 0x80; /** Constant. */ @@ -215,10 +211,6 @@ /** Constant. */ @JsxConstant(@WebBrowser(FF)) - public static final int META_MASK = 0x8; - - /** Constant. */ - @JsxConstant(@WebBrowser(FF)) public static final int MOUSEDOWN = 0x1; /** Constant. */ @@ -263,10 +255,6 @@ /** Constant. */ @JsxConstant(@WebBrowser(FF)) - public static final int SHIFT_MASK = 0x4; - - /** Constant. */ - @JsxConstant(@WebBrowser(FF)) public static final int SUBMIT = 0x20000; /** Constant. */ @@ -281,6 +269,22 @@ @JsxConstant(@WebBrowser(FF)) public static final int XFER_DONE = 0x200000; + /** Constant. */ + @JsxConstant(@WebBrowser(FF)) + public static final int ALT_MASK = 0x1; + + /** Constant. */ + @JsxConstant(@WebBrowser(FF)) + public static final int CONTROL_MASK = 0x2; + + /** Constant. */ + @JsxConstant(@WebBrowser(FF)) + public static final int SHIFT_MASK = 0x4; + + /** Constant. */ + @JsxConstant(@WebBrowser(FF)) + public static final int META_MASK = 0x8; + private Object srcElement_; // IE-only writable equivalent of target. private Object target_; // W3C standard read-only equivalent of srcElement. private Object currentTarget_; // Changes during event capturing and bubbling. @@ -295,7 +299,7 @@ private boolean preventDefault_; /** - * The current event phase. This is a W3C standard attribute not implemented by IE. One of + * The current event phase. This is a W3C standard attribute. One of {@link #NONE}, * {@link #CAPTURING_PHASE}, {@link #AT_TARGET} or {@link #BUBBLING_PHASE}. */ private short eventPhase_; @@ -485,7 +489,7 @@ * Returns the key code associated with the event. * @return the key code associated with the event */ - @JsxGetter(@WebBrowser(IE)) + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public Object getKeyCode() { if (keyCode_ == null) { if (getBrowserVersion().hasFeature(JS_EVENT_KEY_CODE_UNDEFINED)) { @@ -499,7 +503,7 @@ /** * @return whether SHIFT has been pressed during this event or not */ - @JsxGetter(@WebBrowser(IE)) + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public boolean getShiftKey() { return shiftKey_; } @@ -514,7 +518,7 @@ /** * @return whether CTRL has been pressed during this event or not */ - @JsxGetter(@WebBrowser(IE)) + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public boolean getCtrlKey() { return ctrlKey_; } @@ -529,7 +533,7 @@ /** * @return whether ALT has been pressed during this event or not */ - @JsxGetter(@WebBrowser(IE)) + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public boolean getAltKey() { return altKey_; } @@ -544,7 +548,7 @@ /** * @return the current event phase for the event */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public int getEventPhase() { return eventPhase_; } @@ -579,9 +583,19 @@ } /** + * Returns <tt>true</tt> if both <tt>cancelable</tt> is <tt>true</tt> and <tt>preventDefault()</tt> has been + * called for this event. Otherwise this attribute must return <tt>false</tt>. + * @return <tt>true</tt> if this event has been cancelled or not + */ + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) + public boolean isDefaultPrevented() { + return cancelable_ && preventDefault_; + } + + /** * @return indicates if event propagation is stopped */ - @JsxGetter + @JsxGetter(@WebBrowser(IE)) public boolean getCancelBubble() { return stopPropagation_; } @@ -589,7 +603,7 @@ /** * @param newValue indicates if event propagation is stopped */ - @JsxSetter + @JsxSetter(@WebBrowser(IE)) public void setCancelBubble(final boolean newValue) { stopPropagation_ = newValue; } @@ -597,7 +611,7 @@ /** * Stops the event from propagating. */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public void stopPropagation() { stopPropagation_ = true; } @@ -614,30 +628,30 @@ * Returns the return value associated with the event. * @return the return value associated with the event */ - @JsxGetter + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public Object getReturnValue() { return returnValue_; } /** + * Sets the return value associated with the event. + * @param returnValue the return value associated with the event + */ + @JsxSetter(@WebBrowser(value = IE, maxVersion = 9)) + public void setReturnValue(final Object returnValue) { + returnValue_ = returnValue; + } + + /** * Returns the property name associated with the event. * @return the property name associated with the event */ - @JsxGetter(@WebBrowser(IE)) + @JsxGetter(@WebBrowser(value = IE, maxVersion = 9)) public String getPropertyName() { return propertyName_; } /** - * Sets the return value associated with the event. - * @param returnValue the return value associated with the event - */ - @JsxSetter - public void setReturnValue(final Object returnValue) { - returnValue_ = returnValue; - } - - /** * Initializes this event. * @param type the event type * @param bubbles whether or not the event should bubble Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/KeyboardEvent.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/KeyboardEvent.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/KeyboardEvent.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -14,7 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_113; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_EVENT_DISTINGUISH_PRINTABLE_KEY; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; @@ -522,24 +522,26 @@ final boolean shiftKey, final boolean ctrlKey, final boolean altKey) { super(domNode, type); int keyCode = 0; - if (getBrowserVersion().hasFeature(GENERATED_113)) { - if (getType().equals(Event.TYPE_KEY_PRESS)) { - keyCode = Integer.valueOf(character); - setKeyCode(keyCode); + + if (!getType().equals(Event.TYPE_KEY_PRESS)) { + keyCode = Integer.valueOf(charToKeyCode(character)); + } + else { + if (getBrowserVersion().hasFeature(JS_EVENT_DISTINGUISH_PRINTABLE_KEY)) { + if (character < 32 || character > 126) { + keyCode = Integer.valueOf(charToKeyCode(character)); + } } else { - keyCode = Integer.valueOf(charToKeyCode(character)); - setKeyCode(keyCode); + keyCode = Integer.valueOf(character); } } - else { - if (getType().equals(Event.TYPE_KEY_PRESS) && character >= 33 && character <= 126) { + setKeyCode(keyCode); + if (getType().equals(Event.TYPE_KEY_PRESS)) { + if ((character >= 33 && character <= 126) + || !getBrowserVersion().hasFeature(JS_EVENT_DISTINGUISH_PRINTABLE_KEY)) { charCode_ = character; } - else { - keyCode = Integer.valueOf(charToKeyCode(character)); - setKeyCode(keyCode); - } } setShiftKey(shiftKey); setCtrlKey(ctrlKey); @@ -621,7 +623,7 @@ * Returns the char code associated with the event. * @return the char code associated with the event */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public int getCharCode() { return charCode_; } @@ -665,7 +667,7 @@ * {@inheritDoc} Overridden to modify browser configurations. */ @Override - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public Object getKeyCode() { return super.getKeyCode(); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/MouseEvent.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/MouseEvent.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/MouseEvent.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -22,6 +22,7 @@ import java.util.LinkedList; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.Undefined; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; @@ -361,7 +362,7 @@ * {@inheritDoc} Overridden to modify browser configurations. */ @Override - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public boolean getAltKey() { return super.getAltKey(); } @@ -370,7 +371,7 @@ * {@inheritDoc} Overridden to modify browser configurations. */ @Override - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public boolean getCtrlKey() { return super.getCtrlKey(); } @@ -379,8 +380,16 @@ * {@inheritDoc} Overridden to modify browser configurations. */ @Override - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public boolean getShiftKey() { return super.getShiftKey(); } + + /** + * {@inheritDoc} Overridden to modify browser configurations. + */ + @Override + public Object getKeyCode() { + return Undefined.instance; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -36,6 +36,7 @@ * @author Chris Erskine * @author Ahmed Ashour * @author Marc Guillemot + * @author Frank Danek * * @see <a href="http://msdn.microsoft.com/en-us/library/ms535867.aspx">MSDN documentation</a> */ @@ -258,7 +259,7 @@ * Returns the geolocation. * @return the geolocation */ - @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public Geolocation getGeolocation() { final Geolocation geolocation = new Geolocation(); geolocation.setPrototype(getPrototype(geolocation.getClass())); 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 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Node.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -88,75 +88,75 @@ private EventListenersContainer eventListenersContainer_; /** @see org.w3c.dom.Node#ELEMENT_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short ELEMENT_NODE = org.w3c.dom.Node.ELEMENT_NODE; /** @see org.w3c.dom.Node#ATTRIBUTE_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short ATTRIBUTE_NODE = org.w3c.dom.Node.ATTRIBUTE_NODE; /** @see org.w3c.dom.Node#TEXT_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short TEXT_NODE = org.w3c.dom.Node.TEXT_NODE; /** @see org.w3c.dom.Node#CDATA_SECTION_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short CDATA_SECTION_NODE = org.w3c.dom.Node.CDATA_SECTION_NODE; /** @see org.w3c.dom.Node#ENTITY_REFERENCE_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short ENTITY_REFERENCE_NODE = org.w3c.dom.Node.ENTITY_REFERENCE_NODE; /** @see org.w3c.dom.Node#ENTITY_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short ENTITY_NODE = org.w3c.dom.Node.ENTITY_NODE; /** @see org.w3c.dom.Node#PROCESSING_INSTRUCTION_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short PROCESSING_INSTRUCTION_NODE = org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE; /** @see org.w3c.dom.Node#COMMENT_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short COMMENT_NODE = org.w3c.dom.Node.COMMENT_NODE; /** @see org.w3c.dom.Node#DOCUMENT_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_NODE = org.w3c.dom.Node.DOCUMENT_NODE; /** @see org.w3c.dom.Node#DOCUMENT_TYPE_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_TYPE_NODE = org.w3c.dom.Node.DOCUMENT_TYPE_NODE; /** @see org.w3c.dom.Node#DOCUMENT_FRAGMENT_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_FRAGMENT_NODE = org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE; /** @see org.w3c.dom.Node#NOTATION_NODE */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short NOTATION_NODE = org.w3c.dom.Node.NOTATION_NODE; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_DISCONNECTED */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_DISCONNECTED = org.w3c.dom.Node.DOCUMENT_POSITION_DISCONNECTED; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_PRECEDING */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_PRECEDING = org.w3c.dom.Node.DOCUMENT_POSITION_PRECEDING; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_FOLLOWING */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_FOLLOWING = org.w3c.dom.Node.DOCUMENT_POSITION_FOLLOWING; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_CONTAINS */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_CONTAINS = org.w3c.dom.Node.DOCUMENT_POSITION_CONTAINS; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_CONTAINED_BY */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_CONTAINED_BY = org.w3c.dom.Node.DOCUMENT_POSITION_CONTAINED_BY; /** @see org.w3c.dom.Node#DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC */ - @JsxConstant(@WebBrowser(FF)) + @JsxConstant({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = org.w3c.dom.Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC; @@ -447,7 +447,7 @@ * * @return whether this node is the same node as the given one */ - @JsxFunction(@WebBrowser(value = FF, maxVersion = 3.6f)) + @JsxFunction({ @WebBrowser(value = FF, maxVersion = 3.6f), @WebBrowser(value = IE, minVersion = 10) }) public boolean isSameNode(final Object other) { return other == this; } @@ -711,7 +711,7 @@ * @see <a href="https://developer.mozilla.org/en-US/docs/DOM/element.removeEventListener">Mozilla * documentation</a> */ - @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public void removeEventListener(final String type, final Function listener, final boolean useCapture) { getEventListenersContainer().removeEventListener(type, listener, useCapture); } @@ -964,7 +964,7 @@ * @see <a href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-compareDocumentPosition">DOM level 3</a> * @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node) */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public short compareDocumentPosition(final Object node) { if (!(node instanceof Node)) { throw Context.reportRuntimeError("Could not convert JavaScript argument arg 0"); @@ -1016,7 +1016,7 @@ * Replace all children elements of this element with the supplied value. * @param value - the new value for the contents of this node */ - @JsxSetter(@WebBrowser(FF)) + @JsxSetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public void setTextContent(final Object value) { getDomNodeOrDie().setTextContent(value == null ? null : Context.toString(value)); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/UIEvent.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/UIEvent.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/UIEvent.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; @@ -30,6 +31,7 @@ * @version $Revision$ * @author Daniel Gredler * @author Ahmed Ashour + * @author Frank Danek */ @JsxClass public class UIEvent extends Event { @@ -73,7 +75,7 @@ * * @return some detail information about the event, depending on the event type */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public long getDetail() { return detail_; } @@ -92,7 +94,7 @@ * * @return the view from which the event was generated */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public Object getView() { return getWindow(); } @@ -106,7 +108,7 @@ * @param view the view to use for this event * @param detail the detail to set for the event */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public void initUIEvent( final String type, final boolean bubbles, @@ -122,7 +124,7 @@ * Returns whether or not the "meta" key was pressed during the event firing. * @return whether or not the "meta" key was pressed during the event firing */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public boolean getMetaKey() { return metaKey_; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -19,7 +19,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_HANDLER_UNDEFINED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_CHANGE_OPENER_NOT_ALLOWED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_FRAMES_ACCESSIBLE_BY_ID; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_IS_NOT_A_FUNCTION; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_IS_A_FUNCTION; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_WINDOW_POST_MESSAGE_SYNCHRONOUSE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SUPPORT_VIA_ACTIVEXOBJECT; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; @@ -228,7 +228,7 @@ * @param stringToEncode string to encode * @return the encoded string */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public String btoa(final String stringToEncode) { return new String(Base64.encodeBase64(stringToEncode.getBytes())); } @@ -238,7 +238,7 @@ * @param encodedData the encoded string * @return the decoded value */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public String atob(final String encodedData) { return new String(Base64.decodeBase64(encodedData.getBytes())); } @@ -295,7 +295,7 @@ * Returns the application cache. * @return the application cache */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public OfflineResourceList getApplicationCache() { return applicationCache_; } @@ -629,7 +629,7 @@ * Prints messages to the console. * @param message the message to log */ - @JsxFunction(@WebBrowser(FF)) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public void dump(final String message) { if (console_ instanceof Console) { Console.log(null, console_, new Object[] {message}, null); @@ -1267,7 +1267,7 @@ * {@inheritDoc} */ public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { - if (!getBrowserVersion().hasFeature(JS_WINDOW_IS_NOT_A_FUNCTION)) { + if (!getBrowserVersion().hasFeature(JS_WINDOW_IS_A_FUNCTION)) { throw Context.reportRuntimeError("Window is not a function."); } if (args.length > 0) { @@ -1286,7 +1286,7 @@ * {@inheritDoc} */ public Scriptable construct(final Context cx, final Scriptable scope, final Object[] args) { - if (!getBrowserVersion().hasFeature(JS_WINDOW_IS_NOT_A_FUNCTION)) { + if (!getBrowserVersion().hasFeature(JS_WINDOW_IS_A_FUNCTION)) { throw Context.reportRuntimeError("Window is not a function."); } return null; @@ -1909,7 +1909,7 @@ * Returns the value of "pageXOffset" property. * @return the value of "pageXOffset" property */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public int getPageXOffset() { return 0; } @@ -1918,7 +1918,7 @@ * Returns the value of "pageYOffset" property. * @return the value of "pageYOffset" property */ - @JsxGetter(@WebBrowser(FF)) + @JsxGetter({ @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 10) }) public int getPageYOffset() { return 0; } @@ -2017,7 +2017,7 @@ * @return <tt>false</tt> if at least one of the event handlers which handled the event * called <tt>preventDefault</tt>; <tt>true</tt> otherwise */ - @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public boolean dispatchEvent(final Event event) { event.setTarget(this); final ScriptResult result = Node.fireEvent(this, event); @@ -2028,7 +2028,8 @@ * Getter for the onchange event handler. * @return the handler */ - @JsxGetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + @JsxGetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME), + @WebBrowser(value = IE, minVersion = 10) }) public Object getOnchange() { return getHandlerForJavaScript(Event.TYPE_CHANGE); } @@ -2037,7 +2038,8 @@ * Setter for the onchange event handler. * @param onchange the handler */ - @JsxSetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + @JsxSetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME), + @WebBrowser(value = IE, minVersion = 10) }) public void setOnchange(final Object onchange) { setHandlerForJavaScript(Event.TYPE_CHANGE, onchange); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -23,6 +23,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CSS_ZINDEX_UNDEFINED_OR_NULL_THROWS_ERROR; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_GET_BACKGROUND_COLOR_FOR_COMPUTED_STYLE_AS_RGB; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_OPACITY_ACCEPTS_ARBITRARY_VALUES; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_STYLE_GET_ATTRIBUTE_SUPPORTS_FLAGS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_STYLE_UNSUPPORTED_PROPERTY_GETTER; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; @@ -4040,7 +4041,7 @@ */ @JsxFunction(@WebBrowser(IE)) public Object getAttribute(final String name, final int flag) { - if (flag == 1) { + if (getBrowserVersion().hasFeature(JS_STYLE_GET_ATTRIBUTE_SUPPORTS_FLAGS) && flag == 1) { // Case-sensitive. return getStyleAttribute(name); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -17,6 +17,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.CSS_SELECTOR_LANG; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.QUERYSELECTORALL_NOT_IN_QUIRKS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.SELECTOR_ATTRIBUTE_ESCAPING; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.STYLESHEET_HREF_EMPTY_IS_NULL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.STYLESHEET_HREF_EXPANDURL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.STYLESHEET_HREF_STYLE_EMPTY; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.STYLESHEET_HREF_STYLE_NULL; @@ -947,6 +948,9 @@ final HtmlLink link = (HtmlLink) node; final HtmlPage page = (HtmlPage) link.getPage(); final String href = link.getHrefAttribute(); + if ("".equals(href) && version.hasFeature(STYLESHEET_HREF_EMPTY_IS_NULL)) { + return null; + } if (!version.hasFeature(STYLESHEET_HREF_EXPANDURL)) { // Don't expand relative URLs. return href; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-11-02 12:11:17 UTC (rev 8723) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-11-02 19:13:46 UTC (rev 8724) @@ -15,6 +15,10 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.DOCTYPE_4_0_TRANSITIONAL_STANDARDS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_DOM_LEVEL_2; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_DOM_LEVEL_3; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_EVENTS; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_KEY_EVENTS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EXECCOMMAND_THROWS_ON_WRONG_COMMAND; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_160; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.GENERATED_161; @@ -28,6 +32,7 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_COLOR; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHORS_REQUIRES_NAME_OR_ID; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_APPEND_CHILD_SUPPORTED; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_CLASS_NAME; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_CREATE_ELEMENT_EXTENDED_SYNTAX; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_DOCTYPE_NULL; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DOCUMENT_DOMAIN_IS_LOWERCASE; @@ -180,7 +185,12 @@ * the static initializer. The map is unmodifiable. Any class that is a value in this map MUST * have a no-arg constructor. */ - private static final Map<String, Class<? extends Event>> SUPPORTED_EVENT_TYPE_MAP; + /** Contains all supported DOM level 2 events. */ + private static final Map<String, Class<? extends Event>> SUPPORTED_DOM2_EVENT_TYPE_MAP; + /** Contains all supported DOM level 3 events. DOM level 2 events are not included. */ + private static final Map<String, Class<? extends Event>> SUPPORTED_DOM3_EVENT_TYPE_MAP; + /** Contains all supported vendor specific events. */ + private static final Map<String, Class<? extends Event>> SUPPORTED_VENDOR_EVENT_TYPE_MAP; // all as lowercase for performance private static final Set<String> EXECUTE_CMDS_IE = new HashSet<String>(); @@ -217,20 +227,26 @@ /** Initializes the supported event type map. */ static { - final Map<String, Class<? extends Event>> eventMap = new HashMap<String, Class<? extends Event>>(); - eventMap.put("Event", Event.class); - eventMap.put("Events", Event.class); - eventMap.put("KeyboardEvent", KeyboardEvent.class); - eventMap.put("KeyEvents", KeyboardEvent.class); - eventMap.put("HTMLEvents", Event.class); - eventMap.put("MouseEvent", MouseEvent.class); - eventMap.put("MouseEvents", MouseEvent.class); - eventMap.put("MutationEvent", MutationEvent.class); - eventMap.put("MutationEvents", MutationEvent.class); - eventMap.put("UIEvent", UIEvent.class); - eventMap.put("UIEvents", UIEvent.class); - SUPPORTED_EVENT_TYPE_MAP = Collections.unmodifiableMap(eventMap); + final Map<String, Class<? extends Event>> dom2EventMap = new HashMap<String, Class<? extends Event>>(); + dom2EventMap.put("HTMLEvents", Event.class); + dom2EventMap.put("MouseEvents", MouseEvent.class); + dom2EventMap.put("MutationEvents", MutationEvent.class); + dom2EventMap.put("UIEvents", UIEvent.class); + SUPPORTED_DOM2_EVENT_TYPE_MAP = Collections.unmodifiableMap(dom2EventMap); + final Map<String, Class<? extends Event>> dom3EventMap = new HashMap<String, Class<? extends Event>>(); + dom3EventMap.put("Event", Event.class); + dom3EventMap.put("KeyboardEvent", KeyboardEvent.class); + dom3EventMap.put("MouseEvent", MouseEvent.class); + dom3EventMap.put("MutationEvent", MutationEvent.class); + dom3EventMap.put("UIEvent", UIEvent.class); + SUPPORTED_DOM3_EVENT_TYPE_MAP = Collections.unmodifiableMap(dom3EventMap); + + final Map<String, Class<? extends Event>> additionalEventMap = new HashMap<String, Class<? extends Event>>(); + additionalEventMap.put("Events", Event.class); + additionalEventMap.put("KeyEvents", KeyboardEvent.class); + SUPPORTED_VENDOR_EVENT_TYPE_MAP = Collections.unmodifiableMap(additionalEventMap); + // commands List<String> cmds = Arrays.asList( "2D-Position", "AbsolutePosition", "BackColor", "BackgroundImageCache" /* Undocumented */, @@ -274,6 +290,19 @@ * {@inheritDoc} */ @Override + public String getClassName() { + if (getWindow().getWebWindow() != null) { + if (getBrowserVersion().hasFeature(JS_DOCUMENT_CLASS_NAME)) { + return "Document"; + } + } + return super.getClassName(); + } + + /** + * {@inheritDoc} + */ + @Override @SuppressWarnings("unchecked") public <N extends DomNode> N getDomNodeOrDie() throws IllegalStateException { try { @@ -1809,8 +1838,20 @@ */ @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public Event createEvent(final String eventType) throws DOMException { - final Class<? extends Event> clazz = SUPPORTED_EVENT_TYPE_MAP.get(eventType); + Class<? extends Event> clazz = null; + if (getBrowserVersion().hasFeature(EVENT_DOM_LEVEL_2)) { + clazz = SUPPORTED_DOM2_EVENT_TYPE_MAP.get(eventType); + } + if (clazz == null && getBrowserVersion().hasFeature(EVENT_DOM_LEVEL_3)) { + clazz = SUPPORTED_DOM3_EVENT_TYPE_MAP.get(eventType); + } if (clazz == null) { + if ("Events".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_EVENTS) + || "KeyEvents".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_KEY_EVENTS)) { + clazz = SUPPORTED_VENDOR_EVENT_TYPE_MAP.get(eventType); + } + } + if (clazz == null) { Context.throwAsScriptRuntimeEx(new DOMException(DOMException.NOT_SUPPORTED_ERR, "Event Type is not supported: " + eventType)); return null; // to stop eclipse warning @@ -1899,7 +1940,7 @@ * @throws DOMException on attempt to create a TreeWalker with a root that is <code>null</code> * @return a new TreeWalker */ - @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME) }) + @JsxFunction({ @WebBrowser(FF), @WebBrowser(CHROME), @WebBrowser(value = IE, minVersion = 10) }) public Object createTreeWalker(final Node root, final double whatToShow, final Scriptable filter, boolean expandEntityReferences) throws DOM... [truncated message content] |