From: <rb...@us...> - 2018-07-09 18:01:47
|
Revision: 15448 http://sourceforge.net/p/htmlunit/code/15448 Author: rbri Date: 2018-07-09 18:01:08 +0000 (Mon, 09 Jul 2018) Log Message: ----------- many fixes for document.createEvent('xxx') to support the various UI events Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2018-07-09 16:45:18 UTC (rev 15447) +++ trunk/htmlunit/src/changes/changes.xml 2018-07-09 18:01:08 UTC (rev 15448) @@ -14,6 +14,9 @@ <action type="remove" dev="rbri"> FF45 support removed. </action> + <action type="fix" dev="rbri"> + Many fixes for document.createEvent('xxx') to support the various UI events. + </action> <action type="fix" dev="rbri" issue="1966" due-to="Atsushi Nakagawa"> Correct handling of additional parameters provided in functions setTimeout/setInterval. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-07-09 16:45:18 UTC (rev 15447) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-07-09 18:01:08 UTC (rev 15448) @@ -238,6 +238,10 @@ @BrowserFeature({CHROME, FF}) EVENT_TYPE_BEFOREUNLOADEVENT, + /** Supports event type 'FocusEvent'. */ + @BrowserFeature({CHROME, FF60, IE}) + EVENT_TYPE_FOCUSEVENT, + /** Supports event type 'HashChangeEvent'. */ @BrowserFeature({CHROME, FF}) EVENT_TYPE_HASHCHANGEEVENT, @@ -258,6 +262,14 @@ @BrowserFeature(IE) EVENT_TYPE_PROGRESSEVENT, + /** Supports event type 'SVGZoomEvent'. */ + @BrowserFeature(FF52) + EVENT_TYPE_SVGZOOMEVENT, + + /** Supports event type 'WheelEvent'. */ + @BrowserFeature({CHROME, IE}) + EVENT_TYPE_WHEELEVENT, + /** For new pages the focus points to the body node. */ @BrowserFeature(IE) FOCUS_BODY_ELEMENT_AT_START, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2018-07-09 16:45:18 UTC (rev 15447) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2018-07-09 18:01:08 UTC (rev 15448) @@ -17,11 +17,14 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONCLOSE_DOCUMENT_CREATE_NOT_SUPPORTED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_ONPOPSTATE_DOCUMENT_CREATE_NOT_SUPPORTED; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_BEFOREUNLOADEVENT; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_FOCUSEVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_HASHCHANGEEVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_KEY_EVENTS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_MOUSEWHEELEVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_POINTEREVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_PROGRESSEVENT; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_SVGZOOMEVENT; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_WHEELEVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_APPLETS_NODELIST; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.HTMLDOCUMENT_CHARSET_LOWERCASE; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHORS_REQUIRES_NAME_OR_ID; @@ -128,7 +131,10 @@ import com.gargoylesoftware.htmlunit.javascript.host.event.PointerEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.PopStateEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.ProgressEvent; +import com.gargoylesoftware.htmlunit.javascript.host.event.SVGZoomEvent; +import com.gargoylesoftware.htmlunit.javascript.host.event.TextEvent; import com.gargoylesoftware.htmlunit.javascript.host.event.UIEvent; +import com.gargoylesoftware.htmlunit.javascript.host.event.WheelEvent; import com.gargoylesoftware.htmlunit.javascript.host.html.DocumentProxy; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLAnchorElement; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection; @@ -212,8 +218,8 @@ dom3EventMap.put("CustomEvent", CustomEvent.class); dom3EventMap.put("CloseEvent", CloseEvent.class); dom3EventMap.put("CompositionEvent", CompositionEvent.class); - dom3EventMap.put("FocusEvent", FocusEvent.class); dom3EventMap.put("DragEvent", DragEvent.class); + dom3EventMap.put("TextEvent", TextEvent.class); SUPPORTED_DOM3_EVENT_TYPE_MAP = Collections.unmodifiableMap(dom3EventMap); final Map<String, Class<? extends Event>> additionalEventMap = new HashMap<>(); @@ -225,6 +231,9 @@ additionalEventMap.put("PopStateEvent", PopStateEvent.class); additionalEventMap.put("ProgressEvent", ProgressEvent.class); additionalEventMap.put("MouseWheelEvent", MouseWheelEvent.class); + additionalEventMap.put("FocusEvent", FocusEvent.class); + additionalEventMap.put("WheelEvent", WheelEvent.class); + additionalEventMap.put("SVGZoomEvent", SVGZoomEvent.class); SUPPORTED_VENDOR_EVENT_TYPE_MAP = Collections.unmodifiableMap(additionalEventMap); } @@ -1218,7 +1227,13 @@ && getBrowserVersion().hasFeature(EVENT_TYPE_POINTEREVENT) || "PopStateEvent".equals(eventType) || "ProgressEvent".equals(eventType) - && getBrowserVersion().hasFeature(EVENT_TYPE_PROGRESSEVENT))) { + && getBrowserVersion().hasFeature(EVENT_TYPE_PROGRESSEVENT) + || "FocusEvent".equals(eventType) + && getBrowserVersion().hasFeature(EVENT_TYPE_FOCUSEVENT) + || "SVGZoomEvent".equals(eventType) + && getBrowserVersion().hasFeature(EVENT_TYPE_SVGZOOMEVENT) + || "WheelEvent".equals(eventType) + && getBrowserVersion().hasFeature(EVENT_TYPE_WHEELEVENT))) { clazz = SUPPORTED_VENDOR_EVENT_TYPE_MAP.get(eventType); if (PopStateEvent.class == clazz Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2018-07-09 16:45:18 UTC (rev 15447) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2018-07-09 18:01:08 UTC (rev 15448) @@ -320,23 +320,34 @@ html.append("<tr>").append('\n').append("<td rowspan='2'>").append("<a name='" + name + "'>").append(name) .append("</a>").append("</td>").append('\n').append("<td>"); int implementedCount = 0; - for (int i = 0; i < realProperties.size(); i++) { - final String color; - if (implementedProperties.contains(realProperties.get(i))) { - color = "green"; - implementedCount++; - } - else { - color = "blue"; - } - html.append("<span style='color: " + color + "'>").append(realProperties.get(i)).append("</span>"); - if (i < realProperties.size() - 1) { - html.append(',').append(' '); - } - } + if (realProperties.isEmpty()) { html.append(" "); } + else if (realProperties.size() == 1 + && realProperties.contains("exception") + && implementedProperties.size() == 1 + && implementedProperties.contains("exception") + && erroredProperties.size() == 0) { + html.append(" "); + } + else { + for (int i = 0; i < realProperties.size(); i++) { + final String color; + if (implementedProperties.contains(realProperties.get(i))) { + color = "green"; + implementedCount++; + } + else { + color = "blue"; + } + html.append("<span style='color: " + color + "'>").append(realProperties.get(i)).append("</span>"); + if (i < realProperties.size() - 1) { + html.append(',').append(' '); + } + } + } + html.append("</td>").append("<td>").append(implementedCount).append('/') .append(realProperties.size()).append("</td>").append("</tr>").append('\n'); html.append("<tr>").append("<td>"); @@ -3142,7 +3153,7 @@ FF52 = "exception", FF60 = "relatedTarget", IE = "initFocusEvent(),relatedTarget") - @NotYetImplemented + @NotYetImplemented({CHROME, FF60, IE}) public void focusEvent() throws Exception { testString("document.createEvent('FocusEvent'), document.createEvent('UIEvent')"); } |