From: <asa...@us...> - 2017-08-11 08:48:18
|
Revision: 14785 http://sourceforge.net/p/htmlunit/code/14785 Author: asashour Date: 2017-08-11 08:48:15 +0000 (Fri, 11 Aug 2017) Log Message: ----------- use Event constants Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window2.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/EventNode2.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument2.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement2.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGElement.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -25,6 +25,7 @@ import org.apache.commons.lang3.StringUtils; import com.gargoylesoftware.htmlunit.SgmlPage; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import com.gargoylesoftware.htmlunit.util.KeyDataPair; import com.gargoylesoftware.htmlunit.util.NameValuePair; @@ -162,7 +163,7 @@ files[i] = normalizeFile(files[i]); } files_ = files; - fireEvent("change"); + fireEvent(Event.TYPE_CHANGE); } /** 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 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -1102,7 +1102,7 @@ */ @JsxGetter public Object getOnload() { - final Object onload = getEventHandler("load"); + final Object onload = getEventHandler(Event.TYPE_LOAD); if (onload == null) { final HtmlPage page = (HtmlPage) getWebWindow().getEnclosedPage(); final HtmlElement body = page.getBody(); @@ -2311,7 +2311,7 @@ */ @JsxGetter(IE) public Function getOnfocusin() { - return getEventHandler("focusin"); + return getEventHandler(Event.TYPE_FOCUS_IN); } /** @@ -2320,7 +2320,7 @@ */ @JsxSetter(IE) public void setOnfocusin(final Object onfocusin) { - setHandlerForJavaScript("focusin", onfocusin); + setHandlerForJavaScript(Event.TYPE_FOCUS_IN, onfocusin); } /** @@ -2329,7 +2329,7 @@ */ @JsxGetter public Function getOnfocus() { - return getEventHandler("focus"); + return getEventHandler(Event.TYPE_FOCUS); } /** @@ -2338,7 +2338,7 @@ */ @JsxSetter public void setOnfocus(final Object onfocus) { - setHandlerForJavaScript("focus", onfocus); + setHandlerForJavaScript(Event.TYPE_FOCUS, onfocus); } /** @@ -2563,7 +2563,7 @@ */ @JsxGetter public Function getOnkeydown() { - return getEventHandler("keydown"); + return getEventHandler(Event.TYPE_KEY_DOWN); } /** @@ -2572,7 +2572,7 @@ */ @JsxSetter public void setOnkeydown(final Object onkeydown) { - setHandlerForJavaScript("keydown", onkeydown); + setHandlerForJavaScript(Event.TYPE_KEY_DOWN, onkeydown); } /** @@ -2635,7 +2635,7 @@ */ @JsxGetter public Function getOnkeyup() { - return getEventHandler("keyup"); + return getEventHandler(Event.TYPE_KEY_UP); } /** @@ -2644,7 +2644,7 @@ */ @JsxSetter public void setOnkeyup(final Object onkeyup) { - setHandlerForJavaScript("keyup", onkeyup); + setHandlerForJavaScript(Event.TYPE_KEY_UP, onkeyup); } /** @@ -2689,7 +2689,7 @@ */ @JsxGetter public Function getOnreset() { - return getEventHandler("reset"); + return getEventHandler(Event.TYPE_RESET); } /** @@ -2698,7 +2698,7 @@ */ @JsxSetter public void setOnreset(final Object onreset) { - setHandlerForJavaScript("reset", onreset); + setHandlerForJavaScript(Event.TYPE_RESET, onreset); } /** @@ -2707,7 +2707,7 @@ */ @JsxGetter public Function getOnkeypress() { - return getEventHandler("keypress"); + return getEventHandler(Event.TYPE_KEY_PRESS); } /** @@ -2716,7 +2716,7 @@ */ @JsxSetter public void setOnkeypress(final Object onkeypress) { - setHandlerForJavaScript("keypress", onkeypress); + setHandlerForJavaScript(Event.TYPE_KEY_PRESS, onkeypress); } /** @@ -2743,7 +2743,7 @@ */ @JsxGetter(IE) public Function getOnfocusout() { - return getEventHandler("focusout"); + return getEventHandler(Event.TYPE_FOCUS_OUT); } /** @@ -2752,7 +2752,7 @@ */ @JsxSetter(IE) public void setOnfocusout(final Object onfocusout) { - setHandlerForJavaScript("focusout", onfocusout); + setHandlerForJavaScript(Event.TYPE_FOCUS_OUT, onfocusout); } /** @@ -2851,7 +2851,7 @@ */ @JsxGetter public Function getOncontextmenu() { - return getEventHandler("contextmenu"); + return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } /** @@ -2860,7 +2860,7 @@ */ @JsxSetter public void setOncontextmenu(final Object oncontextmenu) { - setHandlerForJavaScript("contextmenu", oncontextmenu); + setHandlerForJavaScript(MouseEvent.TYPE_CONTEXT_MENU, oncontextmenu); } /** @@ -2869,7 +2869,7 @@ */ @JsxGetter public Function getOnmousemove() { - return getEventHandler("mousemove"); + return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } /** @@ -2878,7 +2878,7 @@ */ @JsxSetter public void setOnmousemove(final Object onmousemove) { - setHandlerForJavaScript("mousemove", onmousemove); + setHandlerForJavaScript(MouseEvent.TYPE_MOUSE_MOVE, onmousemove); } /** @@ -2887,7 +2887,7 @@ */ @JsxGetter(IE) public Function getOnreadystatechange() { - return getEventHandler("readystatechange"); + return getEventHandler(Event.TYPE_READY_STATE_CHANGE); } /** @@ -2896,7 +2896,7 @@ */ @JsxSetter(IE) public void setOnreadystatechange(final Object onreadystatechange) { - setHandlerForJavaScript("readystatechange", onreadystatechange); + setHandlerForJavaScript(Event.TYPE_READY_STATE_CHANGE, onreadystatechange); } /** @@ -2959,7 +2959,7 @@ */ @JsxGetter public Function getOnmouseover() { - return getEventHandler("mouseover"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } /** @@ -2968,7 +2968,7 @@ */ @JsxSetter public void setOnmouseover(final Object onmouseover) { - setHandlerForJavaScript("mouseover", onmouseover); + setHandlerForJavaScript(MouseEvent.TYPE_MOUSE_OVER, onmouseover); } /** @@ -3031,7 +3031,7 @@ */ @JsxGetter(CHROME) public Function getOnclose() { - return getEventHandler("close"); + return getEventHandler(Event.TYPE_CLOSE); } /** @@ -3040,7 +3040,7 @@ */ @JsxSetter(CHROME) public void setOnclose(final Object onclose) { - setHandlerForJavaScript("close", onclose); + setHandlerForJavaScript(Event.TYPE_CLOSE, onclose); } /** @@ -3337,7 +3337,7 @@ */ @JsxGetter public Function getOnmouseout() { - return getEventHandler("mouseout"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } /** @@ -3346,7 +3346,7 @@ */ @JsxSetter public void setOnmouseout(final Object onmouseout) { - setHandlerForJavaScript("mouseout", onmouseout); + setHandlerForJavaScript(MouseEvent.TYPE_MOUSE_OUT, onmouseout); } /** @@ -3409,7 +3409,7 @@ */ @JsxGetter public Function getOnmousedown() { - return getEventHandler("mousedown"); + return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } /** @@ -3418,7 +3418,7 @@ */ @JsxSetter public void setOnmousedown(final Object onmousedown) { - setHandlerForJavaScript("mousedown", onmousedown); + setHandlerForJavaScript(MouseEvent.TYPE_MOUSE_DOWN, onmousedown); } /** @@ -3877,7 +3877,7 @@ */ @JsxGetter public Function getOnmouseup() { - return getEventHandler("mouseup"); + return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } /** @@ -3886,7 +3886,7 @@ */ @JsxSetter public void setOnmouseup(final Object onmouseup) { - setHandlerForJavaScript("mouseup", onmouseup); + setHandlerForJavaScript(MouseEvent.TYPE_MOUSE_UP, onmouseup); } /** @@ -3985,7 +3985,7 @@ */ @JsxGetter public Function getOninput() { - return getEventHandler("input"); + return getEventHandler(Event.TYPE_INPUT); } /** @@ -3994,7 +3994,7 @@ */ @JsxSetter public void setOninput(final Object oninput) { - setHandlerForJavaScript("input", oninput); + setHandlerForJavaScript(Event.TYPE_INPUT, oninput); } /** @@ -4165,7 +4165,7 @@ */ @JsxGetter public Function getOnunload() { - return getEventHandler("unload"); + return getEventHandler(Event.TYPE_UNLOAD); } /** @@ -4174,7 +4174,7 @@ */ @JsxSetter public void setOnunload(final Object onunload) { - setHandlerForJavaScript("unload", onunload); + setHandlerForJavaScript(Event.TYPE_UNLOAD, onunload); } /** @@ -4345,7 +4345,7 @@ */ @JsxGetter public Function getOnpopstate() { - return getEventHandler("popstate"); + return getEventHandler(Event.TYPE_POPSTATE); } /** @@ -4354,7 +4354,7 @@ */ @JsxSetter public void setOnpopstate(final Object onpopstate) { - setHandlerForJavaScript("popstate", onpopstate); + setHandlerForJavaScript(Event.TYPE_POPSTATE, onpopstate); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window2.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window2.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window2.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -353,7 +353,7 @@ @Getter public static Object getOnload(final Object self) { final Window2 window = getWindow(self); - final Object onload = window.getHandlerForJavaScript("load"); + final Object onload = window.getHandlerForJavaScript(Event2.TYPE_LOAD); if (onload == null) { final HtmlPage page = (HtmlPage) window.getWebWindow().getEnclosedPage(); final HtmlElement body = page.getBody(); 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 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Document.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -1425,7 +1425,7 @@ */ @JsxSetter public void setOnclick(final Object handler) { - setEventHandler("click", handler); + setEventHandler(MouseEvent.TYPE_CLICK, handler); } /** @@ -1434,7 +1434,7 @@ */ @JsxGetter public Object getOnclick() { - return getEventHandler("click"); + return getEventHandler(MouseEvent.TYPE_CLICK); } /** @@ -1443,7 +1443,7 @@ */ @JsxSetter public void setOndblclick(final Object handler) { - setEventHandler("dblclick", handler); + setEventHandler(MouseEvent.TYPE_DBL_CLICK, handler); } /** @@ -1452,7 +1452,7 @@ */ @JsxGetter public Object getOndblclick() { - return getEventHandler("dblclick"); + return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } /** @@ -1461,7 +1461,7 @@ */ @JsxSetter public void setOnblur(final Object handler) { - setEventHandler("blur", handler); + setEventHandler(Event.TYPE_BLUR, handler); } /** @@ -1470,7 +1470,7 @@ */ @JsxGetter public Object getOnblur() { - return getEventHandler("blur"); + return getEventHandler(Event.TYPE_BLUR); } /** @@ -1479,7 +1479,7 @@ */ @JsxSetter public void setOnfocus(final Object handler) { - setEventHandler("focus", handler); + setEventHandler(Event.TYPE_FOCUS, handler); } /** @@ -1488,7 +1488,7 @@ */ @JsxGetter public Object getOnfocus() { - return getEventHandler("focus"); + return getEventHandler(Event.TYPE_FOCUS); } /** @@ -1497,7 +1497,7 @@ */ @JsxSetter(IE) public void setOnfocusin(final Object handler) { - setEventHandler("focusin", handler); + setEventHandler(Event.TYPE_FOCUS_IN, handler); } /** @@ -1506,7 +1506,7 @@ */ @JsxGetter(IE) public Object getOnfocusin() { - return getEventHandler("focusin"); + return getEventHandler(Event.TYPE_FOCUS_IN); } /** @@ -1515,7 +1515,7 @@ */ @JsxSetter(IE) public void setOnfocusout(final Object handler) { - setEventHandler("focusout", handler); + setEventHandler(Event.TYPE_FOCUS_OUT, handler); } /** @@ -1524,7 +1524,7 @@ */ @JsxGetter(IE) public Object getOnfocusout() { - return getEventHandler("focusout"); + return getEventHandler(Event.TYPE_FOCUS_OUT); } /** @@ -1533,7 +1533,7 @@ */ @JsxSetter public void setOnkeydown(final Object handler) { - setEventHandler("keydown", handler); + setEventHandler(Event.TYPE_KEY_DOWN, handler); } /** @@ -1542,7 +1542,7 @@ */ @JsxGetter public Object getOnkeydown() { - return getEventHandler("keydown"); + return getEventHandler(Event.TYPE_KEY_DOWN); } /** @@ -1551,7 +1551,7 @@ */ @JsxSetter public void setOnkeypress(final Object handler) { - setEventHandler("keypress", handler); + setEventHandler(Event.TYPE_KEY_PRESS, handler); } /** @@ -1560,7 +1560,7 @@ */ @JsxGetter public Object getOnkeypress() { - return getEventHandler("keypress"); + return getEventHandler(Event.TYPE_KEY_PRESS); } /** @@ -1569,7 +1569,7 @@ */ @JsxSetter public void setOnkeyup(final Object handler) { - setEventHandler("keyup", handler); + setEventHandler(Event.TYPE_KEY_UP, handler); } /** @@ -1578,7 +1578,7 @@ */ @JsxGetter public Object getOnkeyup() { - return getEventHandler("keyup"); + return getEventHandler(Event.TYPE_KEY_UP); } /** @@ -1587,7 +1587,7 @@ */ @JsxSetter public void setOnmousedown(final Object handler) { - setEventHandler("mousedown", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_DOWN, handler); } /** @@ -1596,7 +1596,7 @@ */ @JsxGetter public Object getOnmousedown() { - return getEventHandler("mousedown"); + return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } /** @@ -1605,7 +1605,7 @@ */ @JsxSetter public void setOnmousemove(final Object handler) { - setEventHandler("mousemove", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_MOVE, handler); } /** @@ -1614,7 +1614,7 @@ */ @JsxGetter public Object getOnmousemove() { - return getEventHandler("mousemove"); + return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } /** @@ -1623,7 +1623,7 @@ */ @JsxSetter public void setOnmouseout(final Object handler) { - setEventHandler("mouseout", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_OUT, handler); } /** @@ -1632,7 +1632,7 @@ */ @JsxGetter public Object getOnmouseout() { - return getEventHandler("mouseout"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } /** @@ -1641,7 +1641,7 @@ */ @JsxSetter public void setOnmouseover(final Object handler) { - setEventHandler("mouseover", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_OVER, handler); } /** @@ -1650,7 +1650,7 @@ */ @JsxGetter public Object getOnmouseover() { - return getEventHandler("mouseover"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } /** @@ -1659,7 +1659,7 @@ */ @JsxSetter public void setOnmouseup(final Object handler) { - setEventHandler("mouseup", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_UP, handler); } /** @@ -1668,7 +1668,7 @@ */ @JsxGetter public Object getOnmouseup() { - return getEventHandler("mouseup"); + return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } /** @@ -1677,7 +1677,7 @@ */ @JsxSetter public void setOncontextmenu(final Object handler) { - setEventHandler("contextmenu", handler); + setEventHandler(MouseEvent.TYPE_CONTEXT_MENU, handler); } /** @@ -1686,7 +1686,7 @@ */ @JsxGetter public Object getOncontextmenu() { - return getEventHandler("contextmenu"); + return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } /** @@ -1713,7 +1713,7 @@ */ @JsxSetter public void setOnerror(final Object handler) { - setEventHandler("error", handler); + setEventHandler(Event.TYPE_ERROR, handler); } /** @@ -1722,7 +1722,7 @@ */ @JsxGetter public Object getOnerror() { - return getEventHandler("error"); + return getEventHandler(Event.TYPE_ERROR); } /** @@ -1731,7 +1731,7 @@ */ @JsxGetter public Function getOninput() { - return getEventHandler("input"); + return getEventHandler(Event.TYPE_INPUT); } /** @@ -1740,7 +1740,7 @@ */ @JsxSetter public void setOninput(final Object oninput) { - setEventHandler("input", oninput); + setEventHandler(Event.TYPE_INPUT, oninput); } /** @@ -2399,7 +2399,7 @@ */ @JsxGetter public Function getOnchange() { - return getEventHandler("change"); + return getEventHandler(Event.TYPE_CHANGE); } /** @@ -2408,7 +2408,7 @@ */ @JsxSetter public void setOnchange(final Object onchange) { - setEventHandler("change", onchange); + setEventHandler(Event.TYPE_CHANGE, onchange); } /** @@ -2417,7 +2417,7 @@ */ @JsxGetter(CHROME) public Function getOnclose() { - return getEventHandler("close"); + return getEventHandler(Event.TYPE_CLOSE); } /** @@ -2426,7 +2426,7 @@ */ @JsxSetter(CHROME) public void setOnclose(final Object onclose) { - setEventHandler("close", onclose); + setEventHandler(Event.TYPE_CLOSE, onclose); } /** @@ -2705,7 +2705,7 @@ */ @JsxGetter public Function getOnload() { - return getEventHandler("load"); + return getEventHandler(Event.TYPE_LOAD); } /** @@ -2714,7 +2714,7 @@ */ @JsxSetter public void setOnload(final Object onload) { - setEventHandler("load", onload); + setEventHandler(Event.TYPE_LOAD, onload); } /** @@ -3137,7 +3137,7 @@ */ @JsxGetter public Function getOnreadystatechange() { - return getEventHandler("readystatechange"); + return getEventHandler(Event.TYPE_READY_STATE_CHANGE); } /** @@ -3146,7 +3146,7 @@ */ @JsxSetter public void setOnreadystatechange(final Object onreadystatechange) { - setEventHandler("readystatechange", onreadystatechange); + setEventHandler(Event.TYPE_READY_STATE_CHANGE, onreadystatechange); } /** @@ -3155,7 +3155,7 @@ */ @JsxGetter public Function getOnreset() { - return getEventHandler("reset"); + return getEventHandler(Event.TYPE_RESET); } /** @@ -3164,7 +3164,7 @@ */ @JsxSetter public void setOnreset(final Object onreset) { - setEventHandler("reset", onreset); + setEventHandler(Event.TYPE_RESET, onreset); } /** @@ -3335,7 +3335,7 @@ */ @JsxGetter public Function getOnsubmit() { - return getEventHandler("submit"); + return getEventHandler(Event.TYPE_SUBMIT); } /** @@ -3344,7 +3344,7 @@ */ @JsxSetter public void setOnsubmit(final Object onsubmit) { - setEventHandler("submit", onsubmit); + setEventHandler(Event.TYPE_SUBMIT, onsubmit); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/EventNode2.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/EventNode2.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/EventNode2.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -16,6 +16,8 @@ import static com.gargoylesoftware.js.nashorn.internal.objects.annotations.SupportedBrowser.IE; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event2; +import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent2; import com.gargoylesoftware.js.nashorn.internal.objects.annotations.Getter; import com.gargoylesoftware.js.nashorn.internal.objects.annotations.Setter; @@ -36,7 +38,7 @@ */ @Setter public void setOnclick(final Object handler) { - setEventHandler("click", handler); + setEventHandler(MouseEvent2.TYPE_CLICK, handler); } /** @@ -54,7 +56,7 @@ */ @Setter public void setOndblclick(final Object handler) { - setEventHandler("dblclick", handler); + setEventHandler(MouseEvent2.TYPE_DBL_CLICK, handler); } /** @@ -72,7 +74,7 @@ */ @Setter public void setOnblur(final Object handler) { - setEventHandler("blur", handler); + setEventHandler(Event2.TYPE_BLUR, handler); } /** @@ -90,7 +92,7 @@ */ @Setter public void setOnfocus(final Object handler) { - setEventHandler("focus", handler); + setEventHandler(Event2.TYPE_FOCUS, handler); } /** @@ -108,7 +110,7 @@ */ @Setter(IE) public void setOnfocusin(final Object handler) { - setEventHandler("focusin", handler); + setEventHandler(Event2.TYPE_FOCUS_IN, handler); } /** @@ -126,7 +128,7 @@ */ @Setter(IE) public void setOnfocusout(final Object handler) { - setEventHandler("focusout", handler); + setEventHandler(Event2.TYPE_FOCUS_OUT, handler); } /** @@ -144,7 +146,7 @@ */ @Setter public void setOnkeydown(final Object handler) { - setEventHandler("keydown", handler); + setEventHandler(Event2.TYPE_KEY_DOWN, handler); } /** @@ -162,7 +164,7 @@ */ @Setter public void setOnkeypress(final Object handler) { - setEventHandler("keypress", handler); + setEventHandler(Event2.TYPE_KEY_PRESS, handler); } /** @@ -180,7 +182,7 @@ */ @Setter public void setOnkeyup(final Object handler) { - setEventHandler("keyup", handler); + setEventHandler(Event2.TYPE_KEY_UP, handler); } /** @@ -198,7 +200,7 @@ */ @Setter public void setOnmousedown(final Object handler) { - setEventHandler("mousedown", handler); + setEventHandler(MouseEvent2.TYPE_MOUSE_DOWN, handler); } /** @@ -216,7 +218,7 @@ */ @Setter public void setOnmousemove(final Object handler) { - setEventHandler("mousemove", handler); + setEventHandler(MouseEvent2.TYPE_MOUSE_MOVE, handler); } /** @@ -234,7 +236,7 @@ */ @Setter public void setOnmouseout(final Object handler) { - setEventHandler("mouseout", handler); + setEventHandler(MouseEvent2.TYPE_MOUSE_OUT, handler); } /** @@ -252,7 +254,7 @@ */ @Setter public void setOnmouseover(final Object handler) { - setEventHandler("mouseover", handler); + setEventHandler(MouseEvent2.TYPE_MOUSE_OVER, handler); } /** @@ -270,7 +272,7 @@ */ @Setter public void setOnmouseup(final Object handler) { - setEventHandler("mouseup", handler); + setEventHandler(MouseEvent2.TYPE_MOUSE_UP, handler); } /** @@ -288,7 +290,7 @@ */ @Setter public void setOncontextmenu(final Object handler) { - setEventHandler("contextmenu", handler); + setEventHandler(MouseEvent2.TYPE_CONTEXT_MENU, handler); } /** @@ -319,30 +321,12 @@ } /** - * Sets the {@code onpropertychange} event handler for this element. - * @param handler the {@code onpropertychange} event handler for this element - */ - @Setter(IE) - public void setOnpropertychange(final Object handler) { - setEventHandler("propertychange", handler); - } - - /** - * Returns the {@code onpropertychange} event handler for this element. - * @return the {@code onpropertychange} event handler for this element - */ - @Getter(IE) - public Object getOnpropertychange() { - return getEventHandlerProp("onpropertychange"); - } - - /** * Sets the {@code onerror} event handler for this element. * @param handler the {@code onerror} event handler for this element */ @Setter public void setOnerror(final Object handler) { - setEventHandler("error", handler); + setEventHandler(Event2.TYPE_ERROR, handler); } /** @@ -360,7 +344,7 @@ */ @Setter public void setOninput(final Object onchange) { - setEventHandler("input", onchange); + setEventHandler(Event2.TYPE_INPUT, onchange); } /** @@ -369,6 +353,6 @@ */ @Getter public Object getOninput() { - return getEventHandler("input"); + return getEventHandler(Event2.TYPE_INPUT); } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -89,6 +89,7 @@ /** * Reads the contents of the specified {@link Blob} or {@link File}. * @param object the {@link Blob} or {@link File} from which to read + * @throws IOException if an error occurs */ @JsxFunction public void readAsDataURL(final Object object) throws IOException { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLBodyElement.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -31,6 +31,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration; import com.gargoylesoftware.htmlunit.javascript.host.dom.TextRange; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -242,7 +243,7 @@ */ @JsxGetter public Function getOnbeforeunload() { - return getEventHandler("beforeunload"); + return getEventHandler(Event.TYPE_BEFORE_UNLOAD); } /** @@ -251,7 +252,7 @@ */ @JsxSetter public void setOnbeforeunload(final Object onbeforeunload) { - setEventHandler("beforeunload", onbeforeunload); + setEventHandler(Event.TYPE_BEFORE_UNLOAD, onbeforeunload); } /** @@ -260,7 +261,7 @@ */ @JsxGetter public Function getOnhashchange() { - return getEventHandler("hashchange"); + return getEventHandler(Event.TYPE_HASH_CHANGE); } /** @@ -269,7 +270,7 @@ */ @JsxSetter public void setOnhashchange(final Object onhashchange) { - setEventHandler("hashchange", onhashchange); + setEventHandler(Event.TYPE_HASH_CHANGE, onhashchange); } /** @@ -296,7 +297,7 @@ */ @JsxGetter public Function getOnmessage() { - return getEventHandler("message"); + return getEventHandler(Event.TYPE_MESSAGE); } /** @@ -305,7 +306,7 @@ */ @JsxSetter public void setOnmessage(final Object onmessage) { - setEventHandler("message", onmessage); + setEventHandler(Event.TYPE_MESSAGE, onmessage); } /** @@ -386,7 +387,7 @@ */ @JsxGetter public Function getOnpopstate() { - return getEventHandler("popstate"); + return getEventHandler(Event.TYPE_POPSTATE); } /** @@ -395,7 +396,7 @@ */ @JsxSetter public void setOnpopstate(final Object onpopstate) { - setEventHandler("popstate", onpopstate); + setEventHandler(Event.TYPE_POPSTATE, onpopstate); } /** @@ -458,7 +459,7 @@ */ @JsxGetter public Function getOnunload() { - return getEventHandler("unload"); + return getEventHandler(Event.TYPE_UNLOAD); } /** @@ -467,7 +468,7 @@ */ @JsxSetter public void setOnunload(final Object onunload) { - setEventHandler("unload", onunload); + setEventHandler(Event.TYPE_UNLOAD, onunload); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument2.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument2.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument2.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -377,7 +377,7 @@ } /** - * JavaScript function "close". + * JavaScript function {@code close}. * * See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for * a good description of the semantics of open(), write(), writeln() and close(). 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 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -127,6 +127,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.dom.Node; import com.gargoylesoftware.htmlunit.javascript.host.dom.NodeList; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import com.gargoylesoftware.htmlunit.javascript.host.event.EventHandler; import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent; @@ -2032,7 +2033,7 @@ */ @JsxSetter public void setOnchange(final Object onchange) { - setEventHandler("change", onchange); + setEventHandler(Event.TYPE_CHANGE, onchange); } /** @@ -2041,7 +2042,7 @@ */ @JsxGetter public Function getOnchange() { - return getEventHandler("change"); + return getEventHandler(Event.TYPE_CHANGE); } /** @@ -2050,7 +2051,7 @@ */ @JsxGetter public Object getOnsubmit() { - return getEventHandler("submit"); + return getEventHandler(Event.TYPE_SUBMIT); } /** @@ -2059,7 +2060,7 @@ */ @JsxSetter public void setOnsubmit(final Object onsubmit) { - setEventHandler("submit", onsubmit); + setEventHandler(Event.TYPE_SUBMIT, onsubmit); } /** @@ -2173,7 +2174,7 @@ */ @JsxSetter public void setOnclick(final Object handler) { - setEventHandler("click", handler); + setEventHandler(MouseEvent.TYPE_CLICK, handler); } /** @@ -2182,7 +2183,7 @@ */ @JsxGetter public Object getOnclick() { - return getEventHandler("click"); + return getEventHandler(MouseEvent.TYPE_CLICK); } /** @@ -2191,7 +2192,7 @@ */ @JsxSetter public void setOndblclick(final Object handler) { - setEventHandler("dblclick", handler); + setEventHandler(MouseEvent.TYPE_DBL_CLICK, handler); } /** @@ -2200,7 +2201,7 @@ */ @JsxGetter public Object getOndblclick() { - return getEventHandler("dblclick"); + return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } /** @@ -2209,7 +2210,7 @@ */ @JsxSetter public void setOnblur(final Object handler) { - setEventHandler("blur", handler); + setEventHandler(Event.TYPE_BLUR, handler); } /** @@ -2218,7 +2219,7 @@ */ @JsxGetter public Object getOnblur() { - return getEventHandler("blur"); + return getEventHandler(Event.TYPE_BLUR); } /** @@ -2227,7 +2228,7 @@ */ @JsxSetter public void setOnfocus(final Object handler) { - setEventHandler("focus", handler); + setEventHandler(Event.TYPE_FOCUS, handler); } /** @@ -2236,7 +2237,7 @@ */ @JsxGetter public Object getOnfocus() { - return getEventHandler("focus"); + return getEventHandler(Event.TYPE_FOCUS); } /** @@ -2245,7 +2246,7 @@ */ @JsxSetter(IE) public void setOnfocusin(final Object handler) { - setEventHandler("focusin", handler); + setEventHandler(Event.TYPE_FOCUS_IN, handler); } /** @@ -2254,7 +2255,7 @@ */ @JsxGetter(IE) public Object getOnfocusin() { - return getEventHandler("focusin"); + return getEventHandler(Event.TYPE_FOCUS_IN); } /** @@ -2263,7 +2264,7 @@ */ @JsxSetter(IE) public void setOnfocusout(final Object handler) { - setEventHandler("focusout", handler); + setEventHandler(Event.TYPE_FOCUS_OUT, handler); } /** @@ -2272,7 +2273,7 @@ */ @JsxGetter(IE) public Object getOnfocusout() { - return getEventHandler("focusout"); + return getEventHandler(Event.TYPE_FOCUS_OUT); } /** @@ -2281,7 +2282,7 @@ */ @JsxSetter public void setOnkeydown(final Object handler) { - setEventHandler("keydown", handler); + setEventHandler(Event.TYPE_KEY_DOWN, handler); } /** @@ -2290,7 +2291,7 @@ */ @JsxGetter public Object getOnkeydown() { - return getEventHandler("keydown"); + return getEventHandler(Event.TYPE_KEY_DOWN); } /** @@ -2299,7 +2300,7 @@ */ @JsxSetter public void setOnkeypress(final Object handler) { - setEventHandler("keypress", handler); + setEventHandler(Event.TYPE_KEY_PRESS, handler); } /** @@ -2308,7 +2309,7 @@ */ @JsxGetter public Object getOnkeypress() { - return getEventHandler("keypress"); + return getEventHandler(Event.TYPE_KEY_PRESS); } /** @@ -2317,7 +2318,7 @@ */ @JsxSetter public void setOnkeyup(final Object handler) { - setEventHandler("keyup", handler); + setEventHandler(Event.TYPE_KEY_UP, handler); } /** @@ -2326,7 +2327,7 @@ */ @JsxGetter public Object getOnkeyup() { - return getEventHandler("keyup"); + return getEventHandler(Event.TYPE_KEY_UP); } /** @@ -2335,7 +2336,7 @@ */ @JsxSetter public void setOnmousedown(final Object handler) { - setEventHandler("mousedown", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_DOWN, handler); } /** @@ -2344,7 +2345,7 @@ */ @JsxGetter public Object getOnmousedown() { - return getEventHandler("mousedown"); + return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } /** @@ -2353,7 +2354,7 @@ */ @JsxSetter public void setOnmousemove(final Object handler) { - setEventHandler("mousemove", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_MOVE, handler); } /** @@ -2362,7 +2363,7 @@ */ @JsxGetter public Object getOnmousemove() { - return getEventHandler("mousemove"); + return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } /** @@ -2371,7 +2372,7 @@ */ @JsxSetter public void setOnmouseout(final Object handler) { - setEventHandler("mouseout", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_OUT, handler); } /** @@ -2380,7 +2381,7 @@ */ @JsxGetter public Object getOnmouseout() { - return getEventHandler("mouseout"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } /** @@ -2389,7 +2390,7 @@ */ @JsxSetter public void setOnmouseover(final Object handler) { - setEventHandler("mouseover", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_OVER, handler); } /** @@ -2398,7 +2399,7 @@ */ @JsxGetter public Object getOnmouseover() { - return getEventHandler("mouseover"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } /** @@ -2407,7 +2408,7 @@ */ @JsxSetter public void setOnmouseup(final Object handler) { - setEventHandler("mouseup", handler); + setEventHandler(MouseEvent.TYPE_MOUSE_UP, handler); } /** @@ -2416,7 +2417,7 @@ */ @JsxGetter public Object getOnmouseup() { - return getEventHandler("mouseup"); + return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } /** @@ -2425,7 +2426,7 @@ */ @JsxSetter public void setOncontextmenu(final Object handler) { - setEventHandler("contextmenu", handler); + setEventHandler(MouseEvent.TYPE_CONTEXT_MENU, handler); } /** @@ -2434,7 +2435,7 @@ */ @JsxGetter public Object getOncontextmenu() { - return getEventHandler("contextmenu"); + return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } /** @@ -2461,7 +2462,7 @@ */ @JsxSetter public void setOnerror(final Object handler) { - setEventHandler("error", handler); + setEventHandler(Event.TYPE_ERROR, handler); } /** @@ -2470,7 +2471,7 @@ */ @JsxGetter public Object getOnerror() { - return getEventHandler("error"); + return getEventHandler(Event.TYPE_ERROR); } /** @@ -2479,7 +2480,7 @@ */ @JsxGetter public Function getOninput() { - return getEventHandler("input"); + return getEventHandler(Event.TYPE_INPUT); } /** @@ -2488,7 +2489,7 @@ */ @JsxSetter public void setOninput(final Object oninput) { - setEventHandler("input", oninput); + setEventHandler(Event.TYPE_INPUT, oninput); } /** @@ -2637,7 +2638,7 @@ */ @JsxGetter(CHROME) public Function getOnclose() { - return getEventHandler("close"); + return getEventHandler(Event.TYPE_CLOSE); } /** @@ -2646,7 +2647,7 @@ */ @JsxSetter(CHROME) public void setOnclose(final Object onclose) { - setEventHandler("close", onclose); + setEventHandler(Event.TYPE_CLOSE, onclose); } /** @@ -2891,7 +2892,7 @@ */ @JsxGetter public Function getOnload() { - return getEventHandler("load"); + return getEventHandler(Event.TYPE_LOAD); } /** @@ -2900,7 +2901,7 @@ */ @JsxSetter public void setOnload(final Object onload) { - setEventHandler("load", onload); + setEventHandler(Event.TYPE_LOAD, onload); } /** @@ -3287,7 +3288,7 @@ */ @JsxGetter public Function getOnreset() { - return getEventHandler("reset"); + return getEventHandler(Event.TYPE_RESET); } /** @@ -3296,7 +3297,7 @@ */ @JsxSetter public void setOnreset(final Object onreset) { - setEventHandler("reset", onreset); + setEventHandler(Event.TYPE_RESET, onreset); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLFrameSetElement.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -24,6 +24,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -137,7 +138,7 @@ */ @JsxGetter public Function getOnbeforeunload() { - return getEventHandler("beforeunload"); + return getEventHandler(Event.TYPE_BEFORE_UNLOAD); } /** @@ -146,7 +147,7 @@ */ @JsxSetter public void setOnbeforeunload(final Object beforeunload) { - setEventHandler("beforeunload", beforeunload); + setEventHandler(Event.TYPE_BEFORE_UNLOAD, beforeunload); } /** @@ -155,7 +156,7 @@ */ @JsxGetter public Function getOnhashchange() { - return getEventHandler("hashchange"); + return getEventHandler(Event.TYPE_HASH_CHANGE); } /** @@ -164,7 +165,7 @@ */ @JsxSetter public void setOnhashchange(final Object hashchange) { - setEventHandler("hashchange", hashchange); + setEventHandler(Event.TYPE_HASH_CHANGE, hashchange); } /** @@ -191,7 +192,7 @@ */ @JsxGetter public Function getOnmessage() { - return getEventHandler("message"); + return getEventHandler(Event.TYPE_MESSAGE); } /** @@ -200,7 +201,7 @@ */ @JsxSetter public void setOnmessage(final Object message) { - setEventHandler("message", message); + setEventHandler(Event.TYPE_MESSAGE, message); } /** @@ -299,7 +300,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnpopstate() { - return getEventHandler("popstate"); + return getEventHandler(Event.TYPE_POPSTATE); } /** @@ -308,7 +309,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnpopstate(final Object popstate) { - setEventHandler("popstate", popstate); + setEventHandler(Event.TYPE_POPSTATE, popstate); } /** @@ -371,7 +372,7 @@ */ @JsxGetter public Function getOnunload() { - return getEventHandler("unload"); + return getEventHandler(Event.TYPE_UNLOAD); } /** @@ -380,7 +381,7 @@ */ @JsxSetter public void setOnunload(final Object unload) { - setEventHandler("unload", unload); + setEventHandler(Event.TYPE_UNLOAD, unload); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -32,6 +32,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import net.sourceforge.htmlunit.corejs.javascript.Undefined; @@ -139,7 +140,7 @@ */ @JsxGetter(IE) public Object getOnreadystatechange() { - return getEventHandler("readystatechange"); + return getEventHandler(Event.TYPE_READY_STATE_CHANGE); } /** @@ -148,7 +149,7 @@ */ @JsxSetter(IE) public void setOnreadystatechange(final Object handler) { - setEventHandler("readystatechange", handler); + setEventHandler(Event.TYPE_READY_STATE_CHANGE, handler); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement2.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement2.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLScriptElement2.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -28,6 +28,8 @@ import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlScript; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event2; import com.gargoylesoftware.js.nashorn.ScriptUtils; import com.gargoylesoftware.js.nashorn.internal.objects.Global; import com.gargoylesoftware.js.nashorn.internal.objects.annotations.Getter; @@ -157,7 +159,7 @@ */ @Setter(IE) public void setOnreadystatechange(final Object handler) { - setEventHandler("readystatechange", handler); + setEventHandler(Event.TYPE_READY_STATE_CHANGE, handler); } /** @@ -175,7 +177,7 @@ */ @Setter public void setOnload(final Object handler) { - setEventHandler("load", handler); + setEventHandler(Event2.TYPE_LOAD, handler); } /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGElement.java 2017-08-11 08:07:49 UTC (rev 14784) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGElement.java 2017-08-11 08:48:15 UTC (rev 14785) @@ -27,6 +27,8 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.host.Element; import com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration; +import com.gargoylesoftware.htmlunit.javascript.host.event.Event; +import com.gargoylesoftware.htmlunit.javascript.host.event.MouseEvent; import com.gargoylesoftware.htmlunit.svg.SvgElement; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -99,7 +101,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnfocus() { - return getEventHandler("focus"); + return getEventHandler(Event.TYPE_FOCUS); } /** @@ -108,7 +110,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnfocus(final Object focus) { - setEventHandler("focus", focus); + setEventHandler(Event.TYPE_FOCUS, focus); } /** @@ -405,7 +407,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnkeydown() { - return getEventHandler("keydown"); + return getEventHandler(Event.TYPE_KEY_DOWN); } /** @@ -414,7 +416,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnkeydown(final Object keydown) { - setEventHandler("keydown", keydown); + setEventHandler(Event.TYPE_KEY_DOWN, keydown); } /** @@ -459,7 +461,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnclick() { - return getEventHandler("click"); + return getEventHandler(MouseEvent.TYPE_CLICK); } /** @@ -468,7 +470,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnclick(final Object click) { - setEventHandler("click", click); + setEventHandler(MouseEvent.TYPE_CLICK, click); } /** @@ -477,7 +479,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnkeyup() { - return getEventHandler("keyup"); + return getEventHandler(Event.TYPE_KEY_UP); } /** @@ -486,7 +488,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnkeyup(final Object keyup) { - setEventHandler("keyup", keyup); + setEventHandler(Event.TYPE_KEY_UP, keyup); } /** @@ -495,7 +497,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnchange() { - return getEventHandler("change"); + return getEventHandler(Event.TYPE_CHANGE); } /** @@ -504,7 +506,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnchange(final Object change) { - setEventHandler("change", change); + setEventHandler(Event.TYPE_CHANGE, change); } /** @@ -513,7 +515,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnreset() { - return getEventHandler("reset"); + return getEventHandler(Event.TYPE_RESET); } /** @@ -522,7 +524,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnreset(final Object reset) { - setEventHandler("reset", reset); + setEventHandler(Event.TYPE_RESET, reset); } /** @@ -531,7 +533,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnkeypress() { - return getEventHandler("keypress"); + return getEventHandler(Event.TYPE_KEY_PRESS); } /** @@ -540,7 +542,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnkeypress(final Object keypress) { - setEventHandler("keypress", keypress); + setEventHandler(Event.TYPE_KEY_PRESS, keypress); } /** @@ -567,7 +569,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOndblclick() { - return getEventHandler("dblclick"); + return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } /** @@ -576,7 +578,7 @@ */ @JsxSetter({CHROME, FF}) public void setOndblclick(final Object dblclick) { - setEventHandler("dblclick", dblclick); + setEventHandler(MouseEvent.TYPE_DBL_CLICK, dblclick); } /** @@ -693,7 +695,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOncontextmenu() { - return getEventHandler("contextmenu"); + return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } /** @@ -702,7 +704,7 @@ */ @JsxSetter({CHROME, FF}) public void setOncontextmenu(final Object contextmenu) { - setEventHandler("contextmenu", contextmenu); + setEventHandler(MouseEvent.TYPE_CONTEXT_MENU, contextmenu); } /** @@ -711,7 +713,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnmousemove() { - return getEventHandler("mousemove"); + return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } /** @@ -720,7 +722,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnmousemove(final Object mousemove) { - setEventHandler("mousemove", mousemove); + setEventHandler(MouseEvent.TYPE_MOUSE_MOVE, mousemove); } /** @@ -729,7 +731,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnerror() { - return getEventHandler("error"); + return getEventHandler(Event.TYPE_ERROR); } /** @@ -738,7 +740,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnerror(final Object error) { - setEventHandler("error", error); + setEventHandler(Event.TYPE_ERROR, error); } /** @@ -747,7 +749,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnmouseup() { - return getEventHandler("mouseup"); + return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } /** @@ -756,7 +758,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnmouseup(final Object mouseup) { - setEventHandler("mouseup", mouseup); + setEventHandler(MouseEvent.TYPE_MOUSE_UP, mouseup); } /** @@ -819,7 +821,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnmouseover() { - return getEventHandler("mouseover"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } /** @@ -828,7 +830,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnmouseover(final Object mouseover) { - setEventHandler("mouseover", mouseover); + setEventHandler(MouseEvent.TYPE_MOUSE_OVER, mouseover); } /** @@ -837,7 +839,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOninput() { - return getEventHandler("input"); + return getEventHandler(Event.TYPE_INPUT); } /** @@ -846,7 +848,7 @@ */ @JsxSetter({CHROME, FF}) public void setOninput(final Object input) { - setEventHandler("input", input); + setEventHandler(Event.TYPE_INPUT, input); } /** @@ -927,7 +929,7 @@ */ @JsxGetter(CHROME) public Function getOnclose() { - return getEventHandler("close"); + return getEventHandler(Event.TYPE_CLOSE); } /** @@ -936,7 +938,7 @@ */ @JsxSetter(CHROME) public void setOnclose(final Object close) { - setEventHandler("close", close); + setEventHandler(Event.TYPE_CLOSE, close); } /** @@ -981,7 +983,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnsubmit() { - return getEventHandler("submit"); + return getEventHandler(Event.TYPE_SUBMIT); } /** @@ -990,7 +992,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnsubmit(final Object submit) { - setEventHandler("submit", submit); + setEventHandler(Event.TYPE_SUBMIT, submit); } /** @@ -1107,7 +1109,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnblur() { - return getEventHandler("blur"); + return getEventHandler(Event.TYPE_BLUR); } /** @@ -1116,7 +1118,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnblur(final Object blur) { - setEventHandler("blur", blur); + setEventHandler(Event.TYPE_BLUR, blur); } /** @@ -1233,7 +1235,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnload() { - return getEventHandler("load"); + return getEventHandler(Event.TYPE_LOAD); } /** @@ -1242,7 +1244,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnload(final Object load) { - setEventHandler("load", load); + setEventHandler(Event.TYPE_LOAD, load); } /** @@ -1341,7 +1343,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnmouseout() { - return getEventHandler("mouseout"); + return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } /** @@ -1350,7 +1352,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnmouseout(final Object mouseout) { - setEventHandler("mouseout", mouseout); + setEventHandler(MouseEvent.TYPE_MOUSE_OUT, mouseout); } /** @@ -1431,7 +1433,7 @@ */ @JsxGetter({CHROME, FF}) public Function getOnmousedown() { - return getEventHandler("mousedown"); + return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } /** @@ -1440,7 +1442,7 @@ */ @JsxSetter({CHROME, FF}) public void setOnmousedown(final Object mousedown) { - setEventHandler("mousedown", mousedown); + setEventHandler(MouseEvent.TYPE_MOUSE_DOWN, mousedown); } /** |
From: <asa...@us...> - 2017-08-11 09:19:54
|
Revision: 14786 http://sourceforge.net/p/htmlunit/code/14786 Author: asashour Date: 2017-08-11 09:19:51 +0000 (Fri, 11 Aug 2017) Log Message: ----------- Add BuildServerDiscrepancy Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-08-11 08:48:15 UTC (rev 14785) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-08-11 09:19:51 UTC (rev 14786) @@ -897,11 +897,11 @@ @BrowserFeature(FF) JS_FILE_SHORT_DATE_FORMAT, - /** Whether {@link FileReader} includes content type or not. */ + /** Whether {@code FileReader} includes content type or not. */ @BrowserFeature(FF) JS_FILEREADER_CONTENT_TYPE, - /** Whether {@link FileReader} includes {@code base64} for empty content or not. */ + /** Whether {@code FileReader} includes {@code base64} for empty content or not. */ @BrowserFeature(IE) JS_FILEREADER_EMPTY_NULL, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java 2017-08-11 08:48:15 UTC (rev 14785) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java 2017-08-11 09:19:51 UTC (rev 14786) @@ -46,7 +46,7 @@ final HtmlForm form = ((HtmlElement) domNode).getEnclosingForm(); if (form != null) { - setParentScope(getScriptableFor(form)); + setParentScope(getScriptableFor(form).getParentScope()); } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java 2017-08-11 09:19:51 UTC (rev 14786) @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2002-2017 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.annotations; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * An annotation to denote a test which behaves on the build server differnt than locally. + * + * @author Ahmed Ashour + */ +@Retention(RetentionPolicy.SOURCE) +@Target(ElementType.METHOD) +public @interface BuildServerDiscrepancy { + +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java 2017-08-11 08:48:15 UTC (rev 14785) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/NativeArrayTest.java 2017-08-11 09:19:51 UTC (rev 14786) @@ -27,6 +27,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.annotations.BuildServerDiscrepancy; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -184,6 +185,7 @@ * @throws Exception if the test fails */ @Test + @BuildServerDiscrepancy public void comparisonMethodViolatesContract2() throws Exception { final Properties props = System.getProperties(); props.list(System.out); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java 2017-08-11 08:48:15 UTC (rev 14785) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java 2017-08-11 09:19:51 UTC (rev 14786) @@ -25,6 +25,8 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.annotations.BuildServerDiscrepancy; import com.gargoylesoftware.htmlunit.WebDriverTestCase; import com.gargoylesoftware.htmlunit.html.HtmlPageTest; @@ -32,6 +34,7 @@ * Tests for {@link FileReader}. * * @author Ronald Brill + * @author Ahmed Ashour */ @RunWith(BrowserRunner.class) public class FileReaderTest extends WebDriverTestCase { @@ -120,6 +123,8 @@ FF = "data:application/octet-stream;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAABlBMVEX+1K8AAAD" + "jghFsAAAAGXRFWHRTb2Z0d2FyZQBHcmFwaGljQ29udmVydGVyNV1I7gAAABBJREFUeJxiYAAAAAD//wMAAAIAAcx+i34AAAAASU" + "VORK5CYII=") + @NotYetImplemented + @BuildServerDiscrepancy public void readAsDataURLUnknown() throws Exception { final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ |
From: <asa...@us...> - 2017-08-11 09:26:29
|
Revision: 14787 http://sourceforge.net/p/htmlunit/code/14787 Author: asashour Date: 2017-08-11 09:26:26 +0000 (Fri, 11 Aug 2017) Log Message: ----------- Fixing build Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java 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 2017-08-11 09:19:51 UTC (rev 14786) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Element.java 2017-08-11 09:26:26 UTC (rev 14787) @@ -123,7 +123,7 @@ style_ = new CSSStyleDeclaration(this); - setParentScope(getWindow()); + setParentScope(getWindow().getDocument()); /** * Convert JavaScript snippets defined in the attribute map to executable event handlers. Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java 2017-08-11 09:19:51 UTC (rev 14786) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/event/EventListenersContainer.java 2017-08-11 09:26:26 UTC (rev 14787) @@ -32,6 +32,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlBody; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.javascript.host.Window; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.NativeObject; @@ -230,14 +231,19 @@ if (listeners != null && !listeners.isEmpty()) { event.setCurrentTarget(jsNode_); - final Window window; + final HtmlPage page; if (jsNode_ instanceof Window) { - window = (Window) jsNode_; + page = (HtmlPage) ((Window) jsNode_).getDomNodeOrDie(); } else { - window = (Window) jsNode_.getParentScope(); + final Scriptable parentScope = jsNode_.getParentScope(); + if (parentScope instanceof HTMLDocument) { + page = ((HTMLDocument) parentScope).getPage(); + } + else { + page = (HtmlPage) ((Window) parentScope).getDomNodeOrDie(); + } } - final HtmlPage page = (HtmlPage) window.getDomNodeOrDie(); // no need for a copy, listeners are copy on write for (final Scriptable listener : listeners) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java 2017-08-11 09:19:51 UTC (rev 14786) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/FormField.java 2017-08-11 09:26:26 UTC (rev 14787) @@ -46,7 +46,7 @@ final HtmlForm form = ((HtmlElement) domNode).getEnclosingForm(); if (form != null) { - setParentScope(getScriptableFor(form).getParentScope()); + setParentScope(getScriptableFor(form)); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java 2017-08-11 09:19:51 UTC (rev 14786) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/annotations/BuildServerDiscrepancy.java 2017-08-11 09:26:26 UTC (rev 14787) @@ -20,7 +20,7 @@ import java.lang.annotation.Target; /** - * An annotation to denote a test which behaves on the build server differnt than locally. + * An annotation to denote a test which behaves on the build server different than locally. * * @author Ahmed Ashour */ |
From: <rb...@us...> - 2017-08-25 09:03:49
|
Revision: 14790 http://sourceforge.net/p/htmlunit/code/14790 Author: rbri Date: 2017-08-25 09:03:46 +0000 (Fri, 25 Aug 2017) Log Message: ----------- minor browser version updates Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-08-11 10:26:14 UTC (rev 14789) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-08-25 09:03:46 UTC (rev 14790) @@ -171,7 +171,7 @@ // FF52 FIREFOX_52.applicationVersion_ = "5.0 (Windows)"; FIREFOX_52.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0"; - FIREFOX_52.buildId_ = "20170627155318"; + FIREFOX_52.buildId_ = "20170802111520"; FIREFOX_52.headerNamesOrdered_ = new String[] { "Host", "User-Agent", "Accept", "Accept-Language", "Accept-Encoding", "Referer", "Cookie", "Connection", "Upgrade-Insecure-Requests"}; FIREFOX_52.htmlAcceptHeader_ = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; @@ -194,8 +194,8 @@ EDGE.userAgent_ = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; // CHROME - CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"; - CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"; + CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"; + CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"; CHROME.applicationCodeName_ = "Mozilla"; CHROME.vendor_ = "Google Inc."; @@ -327,19 +327,19 @@ CHROME.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.137", "NPSWF32_26_0_0_137.dll"); + "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF32_26_0_0_151.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); FIREFOX_45.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.137", "NPSWF64_26_0_0_137.dll"); + "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF64_26_0_0_151.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); FIREFOX_52.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.137", "Flash32_26_0_0_137.ocx"); + "Shockwave Flash 26.0 r0", "26.0.0.151", "Flash32_26_0_0_151.ocx"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); INTERNET_EXPLORER.getPlugins().add(flash); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-08-11 10:26:14 UTC (rev 14789) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-08-25 09:03:46 UTC (rev 14790) @@ -214,10 +214,10 @@ * @throws Exception on test failure */ @Test - @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.137", "NPSWF32_26_0_0_137.dll"}, - FF52 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.137", "NPSWF64_26_0_0_137.dll"}, + @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF32_26_0_0_151.dll"}, + FF52 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF64_26_0_0_151.dll"}, CHROME = {"Shockwave Flash", "Shockwave Flash 24.0 r0", "undefined", "internal-not-yet-present"}, - IE = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.137", "Flash32_26_0_0_137.ocx"}, + IE = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "Flash32_26_0_0_151.ocx"}, EDGE = {"Shockwave Flash", "Shockwave Flash 18.0 r0", "18.0.0.232", "Flash.ocx"}) public void pluginsShockwaveFlash() throws Exception { final String html = "<html>\n" @@ -380,7 +380,7 @@ @Test @Alerts(DEFAULT = "undefined", FF45 = "20170411115307", - FF52 = "20170627155318") + FF52 = "20170802111520") public void buildID() throws Exception { final String html = "<html><head><title>First</title>\n" |
From: <rb...@us...> - 2017-08-25 09:59:34
|
Revision: 14792 http://sourceforge.net/p/htmlunit/code/14792 Author: rbri Date: 2017-08-25 09:59:32 +0000 (Fri, 25 Aug 2017) Log Message: ----------- FileReader.readAsArrayBuffer() Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-08-25 09:04:46 UTC (rev 14791) +++ trunk/htmlunit/src/changes/changes.xml 2017-08-25 09:59:32 UTC (rev 14792) @@ -8,6 +8,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 60"> + <action type="add" dev="rbri" issue="1913"> + JavaScript: support FileReader.readAsArrayBuffer(). + </action> <action type="add" dev="asashour" issue="1912"> JavaScript: support FileReader.readAsDataURL(). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-08-25 09:04:46 UTC (rev 14791) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/WebSocket.java 2017-08-25 09:59:32 UTC (rev 14792) @@ -457,13 +457,10 @@ } super.onWebSocketBinary(data, offset, length); - final ArrayBuffer buffer = new ArrayBuffer(); + final ArrayBuffer buffer = new ArrayBuffer(Arrays.copyOfRange(data, offset, length)); buffer.setParentScope(getParentScope()); buffer.setPrototype(getPrototype(buffer.getClass())); - buffer.constructor(length); - buffer.setBytes(0, Arrays.copyOfRange(data, offset, length)); - final MessageEvent msgEvent = new MessageEvent(buffer); msgEvent.setOrigin(getUrl()); fire(msgEvent); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2017-08-25 09:04:46 UTC (rev 14791) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2017-08-25 09:59:32 UTC (rev 14792) @@ -36,6 +36,20 @@ private byte[] bytes_; /** + * Ctor. + */ + public ArrayBuffer() { + } + + /** + * Ctor with given bytes. + * @param bytes the initial bytes + */ + public ArrayBuffer(final byte[] bytes) { + bytes_ = bytes; + } + + /** * The constructor. * @param length the size, in bytes, of the array buffer to create. */ @@ -74,8 +88,7 @@ else if (Double.isInfinite(beginNumber)) { if (beginNumber > 0) { final byte[] byteArray = new byte[0]; - final ArrayBuffer arrayBuffer = new ArrayBuffer(); - arrayBuffer.bytes_ = byteArray; + final ArrayBuffer arrayBuffer = new ArrayBuffer(byteArray); return arrayBuffer; } beginInt = 0; @@ -101,8 +114,7 @@ final byte[] byteArray = new byte[(int) endNumber - beginInt]; System.arraycopy(bytes_, beginInt, byteArray, 0, byteArray.length); - final ArrayBuffer arrayBuffer = new ArrayBuffer(); - arrayBuffer.bytes_ = byteArray; + final ArrayBuffer arrayBuffer = new ArrayBuffer(byteArray); return arrayBuffer; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java 2017-08-25 09:04:46 UTC (rev 14791) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReader.java 2017-08-25 09:59:32 UTC (rev 14792) @@ -31,6 +31,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; +import com.gargoylesoftware.htmlunit.javascript.host.arrays.ArrayBuffer; import com.gargoylesoftware.htmlunit.javascript.host.event.Event; import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; @@ -93,12 +94,6 @@ */ @JsxFunction public void readAsDataURL(final Object object) throws IOException { - setResult(object); - final Event event = new Event(this, Event.TYPE_LOAD); - fireEvent(event); - } - - private void setResult(final Object object) throws IOException { readyState_ = LOADING; final java.io.File file = ((File) object).getFile(); String contentType = Files.probeContentType(file.toPath()); @@ -127,9 +122,37 @@ } } readyState_ = DONE; + + final Event event = new Event(this, Event.TYPE_LOAD); + fireEvent(event); } /** + * Reads the contents of the specified {@link Blob} or {@link File}. + * @param object the {@link Blob} or {@link File} from which to read + * @throws IOException if an error occurs + */ + @JsxFunction + public void readAsArrayBuffer(final Object object) throws IOException { + readyState_ = LOADING; + final java.io.File file = ((File) object).getFile(); + try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { + FileUtils.copyFile(file, bos); + + final byte[] bytes = bos.toByteArray(); + + final ArrayBuffer buffer = new ArrayBuffer(bytes); + buffer.setParentScope(getParentScope()); + buffer.setPrototype(getPrototype(buffer.getClass())); + result_ = buffer; + } + readyState_ = DONE; + + final Event event = new Event(this, Event.TYPE_LOAD); + fireEvent(event); + } + + /** * Returns the {@code onload} event handler for this {@link FileReader}. * @return the {@code onload} event handler for this {@link FileReader} */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java 2017-08-25 09:04:46 UTC (rev 14791) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/file/FileReaderTest.java 2017-08-25 09:59:32 UTC (rev 14792) @@ -193,4 +193,126 @@ driver.findElement(By.tagName("input")).sendKeys(path); verifyAlerts(driver, getExpectedAlerts()); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object ArrayBuffer]", "8"}) + public void readAsArrayBuffer() throws Exception { + final String html + = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " var files = document.testForm.fileupload.files;\n" + + " var reader = new FileReader();\n" + + " reader.onload = function() {\n" + + " alert(reader.result);\n" + + " alert(reader.result.byteLength);\n" + + " };\n" + + " reader.readAsArrayBuffer(files[0]);\n" + + " }\n" + + " </script>\n" + + "<head>\n" + + "<body>\n" + + " <form name='testForm'>\n" + + " <input type='file' id='fileupload' name='fileupload'>\n" + + " </form>\n" + + " <button id='testBtn' onclick='test()'>Tester</button>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + + final File tstFile = File.createTempFile("HtmlUnitReadAsArrayBufferTest", ".txt"); + try { + FileUtils.write(tstFile, "HtmlUnit", StandardCharsets.UTF_8); + + final String path = tstFile.getCanonicalPath(); + driver.findElement(By.name("fileupload")).sendKeys(path); + + driver.findElement(By.id("testBtn")).click(); + + verifyAlerts(driver, getExpectedAlerts()); + } + finally { + FileUtils.deleteQuietly(tstFile); + } + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object ArrayBuffer]", "128"}) + public void readAsArrayBufferUnknown() throws Exception { + final String html + = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head><title>foo</title>\n" + + "<script>\n" + + " function previewFile() {\n" + + " var file = document.querySelector('input[type=file]').files[0];\n" + + " var reader = new FileReader();\n" + + " reader.addEventListener('load', function () {\n" + + " alert(reader.result);\n" + + " alert(reader.result.byteLength);\n" + + " }, false);\n" + + "\n" + + " if (file) {\n" + + " reader.readAsArrayBuffer(file);\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body>\n" + + " <input type='file' onchange='previewFile()'>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + + final String path = new File("src/test/resources/testfiles/tiny-png.img").getCanonicalPath(); + driver.findElement(By.tagName("input")).sendKeys(path); + verifyAlerts(driver, getExpectedAlerts()); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object ArrayBuffer]", "0"}) + public void readAsArrayBufferEmptyImage() throws Exception { + final String html + = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html>\n" + + "<head><title>foo</title>\n" + + "<script>\n" + + " function previewFile() {\n" + + " var file = document.querySelector('input[type=file]').files[0];\n" + + " var reader = new FileReader();\n" + + " reader.addEventListener('load', function () {\n" + + " alert(reader.result);\n" + + " alert(reader.result.byteLength);\n" + + " }, false);\n" + + "\n" + + " if (file) {\n" + + " reader.readAsArrayBuffer(file);\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body>\n" + + " <input type='file' onchange='previewFile()'>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + + final String path = new File("src/test/resources/testfiles/empty.png").getCanonicalPath(); + driver.findElement(By.tagName("input")).sendKeys(path); + verifyAlerts(driver, getExpectedAlerts()); + } } |
From: <rb...@us...> - 2017-08-28 18:11:06
|
Revision: 14799 http://sourceforge.net/p/htmlunit/code/14799 Author: rbri Date: 2017-08-28 18:11:03 +0000 (Mon, 28 Aug 2017) Log Message: ----------- take the selector specificity into account Issue 1916 Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 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 2017-08-28 16:52:35 UTC (rev 14798) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2017-08-28 18:11:03 UTC (rev 14799) @@ -413,10 +413,14 @@ if (element1 == null) { value = element2.getValue(); } - else if (element1.getIndex() > element2.getIndex()) { - return element1.getValue(); - } else { + final int comp = element1.getSpecificity().compareTo(element2.getSpecificity()); + if (comp > 0) { + return element1.getValue(); + } + if (comp == 0 && element1.getIndex() > element2.getIndex()) { + return element1.getValue(); + } value = element2.getValue(); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-28 16:52:35 UTC (rev 14798) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-28 18:11:03 UTC (rev 14799) @@ -2120,4 +2120,30 @@ + "</body></html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("131") + public void combineStyles() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + "<style type='text/css'>\n" + + " div { margin: 10px 20px 30px 40px; }\n" + + "</style>\n" + + "<script>\n" + + " function test() {\n" + + " var div = document.getElementById('div1');\n" + + " var left = div.style.marginLeft;\n" // force the resolution + + " alert(div.offsetLeft);\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <div id='div1' style='margin-left: 123px'></div>\n" + + "</body></html>\n"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-08-29 17:21:26
|
Revision: 14801 http://sourceforge.net/p/htmlunit/code/14801 Author: rbri Date: 2017-08-29 17:21:23 +0000 (Tue, 29 Aug 2017) Log Message: ----------- fix handling of browser default styles Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/SelectorSpecificity.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/StyleElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/SelectorSpecificity.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/SelectorSpecificity.java 2017-08-28 18:22:05 UTC (rev 14800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/SelectorSpecificity.java 2017-08-29 17:21:23 UTC (rev 14801) @@ -44,6 +44,10 @@ * The specificity for declarations made in the style attributes of an element. */ public static final SelectorSpecificity FROM_STYLE_ATTRIBUTE = new SelectorSpecificity(1, 0, 0, 0); + /** + * The specificity for browser defaults. + */ + public static final SelectorSpecificity DEFAULT_STYLE_ATTRIBUTE = new SelectorSpecificity(0, 0, 0, 0); private int fieldA_; private int fieldB_; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/StyleElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/StyleElement.java 2017-08-28 18:22:05 UTC (rev 14800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/css/StyleElement.java 2017-08-29 17:21:23 UTC (rev 14801) @@ -75,15 +75,6 @@ } /** - * Creates a new instance. - * @param name the style element's name - * @param value the style element's value - */ - public StyleElement(final String name, final String value) { - this(name, value, "", SelectorSpecificity.FROM_STYLE_ATTRIBUTE); - } - - /** * Returns the style element's name. * @return the style element's name */ Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-08-28 18:22:05 UTC (rev 14800) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclaration.java 2017-08-29 17:21:23 UTC (rev 14801) @@ -302,7 +302,7 @@ * @param newValue the value of the style attribute to set */ public void setDefaultLocalStyleAttribute(final String name, final String newValue) { - final StyleElement element = new StyleElement(name, newValue); + final StyleElement element = new StyleElement(name, newValue, "", SelectorSpecificity.DEFAULT_STYLE_ATTRIBUTE); localModifications_.put(name, element); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-28 18:22:05 UTC (rev 14800) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-29 17:21:23 UTC (rev 14801) @@ -2146,4 +2146,31 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts("23") + public void combineStylesBrowserDefaults() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + "<style type='text/css'>\n" + + " body { margin: 3px; }\n" + + " div { margin: 20px; }\n" + + "</style>\n" + + "<script>\n" + + " function test() {\n" + + " var div = document.getElementById('div1');\n" + + " var left = div.style.marginLeft;\n" // force the resolution + + " alert(div.offsetLeft);\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <div id='div1'></div>\n" + + "</body></html>\n"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-08-30 18:41:06
|
Revision: 14808 http://sourceforge.net/p/htmlunit/code/14808 Author: rbri Date: 2017-08-30 18:41:04 +0000 (Wed, 30 Aug 2017) Log Message: ----------- take care of important also Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 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 2017-08-30 17:35:49 UTC (rev 14807) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleDeclaration.java 2017-08-30 18:41:04 UTC (rev 14808) @@ -414,13 +414,9 @@ value = element2.getValue(); } else { - final int comp = element1.getSpecificity().compareTo(element2.getSpecificity()); - if (comp > 0) { + if (element1.compareTo(element2) > 0) { return element1.getValue(); } - if (comp == 0 && element1.getIndex() > element2.getIndex()) { - return element1.getValue(); - } value = element2.getValue(); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-30 17:35:49 UTC (rev 14807) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/ComputedCSSStyleDeclarationTest.java 2017-08-30 18:41:04 UTC (rev 14808) @@ -2151,6 +2151,32 @@ * @throws Exception if an error occurs */ @Test + @Alerts("48") + public void combineStylesImportant() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + "<style type='text/css'>\n" + + " div { margin: 10px 20px 30px 40px !important; }\n" + + "</style>\n" + + "<script>\n" + + " function test() {\n" + + " var div = document.getElementById('div1');\n" + + " var left = div.style.marginLeft;\n" // force the resolution + + " alert(div.offsetLeft);\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <div id='div1' style='margin-left: 123px'></div>\n" + + "</body></html>\n"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts("23") public void combineStylesBrowserDefaults() throws Exception { final String html = "<html>\n" |
From: <rb...@us...> - 2017-09-08 07:23:45
|
Revision: 14811 http://sourceforge.net/p/htmlunit/code/14811 Author: rbri Date: 2017-09-08 07:23:42 +0000 (Fri, 08 Sep 2017) Log Message: ----------- latest chrome (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-09-07 18:25:12 UTC (rev 14810) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-09-08 07:23:42 UTC (rev 14811) @@ -194,8 +194,8 @@ EDGE.userAgent_ = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; // CHROME - CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"; - CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36"; + CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"; + CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"; CHROME.applicationCodeName_ = "Mozilla"; CHROME.vendor_ = "Google Inc."; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-09-07 18:25:12 UTC (rev 14810) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/ElementPropertiesTest.java 2017-09-08 07:23:42 UTC (rev 14811) @@ -419,7 +419,8 @@ */ @Test @Alerts(CHROME = "accessKey,blur(),click(),contentEditable,dataset,dir,draggable,focus(),hidden," - + "innerText,isContentEditable,lang,offsetHeight,offsetLeft,offsetParent,offsetTop,offsetWidth,onabort," + + "innerText,isContentEditable,lang,nonce," + + "offsetHeight,offsetLeft,offsetParent,offsetTop,offsetWidth,onabort," + "onauxclick,onblur,oncancel,oncanplay,oncanplaythrough,onchange,onclick," + "onclose,oncontextmenu,oncuechange,ondblclick,ondrag,ondragend,ondragenter,ondragleave,ondragover," + "ondragstart,ondrop,ondurationchange,onemptied,onended,onerror,onfocus,ongotpointercapture," @@ -430,7 +431,7 @@ + "onpointercancel,onpointerdown,onpointerenter,onpointerleave,onpointermove,onpointerout," + "onpointerover,onpointerup,onprogress," + "onratechange,onreset,onresize,onscroll,onseeked,onseeking,onselect," - + "onshow,onstalled,onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,outerText," + + "onstalled,onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,onwheel,outerText," + "spellcheck,style,tabIndex,title,translate", FF45 = "accessKey,accessKeyLabel,blur(),click(),contentEditable,contextMenu,dataset,dir," + "draggable,focus(),hidden,innerText,isContentEditable,itemId,itemProp,itemRef,itemScope," @@ -506,15 +507,17 @@ @Test @Alerts(DEFAULT = "animate(),append(),attachShadow(),attributes,childElementCount,children,classList,className," + "clientHeight,clientLeft,clientTop,clientWidth,closest(),createShadowRoot(),firstElementChild," - + "getAttribute(),getAttributeNode(),getAttributeNodeNS(),getAttributeNS(),getBoundingClientRect()," + + "getAttribute(),getAttributeNames(),getAttributeNode(),getAttributeNodeNS(),getAttributeNS()," + + "getBoundingClientRect()," + "getClientRects(),getElementsByClassName(),getElementsByTagName(),getElementsByTagNameNS()," + "hasAttribute(),hasAttributeNS(),hasAttributes(),hasPointerCapture(),id,innerHTML," + "insertAdjacentElement(),insertAdjacentHTML(),insertAdjacentText(),lastElementChild,localName," + "matches(),namespaceURI,onbeforecopy,onbeforecut,onbeforepaste,oncopy,oncut,onpaste,onsearch," - + "onselectstart,onwebkitfullscreenchange,onwebkitfullscreenerror,onwheel,outerHTML,prefix,prepend()," + + "onselectstart,onwebkitfullscreenchange,onwebkitfullscreenerror,outerHTML,prefix,prepend()," + "querySelector(),querySelectorAll(),releasePointerCapture(),removeAttribute(),removeAttributeNode()," - + "removeAttributeNS(),requestPointerLock(),scrollHeight,scrollIntoView(),scrollIntoViewIfNeeded()," - + "scrollLeft,scrollTop,scrollWidth,setAttribute(),setAttributeNode(),setAttributeNodeNS()," + + "removeAttributeNS(),requestPointerLock()," + + "scroll(),scrollBy(),scrollHeight,scrollIntoView(),scrollIntoViewIfNeeded()," + + "scrollLeft,scrollTo(),scrollTop,scrollWidth,setAttribute(),setAttributeNode(),setAttributeNodeNS()," + "setAttributeNS(),setPointerCapture(),shadowRoot,slot,tagName,webkitMatchesSelector()," + "webkitRequestFullScreen(),webkitRequestFullscreen()", FF52 = "animate(),append(),attributes,childElementCount,children,classList,className,clientHeight," @@ -564,15 +567,18 @@ @Test @Alerts(CHROME = "after(),animate(),assignedSlot,attachShadow(),attributes,before(),classList,className," + "clientHeight,clientLeft,clientTop,clientWidth,closest(),createShadowRoot(),getAttribute()," - + "getAttributeNode(),getAttributeNodeNS(),getAttributeNS(),getBoundingClientRect(),getClientRects()," + + "getAttributeNames(),getAttributeNode(),getAttributeNodeNS(),getAttributeNS()," + + "getBoundingClientRect(),getClientRects()," + "getDestinationInsertionPoints(),getElementsByClassName(),getElementsByTagName()," + "getElementsByTagNameNS(),hasAttribute(),hasAttributeNS(),hasAttributes(),hasPointerCapture(),id," + "innerHTML,insertAdjacentElement(),insertAdjacentHTML(),insertAdjacentText(),localName,matches()," + "namespaceURI,nextElementSibling,onbeforecopy,onbeforecut,onbeforepaste,oncopy,oncut,onpaste," - + "onsearch,onselectstart,onwebkitfullscreenchange,onwebkitfullscreenerror,onwheel,outerHTML,prefix," + + "onsearch,onselectstart,onwebkitfullscreenchange,onwebkitfullscreenerror,outerHTML,prefix," + "previousElementSibling,releasePointerCapture(),remove(),removeAttribute(),removeAttributeNode()," - + "removeAttributeNS(),replaceWith(),requestPointerLock(),scrollHeight,scrollIntoView()," - + "scrollIntoViewIfNeeded(),scrollLeft,scrollTop,scrollWidth,setAttribute(),setAttributeNode()," + + "removeAttributeNS(),replaceWith(),requestPointerLock()," + + "scroll(),scrollBy(),scrollHeight,scrollIntoView()," + + "scrollIntoViewIfNeeded(),scrollLeft,scrollTo(),scrollTop,scrollWidth,setAttribute()," + + "setAttributeNode()," + "setAttributeNodeNS(),setAttributeNS(),setPointerCapture(),shadowRoot,slot,tagName," + "webkitMatchesSelector(),webkitRequestFullScreen(),webkitRequestFullscreen()", FF45 = "attributes,classList,className,clientHeight,clientLeft,clientTop," @@ -666,13 +672,15 @@ @Alerts(CHROME = "addEventListener(),alert(),applicationCache,atob(),blur(),btoa(),caches,cancelAnimationFrame()," + "cancelIdleCallback(),captureEvents(),chrome,clearInterval(),clearTimeout(),clientInformation," + "close(),closed,confirm()," - + "createImageBitmap(),crypto,customElements,defaultStatus,defaultstatus,devicePixelRatio," + + "createImageBitmap(),crypto,customElements," + + "defaultstatus,defaultStatus,devicePixelRatio," + "dispatchEvent(),document,external,fetch(),find(),focus(),frameElement,frames,getComputedStyle()," + "getMatchedCSSRules(),getSelection(),history," + "indexedDB,innerHeight,innerWidth,isSecureContext,length," + "localStorage,location,locationbar,matchMedia(),menubar,moveBy(),moveTo(),name,navigator,onabort," - + "onanimationend,onanimationiteration,onanimationstart," - + "onauxclick,onbeforeunload,onblur,oncancel,oncanplay,oncanplaythrough," + + "onanimationend,onanimationiteration,onanimationstart,onappinstalled," + + "onauxclick,onbeforeinstallprompt," + + "onbeforeunload,onblur,oncancel,oncanplay,oncanplaythrough," + "onchange,onclick,onclose,oncontextmenu,oncuechange,ondblclick,ondevicemotion,ondeviceorientation," + "ondeviceorientationabsolute,ondrag,ondragend,ondragenter,ondragleave,ondragover,ondragstart,ondrop," + "ondurationchange,onemptied,onended,onerror,onfocus,ongotpointercapture," @@ -685,7 +693,7 @@ + "onpointermove,onpointerout,onpointerover,onpointerup," + "onpopstate,onprogress,onratechange," + "onrejectionhandled,onreset,onresize,onscroll,onsearch," - + "onseeked,onseeking,onselect,onshow,onstalled,onstorage," + + "onseeked,onseeking,onselect,onstalled,onstorage," + "onsubmit,onsuspend,ontimeupdate,ontoggle,ontransitionend,onunhandledrejection," + "onunload,onvolumechange,onwaiting," + "onwebkitanimationend,onwebkitanimationiteration,onwebkitanimationstart,onwebkittransitionend," @@ -695,7 +703,7 @@ + "resizeBy(),resizeTo(),screen,screenLeft,screenTop," + "screenX,screenY,scroll(),scrollbars,scrollBy(),scrollTo(),scrollX,scrollY,self,sessionStorage," + "setInterval(),setTimeout(),sortFunction(),speechSynthesis,status,statusbar,stop(),styleMedia," - + "TEMPORARY,test(),toolbar,top,webkitCancelAnimationFrame()," + + "TEMPORARY,test(),toolbar,top,visualViewport,webkitCancelAnimationFrame()," + "webkitRequestAnimationFrame(),webkitRequestFileSystem()," + "webkitResolveLocalFileSystemURL(),webkitStorageInfo," + "window", @@ -1655,7 +1663,7 @@ + "longDesc,marginHeight,marginWidth,name,referrerPolicy,sandbox,scrolling,src,srcdoc," + "width", CHROME = "align,allow,allowFullscreen,allowPaymentRequest,contentDocument,contentWindow," - + "frameBorder,getSVGDocument(),height," + + "csp,frameBorder,getSVGDocument(),height," + "longDesc,marginHeight,marginWidth,name,referrerPolicy,sandbox,scrolling,src,srcdoc," + "width", IE = "align,border,contentDocument,contentWindow,frameBorder,frameSpacing,getSVGDocument(),height," @@ -2297,6 +2305,7 @@ */ @Test @Alerts(DEFAULT = "async,charset,crossOrigin,defer,event,htmlFor,integrity,src,text,type", + CHROME = "async,charset,crossOrigin,defer,event,htmlFor,integrity,noModule,src,text,type", IE = "async,charset,defer,event,htmlFor,src,text,type", EDGE = "async,charset,defer,event,htmlFor,src,text,type") @NotYetImplemented @@ -3035,7 +3044,7 @@ + "onmouseout,onmouseover,onmouseup,onmousewheel,onpaste,onpause,onplay,onplaying,onpointercancel," + "onpointerdown,onpointerenter,onpointerleave,onpointerlockchange,onpointerlockerror,onpointermove," + "onpointerout,onpointerover,onpointerup,onprogress,onratechange,onreadystatechange,onreset,onresize," - + "onscroll,onsearch,onseeked,onseeking,onselect,onselectionchange,onselectstart,onshow,onstalled," + + "onscroll,onsearch,onseeked,onseeking,onselect,onselectionchange,onselectstart,onstalled," + "onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,onwebkitfullscreenchange," + "onwebkitfullscreenerror,onwheel,open(),origin,plugins,pointerLockElement,preferredStylesheetSet," + "prepend(),queryCommandEnabled(),queryCommandIndeterm(),queryCommandState(),queryCommandSupported()," @@ -3129,7 +3138,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "blur(),dataset,focus(),onabort,onauxclick,onblur,oncancel,oncanplay,oncanplaythrough,onchange," + @Alerts(DEFAULT = "blur(),dataset,focus(),nonce," + + "onabort,onauxclick,onblur,oncancel,oncanplay,oncanplaythrough,onchange," + "onclick,onclose,oncontextmenu,oncuechange,ondblclick,ondrag,ondragend,ondragenter,ondragleave," + "ondragover,ondragstart,ondrop,ondurationchange,onemptied,onended,onerror,onfocus," + "ongotpointercapture,oninput,oninvalid,onkeydown,onkeypress,onkeyup,onload,onloadeddata," @@ -3136,8 +3146,9 @@ + "onloadedmetadata,onloadstart,onlostpointercapture,onmousedown,onmouseenter,onmouseleave,onmousemove," + "onmouseout,onmouseover,onmouseup,onmousewheel,onpause,onplay,onplaying,onpointercancel," + "onpointerdown,onpointerenter,onpointerleave,onpointermove,onpointerout,onpointerover,onpointerup," - + "onprogress,onratechange,onreset,onresize,onscroll,onseeked,onseeking,onselect,onshow,onstalled," - + "onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,ownerSVGElement,style,tabIndex," + + "onprogress,onratechange,onreset,onresize,onscroll,onseeked,onseeking,onselect,onstalled," + + "onsubmit,onsuspend,ontimeupdate,ontoggle,onvolumechange,onwaiting,onwheel," + + "ownerSVGElement,style,tabIndex," + "viewportElement", FF45 = "onabort,onblur,oncanplay,oncanplaythrough,onchange,onclick,oncontextmenu,oncopy,oncut,ondblclick," + "ondrag,ondragend,ondragenter,ondragleave,ondragover,ondragstart,ondrop,ondurationchange," Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java 2017-09-07 18:25:12 UTC (rev 14810) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java 2017-09-08 07:23:42 UTC (rev 14811) @@ -373,9 +373,8 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "function ClientRect() { [native code] }", - IE = "[object ClientRect]", - FF = "exception") + @Alerts(DEFAULT = "exception", + IE = "[object ClientRect]") public void clientRect() throws Exception { test("ClientRect"); } @@ -3391,6 +3390,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMRect() { [native code] }", FF = "function DOMRect() {\n [native code]\n}") public void domRect() throws Exception { test("DOMRect"); @@ -3439,8 +3439,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "function ClientRectList() { [native code] }", - FF = "exception", + @Alerts(DEFAULT = "exception", IE = "[object ClientRectList]") public void clientRectList() throws Exception { test("ClientRectList"); @@ -4487,6 +4486,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMMatrixReadOnly() { [native code] }", FF = "function DOMMatrixReadOnly() {\n [native code]\n}") public void domMatrixReadOnly() throws Exception { test("DOMMatrixReadOnly"); @@ -4741,7 +4741,8 @@ * @throws Exception if the test fails */ @Test - @Alerts("exception") + @Alerts(DEFAULT = "exception", + CHROME = "function NetworkInformation() { [native code] }") public void networkInformation() throws Exception { test("NetworkInformation"); } @@ -5889,6 +5890,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMMatrix() { [native code] }", FF = "function DOMMatrix() {\n [native code]\n}") public void domMatrix() throws Exception { test("DOMMatrix"); @@ -8215,6 +8217,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMPointReadOnly() { [native code] }", FF = "function DOMPointReadOnly() {\n [native code]\n}") public void domPointReadOnly() throws Exception { test("DOMPointReadOnly"); @@ -8245,6 +8248,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMPoint() { [native code] }", FF = "function DOMPoint() {\n [native code]\n}") public void domPoint() throws Exception { test("DOMPoint"); @@ -8283,6 +8287,7 @@ */ @Test @Alerts(DEFAULT = "exception", + CHROME = "function DOMRectReadOnly() { [native code] }", FF = "function DOMRectReadOnly() {\n [native code]\n}") public void domRectReadOnly() throws Exception { test("DOMRectReadOnly"); @@ -9070,7 +9075,7 @@ */ @Test @Alerts(DEFAULT = "exception", - CHROME = "function WebKitCSSMatrix() { [native code] }", + CHROME = "function DOMMatrix() { [native code] }", EDGE = "function WebKitCSSMatrix() { [native code] }", FF52 = "function WebKitCSSMatrix() {\n [native code]\n}") public void webKitCSSMatrix() throws Exception { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-07 18:25:12 UTC (rev 14810) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-08 07:23:42 UTC (rev 14811) @@ -319,8 +319,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "\u0662\u0660\u200F/\u0661\u0662\u200F/\u0662\u0660\u0661\u0662", - FF = "20\u200F/12\u200F/2012", + @Alerts(DEFAULT = "20\u200F/12\u200F/2012", IE = "\u200F20\u200F-\u200F12\u200F-\u200F2012") public void format_ar_dz() throws Exception { test("new Intl.DateTimeFormat('ar-DZ').format(date)"); @@ -380,8 +379,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "\u0662\u0660\u200F/\u0661\u0662\u200F/\u0662\u0660\u0661\u0662", - FF = "20\u200F/12\u200F/2012", + @Alerts(DEFAULT = "20\u200F/12\u200F/2012", IE = "\u200F20\u200F/\u200F12\u200F/\u200F2012") public void format_ar_ly() throws Exception { test("new Intl.DateTimeFormat('ar-LY').format(date)"); @@ -391,8 +389,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "\u0662\u0660\u200F/\u0661\u0662\u200F/\u0662\u0660\u0661\u0662", - FF = "20\u200F/12\u200F/2012", + @Alerts(DEFAULT = "20\u200F/12\u200F/2012", IE = "\u200F20\u200F-\u200F12\u200F-\u200F2012") public void format_ar_ma() throws Exception { test("new Intl.DateTimeFormat('ar-MA').format(date)"); @@ -422,9 +419,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "\u0662\u0660\u200F/\u0661\u0662\u200F/\u0662\u0660\u0661\u0662", - IE = "\u200F\u0660\u0667\u200F/\u200F\u0660\u0662\u200F/\u200F\u0661\u0664\u0663\u0664", - FF = "\u0667\u200F/\u0662\u200F/\u0661\u0664\u0663\u0664 \u0647\u0640") + @Alerts(DEFAULT = "\u0667\u200F/\u0662\u200F/\u0661\u0664\u0663\u0664 \u0647\u0640", + IE = "\u200F\u0660\u0667\u200F/\u200F\u0660\u0662\u200F/\u200F\u0661\u0664\u0663\u0664") public void format_ar_sa() throws Exception { test("new Intl.DateTimeFormat('ar-SA').format(date)"); } @@ -453,8 +449,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "\u0662\u0660\u200F/\u0661\u0662\u200F/\u0662\u0660\u0661\u0662", - FF = "20\u200F/12\u200F/2012", + @Alerts(DEFAULT = "20\u200F/12\u200F/2012", IE = "\u200F20\u200F-\u200F12\u200F-\u200F2012") public void format_ar_tn() throws Exception { test("new Intl.DateTimeFormat('ar-TN').format(date)"); @@ -749,8 +744,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "12/20/2012", - FF = "20/12/2012", + @Alerts(DEFAULT = "20/12/2012", IE = "\u200E20\u200E/\u200E12\u200E/\u200E2012") public void format_en_sg() throws Exception { test("new Intl.DateTimeFormat('en-SG').format(date)"); @@ -810,8 +804,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "20/12/2012", - FF = "20-12-2012", + @Alerts(DEFAULT = "20-12-2012", IE = "\u200E20\u200E-\u200E12\u200E-\u200E2012") public void format_es_cl() throws Exception { test("new Intl.DateTimeFormat('es-CL').format(date)"); @@ -911,8 +904,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "20/12/2012", - FF = "12/20/2012", + @Alerts(DEFAULT = "12/20/2012", IE = "\u200E12\u200E/\u200E20\u200E/\u200E2012") public void format_es_pa() throws Exception { test("new Intl.DateTimeFormat('es-PA').format(date)"); @@ -932,8 +924,7 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "20/12/2012", - FF = "12/20/2012", + @Alerts(DEFAULT = "12/20/2012", IE = "\u200E20\u200E/\u200E12\u200E/\u200E2012") public void format_es_pr() throws Exception { test("new Intl.DateTimeFormat('es-PR').format(date)"); |
From: <rb...@us...> - 2017-09-09 13:46:21
|
Revision: 14815 http://sourceforge.net/p/htmlunit/code/14815 Author: rbri Date: 2017-09-09 13:46:18 +0000 (Sat, 09 Sep 2017) Log Message: ----------- latest chrome (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRect.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRectList.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrix.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrixReadOnly.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPoint.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPointReadOnly.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMRectReadOnly.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRect.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRect.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRect.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -29,10 +29,11 @@ * Specifies a rectangle that contains a line of text in either an element or a TextRange object. * * @author Ahmed Ashour + * @author Ronald Brill * @see <a href="http://msdn2.microsoft.com/en-us/library/ms535906.aspx">MSDN Documentation</a> */ -@JsxClass({CHROME, IE, EDGE}) -@JsxClass(className = "DOMRect", value = FF) +@JsxClass({IE, EDGE}) +@JsxClass(className = "DOMRect", value = {CHROME, FF}) public class ClientRect extends SimpleScriptable { private int bottom_; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRectList.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRectList.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ClientRectList.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -39,8 +39,9 @@ * @author Ahmed Ashour * @author Ronald Brill */ +@JsxClass(className = "DOMRectList", isJSObject = false, value = CHROME) @JsxClass(isJSObject = false, value = FF) -@JsxClass({CHROME, IE, EDGE}) +@JsxClass({IE, EDGE}) public class ClientRectList extends SimpleScriptable { private final List<ClientRect> clientRects_; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrix.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrix.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrix.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; @@ -23,8 +24,9 @@ * A JavaScript object for {@code DOMMatrix}. * * @author Ahmed Ashour + * @author Ronald Brill */ -@JsxClass(FF) +@JsxClass({CHROME, FF}) public class DOMMatrix extends DOMMatrixReadOnly { /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrixReadOnly.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrixReadOnly.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMMatrixReadOnly.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; @@ -24,8 +25,9 @@ * A JavaScript object for {@code DOMMatrixReadOnly}. * * @author Ahmed Ashour + * @author Ronald Brill */ -@JsxClass(FF) +@JsxClass({CHROME, FF}) public class DOMMatrixReadOnly extends SimpleScriptable { /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPoint.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPoint.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPoint.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; @@ -23,8 +24,9 @@ * A JavaScript object for {@code DOMPoint}. * * @author Ahmed Ashour + * @author Ronald Brill */ -@JsxClass(FF) +@JsxClass({CHROME, FF}) public class DOMPoint extends DOMPointReadOnly { /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPointReadOnly.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPointReadOnly.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMPointReadOnly.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; @@ -24,8 +25,9 @@ * A JavaScript object for {@code DOMPointReadOnly}. * * @author Ahmed Ashour + * @author Ronald Brill */ -@JsxClass(FF) +@JsxClass({CHROME, FF}) public class DOMPointReadOnly extends SimpleScriptable { /** Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMRectReadOnly.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMRectReadOnly.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/DOMRectReadOnly.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.dom; +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; @@ -24,8 +25,9 @@ * A JavaScript object for {@code DOMRectReadOnly}. * * @author Ahmed Ashour + * @author Ronald Brill */ -@JsxClass(FF) +@JsxClass({CHROME, FF}) public class DOMRectReadOnly extends SimpleScriptable { /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostClassNameTest.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -496,7 +496,8 @@ * @throws Exception if an error occurs */ @Test - @Alerts("exception") + @Alerts(DEFAULT = "exception", + FF = "function DOMRectList() {\n [native code]\n}") public void domRectList() throws Exception { test("DOMRectList"); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -6439,7 +6439,7 @@ */ @Test @Alerts(DEFAULT = "function", - FF = "undefined") + IE = "undefined") public void domPoint() throws Exception { test("DOMPoint"); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java 2017-09-09 10:33:03 UTC (rev 14814) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/property/ElementOffsetWidthTest.java 2017-09-09 13:46:18 UTC (rev 14815) @@ -918,7 +918,7 @@ @Test @Alerts(DEFAULT = "-16", IE = "8") - @NotYetImplemented({CHROME, IE}) + @NotYetImplemented(IE) public void legend() throws Exception { loadPageWithAlerts2(test("legend")); } |
From: <rb...@us...> - 2017-09-09 14:52:41
|
Revision: 14818 http://sourceforge.net/p/htmlunit/code/14818 Author: rbri Date: 2017-09-09 14:52:38 +0000 (Sat, 09 Sep 2017) Log Message: ----------- latest chrome (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DefaultDateTimeFormatter.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/GAEDateTimeFormatter.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-09-09 14:29:22 UTC (rev 14817) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-09-09 14:52:38 UTC (rev 14818) @@ -671,10 +671,6 @@ @BrowserFeature(FF45) JS_CSS_MOZ_CSS_KEYFRAMES_RULE, - /** {@link DateTimeFormat} uses the Ascii digits for {@code ar-DZ} locale. */ - @BrowserFeature({FF, IE}) - JS_DATE_AR_DZ_ASCII_DIGITS, - /** <code>Date.toLocaleDateString()</code> returns a short form (d.M.yyyy). */ @BrowserFeature({CHROME, FF}) JS_DATE_LOCALE_DATE_SHORT, Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java 2017-09-09 14:29:22 UTC (rev 14817) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java 2017-09-09 14:52:38 UTC (rev 14818) @@ -154,10 +154,6 @@ CHROME_FORMATS_.put("en-CA", yyyyDash); CHROME_FORMATS_.put("en-IE", mmSlash); CHROME_FORMATS_.put("en-MT", mmSlash); - CHROME_FORMATS_.put("en-SG", mmSlash); - CHROME_FORMATS_.put("es-CL", ddSlash); - CHROME_FORMATS_.put("es-PA", ddSlash); - CHROME_FORMATS_.put("es-PR", ddSlash); CHROME_FORMATS_.put("es-US", ddSlash); CHROME_FORMATS_.put("fr", ddSlash); CHROME_FORMATS_.put("fr-CH", ddDot); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DefaultDateTimeFormatter.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DefaultDateTimeFormatter.java 2017-09-09 14:29:22 UTC (rev 14817) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DefaultDateTimeFormatter.java 2017-09-09 14:52:38 UTC (rev 14818) @@ -14,7 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.intl; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DATE_AR_DZ_ASCII_DIGITS; import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DATE_WITH_LEFT_TO_RIGHT_MARK; import java.time.ZoneId; @@ -42,11 +41,10 @@ DefaultDateTimeFormatter(final String locale, final BrowserVersion browserVersion, final String pattern) { formatter_ = DateTimeFormatter.ofPattern(pattern); if (locale.startsWith("ar") - && (!browserVersion.hasFeature(JS_DATE_AR_DZ_ASCII_DIGITS) - || (!"ar-DZ".equals(locale) + && (!"ar-DZ".equals(locale) && !"ar-LY".equals(locale) && !"ar-MA".equals(locale) - && !"ar-TN".equals(locale)))) { + && !"ar-TN".equals(locale))) { final DecimalStyle decimalStyle = DecimalStyle.STANDARD.withZeroDigit('\u0660'); formatter_ = formatter_.withDecimalStyle(decimalStyle); } @@ -63,9 +61,7 @@ break; case "ar-SA": - if (browserVersion.hasFeature(JS_DATE_AR_DZ_ASCII_DIGITS)) { - chronology_ = HijrahChronology.INSTANCE; - } + chronology_ = HijrahChronology.INSTANCE; break; case "ar-SD": Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/GAEDateTimeFormatter.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/GAEDateTimeFormatter.java 2017-09-09 14:29:22 UTC (rev 14817) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/GAEDateTimeFormatter.java 2017-09-09 14:52:38 UTC (rev 14818) @@ -14,8 +14,6 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.intl; -import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_DATE_AR_DZ_ASCII_DIGITS; - import java.text.DateFormat; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; @@ -39,11 +37,10 @@ GAEDateTimeFormatter(final String locale, final BrowserVersion browserVersion, final String pattern) { format_ = new SimpleDateFormat(pattern); if (locale.startsWith("ar") - && (!browserVersion.hasFeature(JS_DATE_AR_DZ_ASCII_DIGITS) - || (!"ar-DZ".equals(locale) - && !"ar-LY".equals(locale) - && !"ar-MA".equals(locale) - && !"ar-TN".equals(locale)))) { + && (!"ar-DZ".equals(locale) + && !"ar-LY".equals(locale) + && !"ar-MA".equals(locale) + && !"ar-TN".equals(locale))) { setZeroDigit('\u0660'); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-09 14:29:22 UTC (rev 14817) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-09 14:52:38 UTC (rev 14818) @@ -421,6 +421,7 @@ @Test @Alerts(DEFAULT = "\u0667\u200F/\u0662\u200F/\u0661\u0664\u0663\u0664 \u0647\u0640", IE = "\u200F\u0660\u0667\u200F/\u200F\u0660\u0662\u200F/\u200F\u0661\u0664\u0663\u0664") + @NotYetImplemented(CHROME) public void format_ar_sa() throws Exception { test("new Intl.DateTimeFormat('ar-SA').format(date)"); } |
From: <rb...@us...> - 2017-09-09 18:31:28
|
Revision: 14819 http://sourceforge.net/p/htmlunit/code/14819 Author: rbri Date: 2017-09-09 18:31:25 +0000 (Sat, 09 Sep 2017) Log Message: ----------- NetworkInformation added Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/package-info.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformationTest.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 2017-09-09 14:52:38 UTC (rev 14818) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/configuration/JavaScriptConfiguration.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -381,6 +381,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.media.rtc.mozRTCSessionDescription; import com.gargoylesoftware.htmlunit.javascript.host.media.rtc.webkitRTCPeerConnection; import com.gargoylesoftware.htmlunit.javascript.host.moz.MozPowerManager; +import com.gargoylesoftware.htmlunit.javascript.host.network.NetworkInformation; import com.gargoylesoftware.htmlunit.javascript.host.payment.PaymentAddress; import com.gargoylesoftware.htmlunit.javascript.host.payment.PaymentRequest; import com.gargoylesoftware.htmlunit.javascript.host.payment.PaymentResponse; @@ -526,7 +527,8 @@ mozRTCPeerConnection.class, mozRTCSessionDescription.class, MozSettingsEvent.class, MSGestureEvent.class, MutationEvent.class, MutationObserver.class, MutationRecord.class, NamedNodeMap.class, Namespace.class, - NamespaceCollection.class, Navigator.class, Node.class, NodeFilter.class, NodeIterator.class, + NamespaceCollection.class, + Navigator.class, NetworkInformation.class, Node.class, NodeFilter.class, NodeIterator.class, NodeList.class, Notification.class, OES_element_index_uint.class, OES_standard_derivatives.class, OES_texture_float.class, OES_texture_float_linear.class, OfflineAudioCompletionEvent.class, OfflineAudioContext.class, Option.class, OscillatorNode.class, PageTransitionEvent.class, PannerNode.class, 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 2017-09-09 14:52:38 UTC (rev 14818) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -26,6 +26,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.host.geo.Geolocation; +import com.gargoylesoftware.htmlunit.javascript.host.network.NetworkInformation; /** * A JavaScript object for {@code Navigator}. @@ -315,4 +316,16 @@ public String getOscpu() { return "Windows NT 6.1"; } + + /** + * Returns the {@code connection} property. + * @return the {@code connection} property + */ + @JsxGetter(CHROME) + public NetworkInformation getConnection() { + final NetworkInformation networkInformation = new NetworkInformation(); + networkInformation.setPrototype(getPrototype(networkInformation.getClass())); + networkInformation.setParentScope(getParentScope()); + return networkInformation; + } } Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2002-2017 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.network; + +import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; + +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.JsxGetter; + +/** + * A JavaScript object for {@code NetworkInformation}. + * + * @author Ronald Brill + */ +@JsxClass(CHROME) +public class NetworkInformation extends SimpleScriptable { + + /** + * Creates an instance. + */ + @JsxConstructor + public NetworkInformation() { + } + + /** + * @return the {@code downlink} property + */ + @JsxGetter + public double getDownlink() { + return 1.95d; + } + + /** + * @return the {@code effectiveType} property + */ + @JsxGetter + public String getEffectiveType() { + return "4g"; + } + + /** + * @return the {@code rtt} property + */ + @JsxGetter + public int getRtt() { + return 125; + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/package-info.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/package-info.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/package-info.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2002-2017 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. + */ + +/** + * Implementations of the NetworkInformation JavaScript host objects - users of HtmlUnit shouldn't + * need anything in this package. + */ +package com.gargoylesoftware.htmlunit.javascript.host.network; Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/package-info.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-09-09 14:52:38 UTC (rev 14818) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -23,6 +23,7 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; import com.gargoylesoftware.htmlunit.PluginConfiguration; import com.gargoylesoftware.htmlunit.WebDriverTestCase; @@ -437,4 +438,26 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"undefined", "undefined", "undefined"}, + CHROME = {"[object NetworkInformation]", "undefined", "undefined"}) + public void connection() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(navigator.connection);\n" + + " alert(navigator.mozConnection);\n" + + " alert(navigator.webkitConnection);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformationTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformationTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformationTest.java 2017-09-09 18:31:25 UTC (rev 14819) @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2002-2017 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.network; + +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; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link NetworkInformation}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class NetworkInformationTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"undefined", "undefined", "undefined"}, + CHROME = {"[object NetworkInformation]", "undefined", "undefined"}) + public void navigatorConnection() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(navigator.connection);\n" + + " alert(navigator.mozConnection);\n" + + " alert(navigator.webkitConnection);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no connection", + CHROME = "undefined") + public void type() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;\n" + + " if (connection) {" + + " alert(connection.type);\n" + + " } else {\n" + + " alert('no connection');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no connection", + CHROME = "undefined") + public void downlinkMax() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;\n" + + " if (connection) {" + + " alert(connection.downlinkMax);\n" + + " } else {\n" + + " alert('no connection');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no connection", + CHROME = "4g") + public void effectiveType() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;\n" + + " if (connection) {" + + " alert(connection.effectiveType);\n" + + " } else {\n" + + " alert('no connection');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no connection", + CHROME = "1.95") + public void downlink() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;\n" + + " if (connection) {" + + " alert(connection.downlink);\n" + + " } else {\n" + + " alert('no connection');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "no connection", + CHROME = "125") + public void rtt() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;\n" + + " if (connection) {" + + " alert(connection.rtt);\n" + + " } else {\n" + + " alert('no connection');\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformationTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |
From: <rb...@us...> - 2017-09-09 18:33:18
|
Revision: 14820 http://sourceforge.net/p/htmlunit/code/14820 Author: rbri Date: 2017-09-09 18:33:15 +0000 (Sat, 09 Sep 2017) Log Message: ----------- NetworkInformation added Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-09 18:31:25 UTC (rev 14819) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-09 18:33:15 UTC (rev 14820) @@ -7,7 +7,10 @@ </properties> <body> - <release version="2.28" date="???" description="Bugfixes, Chrome 60"> + <release version="2.28" date="???" description="Bugfixes, Chrome 61"> + <action type="add" dev="rbri"> + JavaScript: support NetworkInformation (Chrome only at the moment). + </action> <action type="add" dev="rbri" issue="1913"> JavaScript: support FileReader.readAsArrayBuffer(). </action> Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java 2017-09-09 18:31:25 UTC (rev 14819) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/HostTypeOfTest.java 2017-09-09 18:33:15 UTC (rev 14820) @@ -449,9 +449,21 @@ } /** + * Test {@link com.gargoylesoftware.htmlunit.javascript.host.ClientRect}. + * * @throws Exception if an error occurs */ @Test + @Alerts(DEFAULT = "function", + IE = "undefined") + public void domRect() throws Exception { + test("DOMRect"); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts(DEFAULT = "undefined", FF = "function") public void domRectList() throws Exception { @@ -3139,18 +3151,6 @@ } /** - * Test {@link com.gargoylesoftware.htmlunit.javascript.host.ClientRect}. - * - * @throws Exception if an error occurs - */ - @Test - @Alerts(DEFAULT = "function", - IE = "undefined") - public void domRect() throws Exception { - test("DOMRect"); - } - - /** * Test {@link com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleDeclaration}. * * @throws Exception if an error occurs |
From: <rb...@us...> - 2017-09-10 10:18:37
|
Revision: 14822 http://sourceforge.net/p/htmlunit/code/14822 Author: rbri Date: 2017-09-10 10:18:34 +0000 (Sun, 10 Sep 2017) Log Message: ----------- document.createElementNS is now able to create svg elements also Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-10 08:00:04 UTC (rev 14821) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-10 10:18:34 UTC (rev 14822) @@ -8,6 +8,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> + <action type="fix" dev="rbri"> + JavaScript: document.createElementNS is now able to create svg elements also. + </action> <action type="add" dev="rbri"> JavaScript: support NetworkInformation (Chrome only at the moment). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2017-09-10 08:00:04 UTC (rev 14821) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HTMLParser.java 2017-09-10 10:18:34 UTC (rev 14822) @@ -365,9 +365,9 @@ } if (namespaceURI == null || namespaceURI.isEmpty() - || !qualifiedName.contains(":") - || namespaceURI.equals(XHTML_NAMESPACE) - || namespaceURI.equals(SVG_NAMESPACE)) { + || XHTML_NAMESPACE.equals(namespaceURI) + || SVG_NAMESPACE.equals(namespaceURI) + || !qualifiedName.contains(":")) { String tagName = qualifiedName; final int index = tagName.indexOf(':'); @@ -377,7 +377,13 @@ else { tagName = tagName.substring(index + 1); } - final ElementFactory factory = ELEMENT_FACTORIES.get(tagName); + final ElementFactory factory; + if (!"svg".equals(tagName) && SVG_NAMESPACE.equals(namespaceURI)) { + factory = SVG_FACTORY; + } + else { + factory = ELEMENT_FACTORIES.get(tagName); + } if (factory != null) { return factory; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java 2017-09-10 08:00:04 UTC (rev 14821) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentTest.java 2017-09-10 10:18:34 UTC (rev 14822) @@ -350,6 +350,25 @@ * @throws Exception if the test fails */ @Test + @Alerts("[object SVGRectElement]") + public void createElementNS() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(document.createElementNS('http://www.w3.org/2000/svg', 'rect'));\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts("exception") public void createDocumentNS_xul() throws Exception { final String html = "<html><body>\n" |
From: <rb...@us...> - 2017-09-10 11:33:54
|
Revision: 14823 http://sourceforge.net/p/htmlunit/code/14823 Author: rbri Date: 2017-09-10 11:33:51 +0000 (Sun, 10 Sep 2017) Log Message: ----------- getComputedTextLength() support added for svg text elements Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElement.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTSpanElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElementTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextPathElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-10 10:18:34 UTC (rev 14822) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-10 11:33:51 UTC (rev 14823) @@ -8,6 +8,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> + <action type="add" dev="rbri"> + JavaScript: getComputedTextLength() support added for svg text elements. + </action> <action type="fix" dev="rbri"> JavaScript: document.createElementNS is now able to create svg elements also. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElement.java 2017-09-10 10:18:34 UTC (rev 14822) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElement.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -21,11 +21,13 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstant; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; /** * A JavaScript object for {@code SVGTextContentElement}. * * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass public class SVGTextContentElement extends SVGGraphicsElement { @@ -47,4 +49,12 @@ public SVGTextContentElement() { } + /** + * @return the length of the text + */ + @JsxFunction + public float getComputedTextLength() { + // just a fake for the moment + return 1.0f; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElement.java 2017-09-10 10:18:34 UTC (rev 14822) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElement.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -26,6 +26,7 @@ * A JavaScript object for {@code SVGTextElement}. * * @author Ahmed Ashour + * @author Ronald Brill */ @JsxClass(domClass = SvgText.class) public class SVGTextElement extends SVGTextPositioningElement { Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTSpanElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTSpanElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTSpanElementTest.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2002-2017 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.svg; + +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.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link SVGTextElement}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class SVGTSpanElementTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SVGTSpanElement]", + FF = "function SVGTSpanElement() {\n [native code]\n}", + CHROME = "function SVGTSpanElement() { [native code] }") + public void simpleScriptable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(window.SVGTSpanElement);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object SVGTSpanElement]", "true"}) + public void getComputedTextLengthAvailable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGPathElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " alert(text.getComputedTextLength() > 0);\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <text fill='limegreen' font-size='20'>\n" + + " <tSpan id='myId'x='50' y='50 55 60 60 60 55 50 45 40 35 30 25'>SVG forever!</tSpan>\n" + + " </text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object SVGTSpanElement]", "109.4"}) + @NotYetImplemented + public void getComputedTextLength() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGTextElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " var length = text.getComputedTextLength();\n" + + " alert(length.toFixed(1));\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <text fill='limegreen' font-size='20'>\n" + + " <tSpan id='myId'x='50' y='50 55 60 60 60 55 50 45 40 35 30 25'>SVG forever!</tSpan>\n" + + " </text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTSpanElementTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElementTest.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2002-2017 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.svg; + +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; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link SVGTextContentElement}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class SVGTextContentElementTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SVGTextContentElement]", + FF = "function SVGTextContentElement() {\n [native code]\n}", + CHROME = "function SVGTextContentElement() { [native code] }") + public void simpleScriptable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(window.SVGTextContentElement);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextContentElementTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElementTest.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2002-2017 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.svg; + +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.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link SVGTextElement}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class SVGTextElementTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SVGTextElement]", + FF = "function SVGTextElement() {\n [native code]\n}", + CHROME = "function SVGTextElement() { [native code] }") + public void simpleScriptable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(window.SVGTextElement);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object SVGTextElement]", "true"}) + public void getComputedTextLengthAvailable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGPathElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " alert(text.getComputedTextLength() > 0);\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <text id='myId' x='0' y='4' fill='orange'>HtmlUnit is great!</text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object SVGTextElement]", "117.3"}) + @NotYetImplemented + public void getComputedTextLength() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGTextElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " var length = text.getComputedTextLength();\n" + + " alert(length.toFixed(1));\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <text id='myId' x='0' y='4' fill='orange'>HtmlUnit is great!</text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextElementTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextPathElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextPathElementTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextPathElementTest.java 2017-09-10 11:33:51 UTC (rev 14823) @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2002-2017 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.svg; + +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.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; + +/** + * Tests for {@link SVGTextPathElement}. + * + * @author Ronald Brill + */ +@RunWith(BrowserRunner.class) +public class SVGTextPathElementTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = "[object SVGTextPathElement]", + FF = "function SVGTextPathElement() {\n [native code]\n}", + CHROME = "function SVGTextPathElement() { [native code] }") + public void simpleScriptable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(window.SVGTextPathElement);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({"[object SVGTextPathElement]", "true"}) + public void getComputedTextLengthAvailable() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGPathElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " alert(text.getComputedTextLength() > 0);\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <defs>\n" + + " <path id='myTextPath' d='M 50,100 Q 150,50 250,100' />\n" + + " </defs>\n" + + " <text fill='steelblue' font-size='20'>\n" + + " <textPath id='myId' xlink:href='#myTextPath'>Heho</textPath>\n" + + " </text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = {"[object SVGTextPathElement]", "43.3"}, + IE = {"[object SVGTextPathElement]", "49.3"}) + @NotYetImplemented + public void getComputedTextLength() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " if (window.SVGTextElement) {\n" + + " var text = document.getElementById('myId');\n" + + " alert(text);\n" + + " var length = text.getComputedTextLength();\n" + + " alert(length.toFixed(1));\n" + + " }\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<svg width='100%' height='100%' viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'>\n" + + " <defs>\n" + + " <path id='myTextPath' d='M 50,100 Q 150,50 250,100' />\n" + + " </defs>\n" + + " <text fill='steelblue' font-size='20'>\n" + + " <textPath id='myId' xlink:href='#myTextPath'>Heho</textPath>\n" + + " </text>\n" + + "</svg>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/svg/SVGTextPathElementTest.java ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property |
From: <rb...@us...> - 2017-09-10 12:28:26
|
Revision: 14824 http://sourceforge.net/p/htmlunit/code/14824 Author: rbri Date: 2017-09-10 12:28:24 +0000 (Sun, 10 Sep 2017) Log Message: ----------- relax required types Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob2.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPageTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-09-10 11:33:51 UTC (rev 14823) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2017-09-10 12:28:24 UTC (rev 14824) @@ -363,7 +363,7 @@ * @return the <tt>body</tt> element (or <tt>frameset</tt> element), or {@code null} if it does not yet exist */ public HtmlElement getBody() { - final HtmlElement doc = getDocumentElement(); + final DomElement doc = getDocumentElement(); if (doc != null) { for (final DomNode node : doc.getChildren()) { if (node instanceof HtmlBody || node instanceof HtmlFrameSet) { @@ -379,7 +379,7 @@ * @return the head element */ public HtmlElement getHead() { - final HtmlElement doc = getDocumentElement(); + final DomElement doc = getDocumentElement(); if (doc != null) { for (final DomNode node : doc.getChildren()) { if (node instanceof HtmlHead) { @@ -1217,7 +1217,7 @@ // Execute the specified event on the document element. final WebWindow window = getEnclosingWindow(); if (window.getScriptableObject() instanceof Window) { - final HtmlElement element = getDocumentElement(); + final DomElement element = getDocumentElement(); if (element == null) { // happens for instance if document.documentElement has been removed from parent return true; } @@ -1234,7 +1234,7 @@ } } if (window.getScriptableObject() instanceof Global) { - final HtmlElement element = getDocumentElement(); + final DomElement element = getDocumentElement(); if (element == null) { // happens for instance if document.documentElement has been removed from parent return true; } @@ -1503,7 +1503,7 @@ return; } if (hasFeature(JS_DEFERRED)) { - final HtmlElement doc = getDocumentElement(); + final DomElement doc = getDocumentElement(); final List<HtmlElement> elements = doc.getElementsByTagName("script"); for (final HtmlElement e : elements) { if (e instanceof HtmlScript) { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob.java 2017-09-10 11:33:51 UTC (rev 14823) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob.java 2017-09-10 12:28:24 UTC (rev 14824) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.background; import com.gargoylesoftware.htmlunit.WebWindow; -import com.gargoylesoftware.htmlunit.html.HtmlElement; +import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -47,7 +47,7 @@ /** {@inheritDoc} */ @Override protected void runJavaScript(final HtmlPage page) { - final HtmlElement doc = page.getDocumentElement(); + final DomElement doc = page.getDocumentElement(); final Scriptable scriptable = page.getEnclosingWindow().getScriptableObject(); page.executeJavaScriptFunction(function_, scriptable, new Object[0], doc); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob2.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob2.java 2017-09-10 11:33:51 UTC (rev 14823) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/JavaScriptFunctionJob2.java 2017-09-10 12:28:24 UTC (rev 14824) @@ -15,7 +15,7 @@ package com.gargoylesoftware.htmlunit.javascript.background; import com.gargoylesoftware.htmlunit.WebWindow; -import com.gargoylesoftware.htmlunit.html.HtmlElement; +import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.js.nashorn.internal.objects.Global; import com.gargoylesoftware.js.nashorn.internal.runtime.Context; @@ -51,7 +51,7 @@ /** {@inheritDoc} */ @Override protected void runJavaScript(final HtmlPage page) { - final HtmlElement doc = page.getDocumentElement(); + final DomElement doc = page.getDocumentElement(); final Global oldGlobal = Context.getGlobal(); final Global global = page.getEnclosingWindow().getScriptableObject(); try { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPageTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPageTest.java 2017-09-10 11:33:51 UTC (rev 14823) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlPageTest.java 2017-09-10 12:28:24 UTC (rev 14824) @@ -886,7 +886,7 @@ + "</body></html>"; final HtmlPage page = loadPage(htmlContent); - final HtmlElement root = page.getDocumentElement(); + final DomElement root = page.getDocumentElement(); assertNotNull(root); assertEquals("html", root.getTagName()); @@ -904,7 +904,7 @@ + "</body></html>"; final HtmlPage page = loadPage(htmlContent); - final HtmlElement root = page.getDocumentElement(); + final DomElement root = page.getDocumentElement(); assertEquals(org.w3c.dom.Node.DOCUMENT_NODE, page.getNodeType()); assertEquals(org.w3c.dom.Node.ELEMENT_NODE, root.getNodeType()); @@ -1393,8 +1393,8 @@ final HtmlPage page = loadPage(content); final HtmlPage clone = page.cloneNode(true); assertTrue(page != clone); - final HtmlElement doc = page.getDocumentElement(); - final HtmlElement docclone = clone.getDocumentElement(); + final DomElement doc = page.getDocumentElement(); + final DomElement docclone = clone.getDocumentElement(); assertTrue(doc != docclone); } |
From: <asa...@us...> - 2017-09-11 07:08:07
|
Revision: 14828 http://sourceforge.net/p/htmlunit/code/14828 Author: asashour Date: 2017-09-11 07:08:04 +0000 (Mon, 11 Sep 2017) Log Message: ----------- Fix DateTimeFormat ar-SA. Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java 2017-09-10 16:28:41 UTC (rev 14827) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormat.java 2017-09-11 07:08:04 UTC (rev 14828) @@ -67,6 +67,7 @@ FF_45_FORMATS_.put("", mmSlash); FF_45_FORMATS_.put("ar", "dd\u200F/MM\u200F/YYYY"); + FF_45_FORMATS_.put("ar-SA", "d\u200F/M\u200F/YYYY هـ"); FF_45_FORMATS_.put("ban", ddDot); FF_45_FORMATS_.put("be", ddDot); FF_45_FORMATS_.put("bg", ddDot + "\u200E \u0433."); @@ -131,7 +132,6 @@ CHROME_FORMATS_.putAll(FF_45_FORMATS_); IE_FORMATS_.putAll(FF_45_FORMATS_); - FF_45_FORMATS_.put("ar-SA", "d\u200F/M\u200F/YYYY هـ"); FF_45_FORMATS_.put("en-CA", yyyyDash); FF_45_FORMATS_.put("en-PH", ddSlash); FF_45_FORMATS_.put("es-US", ddSlash); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-10 16:28:41 UTC (rev 14827) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/intl/DateTimeFormatTest.java 2017-09-11 07:08:04 UTC (rev 14828) @@ -421,7 +421,6 @@ @Test @Alerts(DEFAULT = "\u0667\u200F/\u0662\u200F/\u0661\u0664\u0663\u0664 \u0647\u0640", IE = "\u200F\u0660\u0667\u200F/\u200F\u0660\u0662\u200F/\u200F\u0661\u0664\u0663\u0664") - @NotYetImplemented(CHROME) public void format_ar_sa() throws Exception { test("new Intl.DateTimeFormat('ar-SA').format(date)"); } |
From: <rb...@us...> - 2017-09-11 18:36:25
|
Revision: 14830 http://sourceforge.net/p/htmlunit/code/14830 Author: rbri Date: 2017-09-11 18:36:22 +0000 (Mon, 11 Sep 2017) Log Message: ----------- latest chrome (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfDTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java 2017-09-11 16:39:09 UTC (rev 14829) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/network/NetworkInformation.java 2017-09-11 18:36:22 UTC (rev 14830) @@ -16,10 +16,10 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME; -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.JsxGetter; +import com.gargoylesoftware.htmlunit.javascript.host.event.EventTarget; /** * A JavaScript object for {@code NetworkInformation}. @@ -27,7 +27,7 @@ * @author Ronald Brill */ @JsxClass(CHROME) -public class NetworkInformation extends SimpleScriptable { +public class NetworkInformation extends EventTarget { /** * Creates an instance. Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfDTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfDTest.java 2017-09-11 16:39:09 UTC (rev 14829) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/general/huge/HostParentOfDTest.java 2017-09-11 18:36:22 UTC (rev 14830) @@ -34,6 +34,7 @@ * This class handles all host names which starts by character 'D' to 'E'. * * @author Ahmed Ashour + * @author Ronald Brill */ @RunWith(BrowserParameterizedRunner.class) public class HostParentOfDTest extends HostParentOf { @@ -247,8 +248,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMMatrix_DOMMatrix() throws Exception { test("DOMMatrix", "DOMMatrix"); } @@ -258,6 +259,7 @@ */ @Test @Alerts(DEFAULT = "false", + CHROME = "true", FF52 = "true") @NotYetImplemented(FF52) public void _DOMMatrix_WebKitCSSMatrix() throws Exception { @@ -268,8 +270,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMMatrixReadOnly_DOMMatrix() throws Exception { test("DOMMatrixReadOnly", "DOMMatrix"); } @@ -278,8 +280,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMMatrixReadOnly_DOMMatrixReadOnly() throws Exception { test("DOMMatrixReadOnly", "DOMMatrixReadOnly"); } @@ -289,6 +291,7 @@ */ @Test @Alerts(DEFAULT = "false", + CHROME = "true", FF52 = "true") @NotYetImplemented(FF52) public void _DOMMatrixReadOnly_WebKitCSSMatrix() throws Exception { @@ -308,8 +311,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMPoint_DOMPoint() throws Exception { test("DOMPoint", "DOMPoint"); } @@ -318,8 +321,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMPointReadOnly_DOMPoint() throws Exception { test("DOMPointReadOnly", "DOMPoint"); } @@ -328,8 +331,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMPointReadOnly_DOMPointReadOnly() throws Exception { test("DOMPointReadOnly", "DOMPointReadOnly"); } @@ -338,8 +341,8 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = "false", - FF = "true") + @Alerts(DEFAULT = "true", + IE = "false") public void _DOMRectReadOnly_DOMRectReadOnly() throws Exception { test("DOMRectReadOnly", "DOMRectReadOnly"); } @@ -3982,6 +3985,16 @@ * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = "false", + CHROME = "true") + public void _EventTarget_NetworkInformation() throws Exception { + test("EventTarget", "NetworkInformation"); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = "true", IE = "false") public void _EventTarget_Node() throws Exception { @@ -5182,5 +5195,4 @@ public void _External_External() throws Exception { test("External", "External"); } - } |
From: <rb...@us...> - 2017-09-18 06:31:41
|
Revision: 14839 http://sourceforge.net/p/htmlunit/code/14839 Author: rbri Date: 2017-09-18 06:31:38 +0000 (Mon, 18 Sep 2017) Log Message: ----------- fix handling of negative buffer sizes for the ArrayBuffer ctor Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-15 11:24:48 UTC (rev 14838) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-18 06:31:38 UTC (rev 14839) @@ -8,6 +8,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> + <action type="fix" dev="rbri"> + JavaScript: fix handling of negative buffer sizes for the ArrayBuffer ctor. + </action> <action type="add" dev="rbri"> JavaScript: getComputedTextLength() support added for svg text elements. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2017-09-15 11:24:48 UTC (rev 14838) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBuffer.java 2017-09-18 06:31:38 UTC (rev 14839) @@ -21,6 +21,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import net.sourceforge.htmlunit.corejs.javascript.Context; +import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; import net.sourceforge.htmlunit.corejs.javascript.Undefined; /** @@ -55,6 +56,9 @@ */ @JsxConstructor public void constructor(final int length) { + if (length < 0) { + throw ScriptRuntime.rangeError("invalid array length '" + length + "'."); + } bytes_ = new byte[length]; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferTest.java 2017-09-15 11:24:48 UTC (rev 14838) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/arrays/ArrayBufferTest.java 2017-09-18 06:31:38 UTC (rev 14839) @@ -38,6 +38,44 @@ * @throws Exception if the test fails */ @Test + @Alerts("0") + public void ctorLengthZero() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " var buff = new ArrayBuffer(0);\n" + + " alert(buff.byteLength);\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("exception true") + public void ctorLengthNegative() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " try {\n" + + " var buff = new ArrayBuffer(-1);\n" + + " alert(buff.byteLength);\n" + + " } catch(e) { alert('exception ' + (e instanceof RangeError)); }" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts("5") public void byteLength() throws Exception { final String html |
From: <rb...@us...> - 2017-09-28 05:39:40
|
Revision: 14848 http://sourceforge.net/p/htmlunit/code/14848 Author: rbri Date: 2017-09-28 05:39:37 +0000 (Thu, 28 Sep 2017) Log Message: ----------- fix for a strange side effect in Range.getClientRects() and Range.getBoundingClientRect(). Both calls have removed all nodes inside the range from the document. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/impl/SimpleRange.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Range.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/RangeTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-22 17:37:10 UTC (rev 14847) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-28 05:39:37 UTC (rev 14848) @@ -9,6 +9,10 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> <action type="fix" dev="rbri"> + JavaScript: fix for a strange side effect in Range.getClientRects() and Range.getBoundingClientRect(). + Both calls have removed all nodes inside the range from the document. + </action> + <action type="fix" dev="rbri"> JavaScript: fix handling of negative buffer sizes for the ArrayBuffer ctor. </action> <action type="add" dev="rbri"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/impl/SimpleRange.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/impl/SimpleRange.java 2017-09-22 17:37:10 UTC (rev 14847) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/impl/SimpleRange.java 2017-09-28 05:39:37 UTC (rev 14848) @@ -15,7 +15,9 @@ package com.gargoylesoftware.htmlunit.html.impl; import java.io.Serializable; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; @@ -587,4 +589,66 @@ private static int getMaxOffset(final Node node) { return isOffsetChars(node) ? getText(node).length() : node.getChildNodes().getLength(); } + + /** + * @return a list with all nodes contained in this range + */ + public List<DomNode> containedNodes() { + final List<DomNode> nodes = new ArrayList<>(); + final DomNode ancestor = (DomNode) getCommonAncestorContainer(); + if (ancestor == null) { + return nodes; + } + + final DomNode start; + final DomNode end; + if (isOffsetChars(startContainer_)) { + start = (DomNode) startContainer_; + String text = getText(start); + if (startOffset_ > -1 && startOffset_ < text.length()) { + text = text.substring(0, startOffset_); + } + setText(start, text); + } + else if (startContainer_.getChildNodes().getLength() > startOffset_) { + start = (DomNode) startContainer_.getChildNodes().item(startOffset_); + } + else { + start = (DomNode) startContainer_.getNextSibling(); + } + if (isOffsetChars(endContainer_)) { + end = (DomNode) endContainer_; + String text = getText(end); + if (endOffset_ > -1 && endOffset_ < text.length()) { + text = text.substring(endOffset_); + } + setText(end, text); + } + else if (endContainer_.getChildNodes().getLength() > endOffset_) { + end = (DomNode) endContainer_.getChildNodes().item(endOffset_); + } + else { + end = (DomNode) endContainer_.getNextSibling(); + } + + boolean foundStart = false; + boolean started = false; + final Iterator<DomNode> i = ancestor.getDescendants().iterator(); + while (i.hasNext()) { + final DomNode n = i.next(); + if (n == end) { + break; + } + if (n == start) { + foundStart = true; + } + if (foundStart && (n != start || !isOffsetChars(startContainer_))) { + started = true; + } + if (started && !n.isAncestorOf(end)) { + nodes.add(n); + } + } + return nodes; + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Range.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Range.java 2017-09-22 17:37:10 UTC (rev 14847) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/dom/Range.java 2017-09-28 05:39:37 UTC (rev 14848) @@ -497,8 +497,7 @@ rectList.setPrototype(getPrototype(rectList.getClass())); // simple impl for now - final DomDocumentFragment fragment = toW3C().extractContents(); - for (DomNode node : fragment.getDescendants()) { + for (DomNode node : toW3C().containedNodes()) { final ScriptableObject scriptable = node.getScriptableObject(); if (scriptable instanceof HTMLElement) { final ClientRect rect = new ClientRect(0, 0, 1, 1); @@ -523,8 +522,7 @@ rect.setPrototype(getPrototype(rect.getClass())); // simple impl for now - final DomDocumentFragment fragment = toW3C().extractContents(); - for (DomNode node : fragment.getDescendants()) { + for (DomNode node : toW3C().containedNodes()) { final ScriptableObject scriptable = node.getScriptableObject(); if (scriptable instanceof HTMLElement) { final ClientRect childRect = ((HTMLElement) scriptable).getBoundingClientRect(); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/RangeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/RangeTest.java 2017-09-22 17:37:10 UTC (rev 14847) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/dom/RangeTest.java 2017-09-28 05:39:37 UTC (rev 14848) @@ -375,4 +375,62 @@ + "</script></body></html>"; loadPageWithAlerts2(html); } + + /** + * Test for a regression, getBoundingClientRect has detached + * all elements of the range from the document. + * @throws Exception if the test fails + */ + @Test + @Alerts("[object HTMLBodyElement]") + public void getBoundingClientRectDoesNotChangeTheParent() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function doTest() {\n" + + " var range = document.createRange();\n" + + + " var elem = document.createElement('boundtest');\n" + + " document.body.appendChild(elem);\n" + + + " range.selectNode(elem);\n" + + " range.getBoundingClientRect();\n" + + + " alert(elem.parentNode);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='doTest()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * Test for a regression, getClientRects has detached + * all elements of the range from the document. + * @throws Exception if the test fails + */ + @Test + @Alerts("[object HTMLBodyElement]") + public void getClientRectsDoesNotChangeTheParent() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function doTest() {\n" + + " var range = document.createRange();\n" + + + " var elem = document.createElement('boundtest');\n" + + " document.body.appendChild(elem);\n" + + + " range.selectNode(elem);\n" + + " range.getClientRects();\n" + + + " alert(elem.parentNode);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='doTest()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2017-09-28 06:37:59
|
Revision: 14849 http://sourceforge.net/p/htmlunit/code/14849 Author: rbri Date: 2017-09-28 06:37:56 +0000 (Thu, 28 Sep 2017) Log Message: ----------- navigator.productSub now returns the same value as simulated browsers Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-09-28 05:39:37 UTC (rev 14848) +++ trunk/htmlunit/src/changes/changes.xml 2017-09-28 06:37:56 UTC (rev 14849) @@ -9,6 +9,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> <action type="fix" dev="rbri"> + JavaScript: navigator.productSub now returns the same value as simulated browsers + </action> + <action type="fix" dev="rbri"> JavaScript: fix for a strange side effect in Range.getClientRects() and Range.getBoundingClientRect(). Both calls have removed all nodes inside the range from the document. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-09-28 05:39:37 UTC (rev 14848) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2017-09-28 06:37:56 UTC (rev 14849) @@ -161,6 +161,7 @@ FIREFOX_45.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Firefox/45.0"; FIREFOX_45.platform_ = PLATFORM_WIN32; FIREFOX_45.buildId_ = "20170411115307"; + FIREFOX_45.productSub_ = "20100101"; FIREFOX_45.headerNamesOrdered_ = new String[] { "Host", "User-Agent", "Accept", "Accept-Language", "Accept-Encoding", "Referer", "Cookie", "Connection"}; FIREFOX_45.htmlAcceptHeader_ = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; @@ -179,6 +180,7 @@ FIREFOX_52.applicationVersion_ = "5.0 (Windows)"; FIREFOX_52.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:52.0) Gecko/20100101 Firefox/52.0"; FIREFOX_52.buildId_ = "20170802111520"; + FIREFOX_52.productSub_ = "20100101"; FIREFOX_52.headerNamesOrdered_ = new String[] { "Host", "User-Agent", "Accept", "Accept-Language", "Accept-Encoding", "Referer", "Cookie", "Connection", "Upgrade-Insecure-Requests"}; FIREFOX_52.htmlAcceptHeader_ = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; @@ -215,13 +217,14 @@ EDGE.userAgent_ = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"; // CHROME - CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"; - CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"; + CHROME.applicationVersion_ = "5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"; + CHROME.userAgent_ = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"; CHROME.applicationCodeName_ = "Mozilla"; CHROME.vendor_ = "Google Inc."; CHROME.platform_ = PLATFORM_WIN32; CHROME.cpuClass_ = null; + CHROME.productSub_ = "20030107"; CHROME.headerNamesOrdered_ = new String[] { "Host", "Connection", "Upgrade-Insecure-Requests", "User-Agent", "Accept", "Referer", "Accept-Encoding", "Accept-Language", "Cookie"}; CHROME.htmlAcceptHeader_ = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"; @@ -355,19 +358,19 @@ CHROME.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF32_26_0_0_151.dll"); + "Shockwave Flash 27.0 r0", "27.0.0.130", "NPSWF32_27_0_0_130.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); FIREFOX_45.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF64_26_0_0_151.dll"); + "Shockwave Flash 27.0 r0", "27.0.0.130", "NPSWF64_27_0_0_130.dll"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); FIREFOX_52.getPlugins().add(flash); flash = new PluginConfiguration("Shockwave Flash", - "Shockwave Flash 26.0 r0", "26.0.0.151", "Flash32_26_0_0_151.ocx"); + "Shockwave Flash 27.0 r0", "27.0.0.130", "Flash32_27_0_0_130.ocx"); flash.getMimeTypes().add(new PluginConfiguration.MimeType("application/x-shockwave-flash", "Shockwave Flash", "swf")); INTERNET_EXPLORER.getPlugins().add(flash); @@ -387,6 +390,7 @@ private String applicationName_; private String applicationVersion_; private String buildId_; + private String productSub_; private String vendor_ = ""; private String browserLanguage_ = LANGUAGE_ENGLISH_US; private String cpuClass_ = CPU_CLASS_X86; @@ -736,6 +740,14 @@ } /** + * Returns the productSub. + * @return the buildId + */ + public String getProductSub() { + return productSub_; + } + + /** * Gets the headers names, so they are sent in the given order (if included in the request). * @return headerNames the header names in ordered manner */ @@ -831,6 +843,7 @@ .setUserLanguage(version.getUserLanguage()); workPiece_.buildId_ = version.getBuildId(); + workPiece_.productSub_ = version.getProductSub(); workPiece_.htmlAcceptHeader_ = version.getHtmlAcceptHeader(); workPiece_.imgAcceptHeader_ = version.getImgAcceptHeader(); workPiece_.cssAcceptHeader_ = version.getCssAcceptHeader(); 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 2017-09-28 05:39:37 UTC (rev 14848) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Navigator.java 2017-09-28 06:37:56 UTC (rev 14849) @@ -159,7 +159,7 @@ */ @JsxGetter({CHROME, FF, EDGE}) public String getProductSub() { - return "20100215"; + return getBrowserVersion().getProductSub(); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-09-28 05:39:37 UTC (rev 14848) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NavigatorTest.java 2017-09-28 06:37:56 UTC (rev 14849) @@ -96,12 +96,13 @@ * @throws Exception on test failure */ @Test - @Alerts(DEFAULT = {"string", "true"}, - IE = {"undefined", "false"}) + @Alerts(DEFAULT = {"string", "20100101"}, + CHROME = {"string", "20030107"}, + IE = {"undefined", "undefined"}) public void productSub() throws Exception { final String html = "<html><head><script>\n" + "alert(typeof(navigator.productSub));\n" - + "alert(parseInt(navigator.productSub) > 20000101);\n" + + "alert(navigator.productSub);\n" + "</script>\n" + "</head><body></body>\n" + "</html>"; @@ -215,10 +216,10 @@ * @throws Exception on test failure */ @Test - @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF32_26_0_0_151.dll"}, - FF52 = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "NPSWF64_26_0_0_151.dll"}, + @Alerts(FF45 = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.130", "NPSWF32_27_0_0_130.dll"}, + FF52 = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.130", "NPSWF64_27_0_0_130.dll"}, CHROME = {"Shockwave Flash", "Shockwave Flash 24.0 r0", "undefined", "internal-not-yet-present"}, - IE = {"Shockwave Flash", "Shockwave Flash 26.0 r0", "26.0.0.151", "Flash32_26_0_0_151.ocx"}, + IE = {"Shockwave Flash", "Shockwave Flash 27.0 r0", "27.0.0.130", "Flash32_27_0_0_130.ocx"}, EDGE = {"Shockwave Flash", "Shockwave Flash 18.0 r0", "18.0.0.232", "Flash.ocx"}) public void pluginsShockwaveFlash() throws Exception { final String html = "<html>\n" |
From: <rb...@us...> - 2017-10-03 15:03:53
|
Revision: 14851 http://sourceforge.net/p/htmlunit/code/14851 Author: rbri Date: 2017-10-03 15:03:51 +0000 (Tue, 03 Oct 2017) Log Message: ----------- fix typos Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/xml/XmlUtil.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/xml/XmlUtil.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/xml/XmlUtil.java 2017-09-28 06:53:10 UTC (rev 14850) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/xml/XmlUtil.java 2017-10-03 15:03:51 UTC (rev 14851) @@ -203,7 +203,6 @@ wasBlank_ = false; break; } - } } return result; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2017-09-28 06:53:10 UTC (rev 14850) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2017-10-03 15:03:51 UTC (rev 14851) @@ -155,7 +155,7 @@ */ @Test @Alerts({"true", "true"}) - public void offsetWidth_spanWithDiffernetFontSize() throws Exception { + public void offsetWidth_spanWithDifferentFontSize() throws Exception { final String html = "<html>\n" + "<head>\n" @@ -182,7 +182,7 @@ @Test @Alerts({"true", "true"}) @NotYetImplemented - public void offsetWidth_spanWithDiffernetFonts() throws Exception { + public void offsetWidth_spanWithDifferentFonts() throws Exception { final String html = "<html>\n" + "<head>\n" |
From: <rb...@us...> - 2017-10-03 15:05:41
|
Revision: 14852 http://sourceforge.net/p/htmlunit/code/14852 Author: rbri Date: 2017-10-03 15:05:38 +0000 (Tue, 03 Oct 2017) Log Message: ----------- writing to an iFrame triggers the onload event now for chrome also Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement3Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2017-10-03 15:03:51 UTC (rev 14851) +++ trunk/htmlunit/src/changes/changes.xml 2017-10-03 15:05:38 UTC (rev 14852) @@ -9,6 +9,9 @@ <body> <release version="2.28" date="???" description="Bugfixes, Chrome 61"> <action type="fix" dev="rbri"> + JavaScript: writing to an iFrame triggers the onload event now for chrome also + </action> + <action type="fix" dev="rbri"> JavaScript: navigator.productSub now returns the same value as simulated browsers </action> <action type="fix" dev="rbri"> 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 2017-10-03 15:03:51 UTC (rev 14851) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2017-10-03 15:05:38 UTC (rev 14852) @@ -598,6 +598,12 @@ final WebClient webClient = page.getWebClient(); final WebWindow window = page.getEnclosingWindow(); + // reset isAttachedToPageDuringOnload_ to trigger the onload event for chrome also + if (window instanceof FrameWindow) { + final BaseFrameElement frame = ((FrameWindow) window).getFrameElement(); + final HTMLIFrameElement iFrameElement = (HTMLIFrameElement) frame.getScriptableObject(); + iFrameElement.onRefresh(); + } webClient.loadWebResponseInto(webResponse, window); } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement.java 2017-10-03 15:03:51 UTC (rev 14851) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement.java 2017-10-03 15:05:38 UTC (rev 14852) @@ -201,7 +201,8 @@ */ @Override public ScriptResult executeEventLocally(final Event event) { - if (!isAttachedToPageDuringOnload_ || getBrowserVersion().hasFeature(JS_IFRAME_ALWAYS_EXECUTE_ONLOAD)) { + if (Event.TYPE_LOAD != event.getType() + || !isAttachedToPageDuringOnload_ || getBrowserVersion().hasFeature(JS_IFRAME_ALWAYS_EXECUTE_ONLOAD)) { return super.executeEventLocally(event); } return null; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement3Test.java 2017-10-03 15:03:51 UTC (rev 14851) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElement3Test.java 2017-10-03 15:05:38 UTC (rev 14852) @@ -566,6 +566,34 @@ * @throws Exception if the test fails */ @Test + @Alerts("iframe onload") + public void writeTriggersOnload() throws Exception { + final String html + = "<!DOCTYPE html>\n" + + "<html><head><title>First</title><script>\n" + + "function test() {\n" + + " var iframe = document.createElement('iframe');\n" + + " var content = 'something';\n" + + " document.body.appendChild(iframe);\n" + + + " iframe.onload = function() {alert('iframe onload')};\n" + + " iframe.contentWindow.document.open('text/html', 'replace');\n" + + " iframe.contentWindow.document.write(content);\n" + + " iframe.contentWindow.document.close();\n" + + "}\n</script></head>\n" + + "<body>\n" + + " <button type='button' id='clickme' onClick='test();'>Click me</a>\n" + + "</body></html>"; + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("clickme")).click(); + verifyAlerts(driver, getExpectedAlerts()); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts({"localhost", "localhost", "localhost", "localhost", "true", "true", "true"}) public void domain() throws Exception { |
From: <rb...@us...> - 2017-10-06 12:00:06
|
Revision: 14858 http://sourceforge.net/p/htmlunit/code/14858 Author: rbri Date: 2017-10-06 12:00:03 +0000 (Fri, 06 Oct 2017) Log Message: ----------- rewritten Promise support (wip) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java 2017-10-04 10:13:15 UTC (rev 14857) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java 2017-10-06 12:00:03 UTC (rev 14858) @@ -18,7 +18,6 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; -import com.gargoylesoftware.htmlunit.javascript.FunctionWrapper; import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; @@ -27,12 +26,15 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxStaticFunction; +import net.sourceforge.htmlunit.corejs.javascript.BaseFunction; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Function; import net.sourceforge.htmlunit.corejs.javascript.JavaScriptException; import net.sourceforge.htmlunit.corejs.javascript.NativeArray; import net.sourceforge.htmlunit.corejs.javascript.NativeObject; +import net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime; import net.sourceforge.htmlunit.corejs.javascript.Scriptable; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import net.sourceforge.htmlunit.corejs.javascript.Undefined; /** @@ -40,16 +42,20 @@ * * @author Ahmed Ashour * @author Marc Guillemot + * @author Ronald Brill */ @JsxClass({CHROME, FF, EDGE}) public class Promise extends SimpleScriptable { + private enum PromiseState { PENDING, FULFILLED, REJECTED } + private PromiseState state_ = PromiseState.PENDING; private Object value_; /** To be set only by {@link #all(Context, Scriptable, Object[], Function)}. */ private Promise[] all_; - private boolean resolve_ = true; - private String exceptionDetails_; + private PostponedAction thenAction_; + private Promise linkedPromise_; + /** * Default constructor. */ @@ -72,15 +78,39 @@ */ @JsxConstructor public Promise(final Object object) { - if (object instanceof Promise) { - value_ = ((Promise) object).value_; + if (!(object instanceof Function)) { + throw ScriptRuntime.typeError("Promise resolver is not a function"); } - else if (object instanceof NativeObject) { - final NativeObject nativeObject = (NativeObject) object; - value_ = nativeObject.get("then", nativeObject); + + final Function fun = (Function) object; + final Window window = getWindow(fun); + this.setParentScope(window); + this.setPrototype(window.getPrototype(this.getClass())); + final Promise thisPromise = this; + + final Function resolve = new BaseFunction(window, ScriptableObject.getFunctionPrototype(window)) { + @Override + public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, + final Object[] args) { + thisPromise.update(PromiseState.FULFILLED, args.length != 0 ? args[0] : Undefined.instance); + return thisPromise; + } + }; + + final Function reject = new BaseFunction(window, ScriptableObject.getFunctionPrototype(window)) { + @Override + public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, + final Object[] args) { + thisPromise.update(PromiseState.REJECTED, args.length != 0 ? args[0] : Undefined.instance); + return thisPromise; + } + }; + + try { + fun.call(Context.getCurrentContext(), window, window, new Object[] {resolve, reject}); } - else { - value_ = object; + catch (final JavaScriptException e) { + thisPromise.update(PromiseState.REJECTED, e.getValue()); } } @@ -96,11 +126,7 @@ @JsxStaticFunction public static Promise resolve(final Context context, final Scriptable thisObj, final Object[] args, final Function function) { - final Promise promise = new Promise(args.length != 0 ? args[0] : Undefined.instance); - promise.setResolve(true); - promise.setParentScope(thisObj.getParentScope()); - promise.setPrototype(getWindow(thisObj).getPrototype(promise.getClass())); - return promise; + return create(thisObj, args, PromiseState.FULFILLED); } /** @@ -115,40 +141,60 @@ @JsxStaticFunction public static Promise reject(final Context context, final Scriptable thisObj, final Object[] args, final Function function) { - final Promise promise = new Promise(args.length != 0 ? args[0] : Undefined.instance); - promise.setResolve(false); + return create(thisObj, args, PromiseState.REJECTED); + } + + private static Promise create(final Scriptable thisObj, final Object[] args, final PromiseState state) { + if (args.length != 0 && args[0] instanceof Promise && state == PromiseState.FULFILLED) { + return (Promise) args[0]; + } + + final Promise promise; + if (args.length > 0) { + final Object arg = args[0]; + if (arg instanceof NativeObject) { + final NativeObject nativeObject = (NativeObject) arg; + promise = new Promise(nativeObject.get("then", nativeObject)); + } + else { + promise = new Promise(); + promise.value_ = arg; + promise.state_ = state; + } + } + else { + promise = new Promise(); + promise.value_ = Undefined.instance; + promise.state_ = state; + } + promise.setParentScope(thisObj.getParentScope()); promise.setPrototype(getWindow(thisObj).getPrototype(promise.getClass())); return promise; } - private void setResolve(final boolean resolve) { - resolve_ = resolve; - } + private void update(final PromiseState newState, final Object newValue) { + if (state_ == newState || state_ != PromiseState.PENDING) { + return; + } - /** - * Also sets the value of this promise. - */ - private boolean isResolved(final Function onRejected) { - if (all_ != null) { - final Object[] values = new Object[all_.length]; - for (int i = 0; i < all_.length; i++) { - final Promise p = all_[i]; - if (!p.isResolved(onRejected)) { - value_ = p.value_; - return false; - } + value_ = newValue; + state_ = newState; - if (p.value_ instanceof Function) { - // TODO - } - else { - values[i] = p.value_; - } + if (thenAction_ != null) { + try { + thenAction_.execute(); } - value_ = Context.getCurrentContext().newArray(getParentScope(), values); + catch (final Exception e) { + // ignore for now + } + thenAction_ = null; } - return resolve_; + + if (linkedPromise_ != null) { + linkedPromise_.update(newState, newValue); + linkedPromise_ = null; + } } /** @@ -165,7 +211,7 @@ public static Promise all(final Context context, final Scriptable thisObj, final Object[] args, final Function function) { final Promise promise = new Promise(); - promise.setResolve(true); + promise.state_ = PromiseState.FULFILLED; if (args.length == 0) { promise.all_ = new Promise[0]; } @@ -201,38 +247,44 @@ final Promise promise = new Promise(window); final Promise thisPromise = this; - final PostponedAction thenAction = new PostponedAction(window.getDocument().getPage(), "Promise.then") { + thenAction_ = new PostponedAction(window.getDocument().getPage(), "Promise.then") { @Override public void execute() throws Exception { Context.enter(); try { - Object newValue = null; - final Function toExecute = isResolved(onRejected) ? onFulfilled : onRejected; - if (value_ instanceof Function) { - final WasCalledFunctionWrapper wrapper = new WasCalledFunctionWrapper(toExecute); + Function toExecute = null; + if (thisPromise.state_ == PromiseState.FULFILLED) { + toExecute = onFulfilled; + } + else if (thisPromise.state_ == PromiseState.REJECTED) { + toExecute = onRejected; + } + + if (toExecute != null) { try { - ((Function) value_).call(Context.getCurrentContext(), window, thisPromise, - new Object[] {wrapper, onRejected}); - if (wrapper.wasCalled_) { - newValue = wrapper.value_; + final Object newValue = toExecute.call(Context.getCurrentContext(), + window, thisPromise, new Object[] {value_}); + if (newValue instanceof Promise) { + final Promise callPromise = (Promise) newValue; + if (callPromise.state_ == PromiseState.FULFILLED) { + promise.update(PromiseState.FULFILLED, callPromise.value_); + } + else if (callPromise.state_ == PromiseState.REJECTED) { + promise.update(PromiseState.REJECTED, callPromise.value_); + } + else { + callPromise.linkedPromise_ = promise; + } } + else { + promise.update(PromiseState.FULFILLED, newValue); + } } catch (final JavaScriptException e) { - if (onRejected == null) { - promise.exceptionDetails_ = e.details(); - } - else if (!wrapper.wasCalled_) { - newValue = onRejected.call(Context.getCurrentContext(), window, thisPromise, - new Object[] {e.getValue()}); - } + promise.update(PromiseState.REJECTED, e.getValue()); } } - else { - newValue = toExecute.call(Context.getCurrentContext(), window, thisPromise, - new Object[] {value_}); - } - promise.value_ = newValue; } finally { Context.exit(); @@ -240,9 +292,15 @@ } }; - final JavaScriptEngine jsEngine - = (JavaScriptEngine) window.getWebWindow().getWebClient().getJavaScriptEngine(); - jsEngine.addPostponedAction(thenAction); + if (state_ != PromiseState.PENDING) { + final JavaScriptEngine jsEngine + = (JavaScriptEngine) getWindow(this).getWebWindow().getWebClient().getJavaScriptEngine(); + jsEngine.addPostponedAction(thenAction_); + thenAction_ = null; + } + else { + thisPromise.linkedPromise_ = promise; + } return promise; } @@ -255,49 +313,6 @@ */ @JsxFunction(functionName = "catch") public Promise catch_js(final Function onRejected) { - final Window window = getWindow(); - final Promise promise = new Promise(window); - final Promise thisPromise = this; - - final PostponedAction thenAction = new PostponedAction(window.getDocument().getPage(), "Promise.catch") { - - @Override - public void execute() throws Exception { - Context.enter(); - try { - final Object newValue = onRejected.call(Context.getCurrentContext(), window, thisPromise, - new Object[] {exceptionDetails_}); - promise.value_ = newValue; - } - finally { - Context.exit(); - } - } - }; - - final JavaScriptEngine jsEngine - = (JavaScriptEngine) window.getWebWindow().getWebClient().getJavaScriptEngine(); - jsEngine.addPostponedAction(thenAction); - - return promise; + return then(null, onRejected); } - - private static class WasCalledFunctionWrapper extends FunctionWrapper { - private boolean wasCalled_; - private Object value_; - - WasCalledFunctionWrapper(final Function wrapped) { - super(wrapped); - } - - /** - * {@inheritDoc} - */ - @Override - public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { - wasCalled_ = true; - value_ = super.call(cx, scope, thisObj, args); - return value_; - } - } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java 2017-10-04 10:13:15 UTC (rev 14857) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java 2017-10-06 12:00:03 UTC (rev 14858) @@ -147,6 +147,45 @@ * @throws Exception if an error occurs */ @Test + @Alerts(DEFAULT = {"done", "false", "[object Promise]"}, + IE = {}) + public void rejectPromise() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " var original = Promise.reject(42);\n" + + " var cast = Promise.reject(original);\n" + + " cast.then(function(v) {\n" + + " log('failure');\n" + + " }, function(value) {\n" + + " log(value);\n" + + " });\n" + + " log('done');\n" + + " log(original === cast);\n" + + " }\n" + + " }\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts(DEFAULT = {"done", "undefined"}, IE = {}) public void resolveEmpty() throws Exception { @@ -219,8 +258,44 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"done", "true"}, + @Alerts(DEFAULT = {"done", "HtmlUnit"}, IE = {}) + public void resolveString() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " var p = Promise.resolve('HtmlUnit');\n" + + " p.then(function(v) {\n" + + " log(v);\n" + + " });\n" + + " log('done');\n" + + " }\n" + + " }\n" + + "\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = {"done", "true", "42"}, + IE = {}) public void resolvePromise() throws Exception { final String html = "<html>\n" @@ -228,12 +303,13 @@ + " <script>\n" + " function test() {\n" + " if (window.Promise) {\n" - + " var original = Promise.resolve(true);\n" + + " var original = Promise.resolve(42);\n" + " var cast = Promise.resolve(original);\n" + " cast.then(function(v) {\n" + " log(v);\n" + " });\n" + " log('done');\n" + + " log(original === cast);\n" + " }\n" + " }\n" + " function log(x) {\n" @@ -366,19 +442,35 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = {"end in-then"}, - IE = "exception") + @Alerts(DEFAULT = {"done", "undefined"}, + IE = {}) public void then() throws Exception { - final String html = "<html><body><script>\n" - + "try {\n" - + " var p = Promise.resolve(void 0);\n" - + " p.then(function() { document.title += ' in-then'; });\n" - + " document.title += ' end';\n" - + "} catch (e) { document.title += ' exception'; }\n" - + "</script></body></html>"; - + final String html = "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " var p = Promise.resolve(void 0);\n" + + "\n" + + " p.then(function(value) {\n" + + " log(value);\n" + + " })\n" + + " log('done');\n" + + " }\n" + + " }\n" + + "\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; final WebDriver driver = loadPage2(html); - assertEquals(getExpectedAlerts()[0], driver.getTitle()); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); } /** @@ -393,11 +485,11 @@ + " <script>\n" + " function test() {\n" + " if (window.Promise) {\n" - + " var p1 = new Promise(function(resolve, reject) {\n" + + " var p = new Promise(function(resolve, reject) {\n" + " resolve('Success');\n" + " });\n" + "\n" - + " p1.then(function(value) {\n" + + " p.then(function(value) {\n" + " log(value);\n" + " throw 'oh, no!';\n" + " }).catch(function(e) {\n" @@ -506,4 +598,92 @@ final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(CHROME = { "function () { [native code] }", + "function () { [native code] }", + "[object Window]", + "done", "resolved value"}, + FF = { "function () {\n [native code]\n}", + "function () {\n [native code]\n}", + "[object Window]", + "done", "resolved value"}, + IE = {}) + public void constructor() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " var p = new Promise(function(resolve, reject) {\n" + + " log(resolve);\n" + + " log(reject);\n" + + " log(this);\n" + + " resolve('resolved value');\n" + + " });\n" + + " p.then(function(value) {log(value);});\n" + + " log('done');\n" + + " }\n" + + " }\n" + + "\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = {"true", "true", "true"}, + IE = {}) + public void constructorWithoutFunction() throws Exception { + final String html = "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " try{\n" + + " var p = new Promise();\n" + + " log('done');\n" + + " } catch(e) { log(e instanceof TypeError); }\n" + + " try{\n" + + " var p = new Promise([1, 2, 4]);\n" + + " log('done');\n" + + " } catch(e) { log(e instanceof TypeError); }\n" + + " try{\n" + + " var original = Promise.resolve(42);\n" + + " var p = new Promise(original);\n" + + " log('done');\n" + + " } catch(e) { log(e instanceof TypeError); }\n" + + " }\n" + + " }\n" + + "\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + } } |
From: <rb...@us...> - 2017-10-07 11:02:13
|
Revision: 14860 http://sourceforge.net/p/htmlunit/code/14860 Author: rbri Date: 2017-10-07 11:02:10 +0000 (Sat, 07 Oct 2017) Log Message: ----------- make the promises working async Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java 2017-10-06 17:16:32 UTC (rev 14859) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Promise.java 2017-10-07 11:02:10 UTC (rev 14860) @@ -18,9 +18,8 @@ import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE; import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF; -import com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine; -import com.gargoylesoftware.htmlunit.javascript.PostponedAction; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.background.BasicJavaScriptJob; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction; @@ -53,8 +52,8 @@ /** To be set only by {@link #all(Context, Scriptable, Object[], Function)}. */ private Promise[] all_; - private PostponedAction thenAction_; - private Promise linkedPromise_; + private BasicJavaScriptJob settledAction_; + private Promise dependentPromise_; /** * Default constructor. @@ -92,7 +91,7 @@ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { - thisPromise.update(PromiseState.FULFILLED, args.length != 0 ? args[0] : Undefined.instance); + thisPromise.settle(true, args.length != 0 ? args[0] : Undefined.instance, window); return thisPromise; } }; @@ -101,7 +100,7 @@ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { - thisPromise.update(PromiseState.REJECTED, args.length != 0 ? args[0] : Undefined.instance); + thisPromise.settle(false, args.length != 0 ? args[0] : Undefined.instance, window); return thisPromise; } }; @@ -110,7 +109,7 @@ fun.call(Context.getCurrentContext(), window, window, new Object[] {resolve, reject}); } catch (final JavaScriptException e) { - thisPromise.update(PromiseState.REJECTED, e.getValue()); + thisPromise.settle(false, e.getValue(), window); } } @@ -145,6 +144,7 @@ } private static Promise create(final Scriptable thisObj, final Object[] args, final PromiseState state) { + // fulfilled promises are returend if (args.length != 0 && args[0] instanceof Promise && state == PromiseState.FULFILLED) { return (Promise) args[0]; } @@ -173,27 +173,27 @@ return promise; } - private void update(final PromiseState newState, final Object newValue) { - if (state_ == newState || state_ != PromiseState.PENDING) { + private void settle(final boolean fulfilled, final Object newValue, final Window window) { + if (state_ != PromiseState.PENDING) { return; } value_ = newValue; - state_ = newState; + if (fulfilled) { + state_ = PromiseState.FULFILLED; + } + else { + state_ = PromiseState.REJECTED; + } - if (thenAction_ != null) { - try { - thenAction_.execute(); - } - catch (final Exception e) { - // ignore for now - } - thenAction_ = null; + if (settledAction_ != null) { + window.getWebWindow().getJobManager().addJob(settledAction_, window.getDocument().getPage()); + settledAction_ = null; } - if (linkedPromise_ != null) { - linkedPromise_.update(newState, newValue); - linkedPromise_ = null; + if (dependentPromise_ != null) { + dependentPromise_.settle(fulfilled, newValue, window); + dependentPromise_ = null; } } @@ -244,13 +244,14 @@ @JsxFunction public Promise then(final Function onFulfilled, final Function onRejected) { final Window window = getWindow(); - final Promise promise = new Promise(window); + final Promise returnPromise = new Promise(window); + final Promise thisPromise = this; - thenAction_ = new PostponedAction(window.getDocument().getPage(), "Promise.then") { + settledAction_ = new BasicJavaScriptJob() { @Override - public void execute() throws Exception { + public void run() { Context.enter(); try { Function toExecute = null; @@ -263,26 +264,26 @@ if (toExecute != null) { try { - final Object newValue = toExecute.call(Context.getCurrentContext(), + final Object callbackResult = toExecute.call(Context.getCurrentContext(), window, thisPromise, new Object[] {value_}); - if (newValue instanceof Promise) { - final Promise callPromise = (Promise) newValue; - if (callPromise.state_ == PromiseState.FULFILLED) { - promise.update(PromiseState.FULFILLED, callPromise.value_); + if (callbackResult instanceof Promise) { + final Promise resultPromise = (Promise) callbackResult; + if (resultPromise.state_ == PromiseState.FULFILLED) { + returnPromise.settle(true, resultPromise.value_, window); } - else if (callPromise.state_ == PromiseState.REJECTED) { - promise.update(PromiseState.REJECTED, callPromise.value_); + else if (resultPromise.state_ == PromiseState.REJECTED) { + returnPromise.settle(false, resultPromise.value_, window); } else { - callPromise.linkedPromise_ = promise; + resultPromise.dependentPromise_ = returnPromise; } } else { - promise.update(PromiseState.FULFILLED, newValue); + returnPromise.settle(true, callbackResult, window); } } catch (final JavaScriptException e) { - promise.update(PromiseState.REJECTED, e.getValue()); + returnPromise.settle(false, e.getValue(), window); } } } @@ -290,19 +291,20 @@ Context.exit(); } } + + /** {@inheritDoc} */ + @Override + public String toString() { + return super.toString() + " Promise.then"; + } }; - if (state_ != PromiseState.PENDING) { - final JavaScriptEngine jsEngine - = (JavaScriptEngine) getWindow(this).getWebWindow().getWebClient().getJavaScriptEngine(); - jsEngine.addPostponedAction(thenAction_); - thenAction_ = null; + if (state_ == PromiseState.FULFILLED || state_ == PromiseState.REJECTED) { + window.getWebWindow().getJobManager().addJob(settledAction_, window.getDocument().getPage()); + settledAction_ = null; } - else { - thisPromise.linkedPromise_ = promise; - } - return promise; + return returnPromise; } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java 2017-10-06 17:16:32 UTC (rev 14859) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/PromiseTest.java 2017-10-07 11:02:10 UTC (rev 14860) @@ -75,6 +75,37 @@ * @throws Exception if an error occurs */ @Test + @Alerts(DEFAULT = "1", + IE = {}) + public void length() throws Exception { + final String html = + "<html>\n" + + "<head>\n" + + " <script>\n" + + " function test() {\n" + + " if (window.Promise) {\n" + + " log(Promise.length);\n" + + " }\n" + + " }\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " </script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <textarea id='log' cols='80' rows='40'></textarea>\n" + + "</body>\n" + + "</html>"; + + final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); + assertEquals(String.join("\n", getExpectedAlerts()), text); + } + + /** + * @throws Exception if an error occurs + */ + @Test @Alerts(DEFAULT = {"done", "Resolved"}, IE = {}) public void resolve() throws Exception { @@ -103,6 +134,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -139,6 +171,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -178,6 +211,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -214,6 +248,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -250,6 +285,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -286,6 +322,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -323,6 +360,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -392,6 +430,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -434,6 +473,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -469,6 +509,7 @@ + "</body>\n" + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -514,6 +555,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -550,7 +592,6 @@ + "</html>"; final WebDriver driver = loadPage2(html); driver.findElement(By.id("btn1")).click(); - Thread.sleep(200); assertEquals(getExpectedAlerts()[0], driver.getTitle()); } @@ -640,6 +681,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + Thread.sleep(200); final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } @@ -683,6 +725,7 @@ + "</html>"; final WebDriver driver = loadPage2(html); + final String text = driver.findElement(By.id("log")).getAttribute("value").trim().replaceAll("\r", ""); assertEquals(String.join("\n", getExpectedAlerts()), text); } |