From: <rb...@us...> - 2018-06-29 09:33:13
|
Revision: 15407 http://sourceforge.net/p/htmlunit/code/15407 Author: rbri Date: 2018-06-29 09:33:09 +0000 (Fri, 29 Jun 2018) Log Message: ----------- ff60 support (wip) Modified Paths: -------------- 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/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEvent.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEventTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-06-29 08:40:51 UTC (rev 15406) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2018-06-29 09:33:09 UTC (rev 15407) @@ -230,6 +230,10 @@ @BrowserFeature(IE) EVENT_ONMOUSEUP_NOT_FOR_SELECT_OPTION, + /** <code>PopStateEvent</code> can not be created by calling document.createEvent('PopStateEvent'). */ + @BrowserFeature(FF60) + EVENT_ONPOPSTATE_DOCUMENT_CREATE_NOT_SUPPORTED, + /** Supports event type 'BeforeUnloadEvent'. */ @BrowserFeature({CHROME, FF}) EVENT_TYPE_BEFOREUNLOADEVENT, 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-06-29 08:40:51 UTC (rev 15406) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2018-06-29 09:33:09 UTC (rev 15407) @@ -15,6 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.host.dom; 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_HASHCHANGEEVENT; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.EVENT_TYPE_KEY_EVENTS; @@ -1208,6 +1209,11 @@ || "ProgressEvent".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_PROGRESSEVENT))) { clazz = SUPPORTED_VENDOR_EVENT_TYPE_MAP.get(eventType); + + if (PopStateEvent.class == clazz + && getBrowserVersion().hasFeature(EVENT_ONPOPSTATE_DOCUMENT_CREATE_NOT_SUPPORTED)) { + clazz = null; + } } if (clazz == null) { Context.throwAsScriptRuntimeEx(new DOMException(DOMException.NOT_SUPPORTED_ERR, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEvent.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEvent.java 2018-06-29 08:40:51 UTC (rev 15406) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEvent.java 2018-06-29 09:33:09 UTC (rev 15407) @@ -18,9 +18,11 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE; import 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.JsxGetter; import net.sourceforge.htmlunit.corejs.javascript.Context; @@ -92,6 +94,20 @@ } /** + * Initializes this event. + * @param type the event type + * @param bubbles whether or not the event should bubble + * @param cancelable whether or not the event the event should be cancelable + * @param state the state + */ + @JsxFunction(IE) + public void initPopStateEvent(final String type, final boolean bubbles, + final boolean cancelable, final Object state) { + initEvent(type, bubbles, cancelable); + state_ = state; + } + + /** * Return the state object. * @return the state object */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEventTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEventTest.java 2018-06-29 08:40:51 UTC (rev 15406) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/PopStateEventTest.java 2018-06-29 09:33:09 UTC (rev 15407) @@ -100,7 +100,8 @@ * @throws Exception if the test fails */ @Test - @Alerts({"[object PopStateEvent]", "null", "", "false", "false", "null"}) + @Alerts(DEFAULT = {"[object PopStateEvent]", "null", "", "false", "false", "null"}, + FF60 = "exception") public void create_createEvent() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>foo</title><script>\n" @@ -121,7 +122,8 @@ * @throws Exception if the test fails */ @Test - @Alerts({"[object PopStateEvent]", "null", "", "false", "false", "null"}) + @Alerts(DEFAULT = {"[object PopStateEvent]", "null", "", "false", "false", "null"}, + FF60 = "exception") public void setState() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>foo</title><script>\n" @@ -143,8 +145,8 @@ * @throws Exception if the test fails */ @Test - @Alerts("exception") - @NotYetImplemented({IE, CHROME, FF52}) + @Alerts(DEFAULT = "dispatched", + FF60 = "exception ctor") public void dispatchEvent() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + "<html><head><title>foo</title><script>\n" @@ -151,8 +153,42 @@ + " function test() {\n" + " try {\n" + " var event = document.createEvent('PopStateEvent');\n" + + " event.initEvent('', true, true);\n" + + " } catch (e) { alert('exception ctor'); return; }\n" + + + " try {\n" + " dispatchEvent(event);\n" + " alert('dispatched');\n" + + " } catch (e) { alert('exception' + e) }\n" + + " }\n" + + DUMP_EVENT_FUNCTION + + " try {\n" + + " window.addEventListener('popstate',dump);\n" + + " } catch (e) { }\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "exception", + FF60 = "exception ctor") + @NotYetImplemented({CHROME, FF52, IE}) + public void dispatchEventWithoutInit() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " try {\n" + + " var event = document.createEvent('PopStateEvent');\n" + + " } catch (e) { alert('exception ctor') }\n" + + + " try {\n" + + " dispatchEvent(event);\n" + + " alert('dispatched');\n" + " } catch (e) { alert('exception') }\n" + " }\n" + DUMP_EVENT_FUNCTION @@ -164,4 +200,33 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no initPopStateEvent", + FF60 = "exception ctor", + IE = {"[object PopStateEvent]", "null", "PopState", "true", "false", "html"}) + public void initPopStateEvent() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " try {\n" + + " var event = document.createEvent('PopStateEvent');\n" + + " } catch (e) { alert('exception ctor') }\n" + + + " try {\n" + + " if (event.initPopStateEvent) {\n" + + " event.initPopStateEvent('PopState', true, false, 'html');\n" + + " dump(event);\n" + + " } else { alert('no initPopStateEvent'); }\n" + + " } catch (e) { alert('exception') }\n" + + " }\n" + + DUMP_EVENT_FUNCTION + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |