diff --git a/checkstyle_suppressions.xml b/checkstyle_suppressions.xml index b84cdfc765..201500e9cd 100644 --- a/checkstyle_suppressions.xml +++ b/checkstyle_suppressions.xml @@ -15,6 +15,7 @@ + diff --git a/src/main/java/org/htmlunit/javascript/host/MessagePort.java b/src/main/java/org/htmlunit/javascript/host/MessagePort.java index 6f8adc0562..feca9f7139 100644 --- a/src/main/java/org/htmlunit/javascript/host/MessagePort.java +++ b/src/main/java/org/htmlunit/javascript/host/MessagePort.java @@ -18,6 +18,7 @@ import org.htmlunit.Page; import org.htmlunit.WebWindow; +import org.htmlunit.corejs.javascript.Function; import org.htmlunit.javascript.AbstractJavaScriptEngine; import org.htmlunit.javascript.HtmlUnitContextFactory; import org.htmlunit.javascript.PostponedAction; @@ -71,7 +72,7 @@ public MessagePort(final MessagePort port) { * @return the value of the window's {@code onmessage} property */ @JsxGetter - public Object getOnmessage() { + public Function getOnmessage() { return getHandlerForJavaScript(Event.TYPE_MESSAGE); } @@ -84,7 +85,7 @@ public void setOnmessage(final Object onmessage) { setHandlerForJavaScript(Event.TYPE_MESSAGE, onmessage); } - private Object getHandlerForJavaScript(final String eventName) { + private Function getHandlerForJavaScript(final String eventName) { return getEventListenersContainer().getEventHandler(eventName); } diff --git a/src/main/java/org/htmlunit/javascript/host/Window.java b/src/main/java/org/htmlunit/javascript/host/Window.java index 2636fb34a4..5e3b61e085 100644 --- a/src/main/java/org/htmlunit/javascript/host/Window.java +++ b/src/main/java/org/htmlunit/javascript/host/Window.java @@ -1233,7 +1233,7 @@ public void scrollTo(final Scriptable x, final Scriptable y) { * @return the {@code onload} property */ @JsxGetter - public Object getOnload() { + public Function getOnload() { return getEventHandler(Event.TYPE_LOAD); } @@ -1260,7 +1260,7 @@ public void setOnblur(final Object onblur) { * @return the {@code onblur} property */ @JsxGetter - public Object getOnblur() { + public Function getOnblur() { return getEventHandler(Event.TYPE_BLUR); } @@ -1269,7 +1269,7 @@ public Object getOnblur() { * @return the {@code onclick} property */ @JsxGetter - public Object getOnclick() { + public Function getOnclick() { return getEventHandler(MouseEvent.TYPE_CLICK); } @@ -1287,7 +1287,7 @@ public void setOnclick(final Object onclick) { * @return the {@code ondblclick} property */ @JsxGetter - public Object getOndblclick() { + public Function getOndblclick() { return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } @@ -1305,7 +1305,7 @@ public void setOndblclick(final Object ondblclick) { * @return the {@code onhashchange} property */ @JsxGetter - public Object getOnhashchange() { + public Function getOnhashchange() { return getEventHandler(Event.TYPE_HASH_CHANGE); } @@ -1341,7 +1341,7 @@ public void setName(final String name) { * @return the value of the window's {@code onbeforeunload} property */ @JsxGetter - public Object getOnbeforeunload() { + public Function getOnbeforeunload() { return getEventHandler(Event.TYPE_BEFORE_UNLOAD); } @@ -1359,7 +1359,7 @@ public void setOnbeforeunload(final Object onbeforeunload) { * @return the value of the window's {@code onerror} property */ @JsxGetter - public Object getOnerror() { + public Function getOnerror() { return getEventHandler(Event.TYPE_ERROR); } @@ -1377,7 +1377,7 @@ public void setOnerror(final Object onerror) { * @return the value of the window's {@code onmessage} property */ @JsxGetter - public Object getOnmessage() { + public Function getOnmessage() { return getEventHandler(Event.TYPE_MESSAGE); } @@ -1907,7 +1907,7 @@ public boolean dispatchEvent(final Event event) { * @return the handler */ @JsxGetter - public Object getOnchange() { + public Function getOnchange() { return getEventHandler(Event.TYPE_CHANGE); } @@ -1925,7 +1925,7 @@ public void setOnchange(final Object onchange) { * @return the handler */ @JsxGetter - public Object getOnsubmit() { + public Function getOnsubmit() { return getEventHandler(Event.TYPE_SUBMIT); } diff --git a/src/main/java/org/htmlunit/javascript/host/dom/Document.java b/src/main/java/org/htmlunit/javascript/host/dom/Document.java index 38d99c9f3f..28661e4149 100644 --- a/src/main/java/org/htmlunit/javascript/host/dom/Document.java +++ b/src/main/java/org/htmlunit/javascript/host/dom/Document.java @@ -1344,7 +1344,7 @@ public void setOnclick(final Object handler) { * @return the {@code onclick} event handler for this element */ @JsxGetter - public Object getOnclick() { + public Function getOnclick() { return getEventHandler(MouseEvent.TYPE_CLICK); } @@ -1362,7 +1362,7 @@ public void setOndblclick(final Object handler) { * @return the {@code ondblclick} event handler for this element */ @JsxGetter - public Object getOndblclick() { + public Function getOndblclick() { return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } @@ -1380,7 +1380,7 @@ public void setOnblur(final Object handler) { * @return the {@code onblur} event handler for this element */ @JsxGetter - public Object getOnblur() { + public Function getOnblur() { return getEventHandler(Event.TYPE_BLUR); } @@ -1398,7 +1398,7 @@ public void setOnfocus(final Object handler) { * @return the {@code onfocus} event handler for this element */ @JsxGetter - public Object getOnfocus() { + public Function getOnfocus() { return getEventHandler(Event.TYPE_FOCUS); } @@ -1416,7 +1416,7 @@ public void setOnkeydown(final Object handler) { * @return the {@code onkeydown} event handler for this element */ @JsxGetter - public Object getOnkeydown() { + public Function getOnkeydown() { return getEventHandler(Event.TYPE_KEY_DOWN); } @@ -1434,7 +1434,7 @@ public void setOnkeypress(final Object handler) { * @return the {@code onkeypress} event handler for this element */ @JsxGetter - public Object getOnkeypress() { + public Function getOnkeypress() { return getEventHandler(Event.TYPE_KEY_PRESS); } @@ -1452,7 +1452,7 @@ public void setOnkeyup(final Object handler) { * @return the {@code onkeyup} event handler for this element */ @JsxGetter - public Object getOnkeyup() { + public Function getOnkeyup() { return getEventHandler(Event.TYPE_KEY_UP); } @@ -1470,7 +1470,7 @@ public void setOnmousedown(final Object handler) { * @return the {@code onmousedown} event handler for this element */ @JsxGetter - public Object getOnmousedown() { + public Function getOnmousedown() { return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } @@ -1488,7 +1488,7 @@ public void setOnmousemove(final Object handler) { * @return the {@code onmousemove} event handler for this element */ @JsxGetter - public Object getOnmousemove() { + public Function getOnmousemove() { return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } @@ -1506,7 +1506,7 @@ public void setOnmouseout(final Object handler) { * @return the {@code onmouseout} event handler for this element */ @JsxGetter - public Object getOnmouseout() { + public Function getOnmouseout() { return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } @@ -1524,7 +1524,7 @@ public void setOnmouseover(final Object handler) { * @return the {@code onmouseover} event handler for this element */ @JsxGetter - public Object getOnmouseover() { + public Function getOnmouseover() { return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } @@ -1542,7 +1542,7 @@ public void setOnmouseup(final Object handler) { * @return the {@code onmouseup} event handler for this element */ @JsxGetter - public Object getOnmouseup() { + public Function getOnmouseup() { return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } @@ -1560,7 +1560,7 @@ public void setOncontextmenu(final Object handler) { * @return the {@code oncontextmenu} event handler for this element */ @JsxGetter - public Object getOncontextmenu() { + public Function getOncontextmenu() { return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } @@ -1578,7 +1578,7 @@ public void setOnresize(final Object handler) { * @return the {@code onresize} event handler for this element */ @JsxGetter - public Object getOnresize() { + public Function getOnresize() { return getEventHandler(Event.TYPE_RESIZE); } @@ -1596,7 +1596,7 @@ public void setOnerror(final Object handler) { * @return the {@code onerror} event handler for this element */ @JsxGetter - public Object getOnerror() { + public Function getOnerror() { return getEventHandler(Event.TYPE_ERROR); } diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLBodyElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLBodyElement.java index 26d508dc79..4a54c1b128 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLBodyElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLBodyElement.java @@ -213,7 +213,7 @@ public int getClientWidth() { */ @Override @JsxGetter({CHROME, EDGE}) - public Object getOnload() { + public Function getOnload() { return super.getOnload(); } @@ -240,7 +240,7 @@ public void setOnblur(final Object handler) { */ @Override @JsxGetter({CHROME, EDGE}) - public Object getOnblur() { + public Function getOnblur() { return super.getOnblur(); } @@ -258,7 +258,7 @@ public void setOnfocus(final Object handler) { */ @Override @JsxGetter({CHROME, EDGE}) - public Object getOnfocus() { + public Function getOnfocus() { return super.getOnfocus(); } @@ -276,7 +276,7 @@ public void setOnerror(final Object handler) { */ @Override @JsxGetter({CHROME, EDGE}) - public Object getOnerror() { + public Function getOnerror() { return super.getOnerror(); } diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java index 9c4587da1a..ec00dccdcc 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java @@ -1200,7 +1200,7 @@ public Function getOnchange() { * @return the {@code onsubmit} event handler for this element */ @JsxGetter - public Object getOnsubmit() { + public Function getOnsubmit() { return getEventHandler(Event.TYPE_SUBMIT); } @@ -1313,7 +1313,7 @@ public void setOnclick(final Object handler) { * @return the {@code onclick} event handler for this element */ @JsxGetter - public Object getOnclick() { + public Function getOnclick() { return getEventHandler(MouseEvent.TYPE_CLICK); } @@ -1331,7 +1331,7 @@ public void setOndblclick(final Object handler) { * @return the {@code ondblclick} event handler for this element */ @JsxGetter - public Object getOndblclick() { + public Function getOndblclick() { return getEventHandler(MouseEvent.TYPE_DBL_CLICK); } @@ -1349,7 +1349,7 @@ public void setOnblur(final Object handler) { * @return the {@code onblur} event handler for this element */ @JsxGetter - public Object getOnblur() { + public Function getOnblur() { return getEventHandler(Event.TYPE_BLUR); } @@ -1367,7 +1367,7 @@ public void setOnfocus(final Object handler) { * @return the {@code onfocus} event handler for this element */ @JsxGetter - public Object getOnfocus() { + public Function getOnfocus() { return getEventHandler(Event.TYPE_FOCUS); } @@ -1385,7 +1385,7 @@ public void setOnkeydown(final Object handler) { * @return the {@code onkeydown} event handler for this element */ @JsxGetter - public Object getOnkeydown() { + public Function getOnkeydown() { return getEventHandler(Event.TYPE_KEY_DOWN); } @@ -1403,7 +1403,7 @@ public void setOnkeypress(final Object handler) { * @return the {@code onkeypress} event handler for this element */ @JsxGetter - public Object getOnkeypress() { + public Function getOnkeypress() { return getEventHandler(Event.TYPE_KEY_PRESS); } @@ -1421,7 +1421,7 @@ public void setOnkeyup(final Object handler) { * @return the {@code onkeyup} event handler for this element */ @JsxGetter - public Object getOnkeyup() { + public Function getOnkeyup() { return getEventHandler(Event.TYPE_KEY_UP); } @@ -1439,7 +1439,7 @@ public void setOnmousedown(final Object handler) { * @return the {@code onmousedown} event handler for this element */ @JsxGetter - public Object getOnmousedown() { + public Function getOnmousedown() { return getEventHandler(MouseEvent.TYPE_MOUSE_DOWN); } @@ -1457,7 +1457,7 @@ public void setOnmousemove(final Object handler) { * @return the {@code onmousemove} event handler for this element */ @JsxGetter - public Object getOnmousemove() { + public Function getOnmousemove() { return getEventHandler(MouseEvent.TYPE_MOUSE_MOVE); } @@ -1475,7 +1475,7 @@ public void setOnmouseout(final Object handler) { * @return the {@code onmouseout} event handler for this element */ @JsxGetter - public Object getOnmouseout() { + public Function getOnmouseout() { return getEventHandler(MouseEvent.TYPE_MOUSE_OUT); } @@ -1493,7 +1493,7 @@ public void setOnmouseover(final Object handler) { * @return the {@code onmouseover} event handler for this element */ @JsxGetter - public Object getOnmouseover() { + public Function getOnmouseover() { return getEventHandler(MouseEvent.TYPE_MOUSE_OVER); } @@ -1511,7 +1511,7 @@ public void setOnmouseup(final Object handler) { * @return the {@code onmouseup} event handler for this element */ @JsxGetter - public Object getOnmouseup() { + public Function getOnmouseup() { return getEventHandler(MouseEvent.TYPE_MOUSE_UP); } @@ -1529,7 +1529,7 @@ public void setOncontextmenu(final Object handler) { * @return the {@code oncontextmenu} event handler for this element */ @JsxGetter - public Object getOncontextmenu() { + public Function getOncontextmenu() { return getEventHandler(MouseEvent.TYPE_CONTEXT_MENU); } @@ -1565,7 +1565,7 @@ public void setOnerror(final Object handler) { * @return the {@code onerror} event handler for this element */ @JsxGetter - public Object getOnerror() { + public Function getOnerror() { return getEventHandler(Event.TYPE_ERROR); } @@ -1956,7 +1956,7 @@ public void setOninvalid(final Object oninvalid) { * @return the {@code onload} event handler for this element */ @JsxGetter - public Object getOnload() { + public Function getOnload() { if (this instanceof HTMLBodyElement) { return getWindow().getEventHandler(Event.TYPE_LOAD); } diff --git a/src/main/java/org/htmlunit/javascript/host/worker/Worker.java b/src/main/java/org/htmlunit/javascript/host/worker/Worker.java index 78f56bd2f4..eedf4e15f1 100644 --- a/src/main/java/org/htmlunit/javascript/host/worker/Worker.java +++ b/src/main/java/org/htmlunit/javascript/host/worker/Worker.java @@ -123,7 +123,7 @@ public void setOnmessage(final Object onmessage) { * @return the handler */ @JsxGetter - public Object getOnmessage() { + public Function getOnmessage() { return getEventListenersContainer().getEventHandler(Event.TYPE_MESSAGE); } } diff --git a/src/test/java/org/htmlunit/archunit/ArchitectureTest.java b/src/test/java/org/htmlunit/archunit/ArchitectureTest.java index b13ef7fea9..d03538e3c8 100644 --- a/src/test/java/org/htmlunit/archunit/ArchitectureTest.java +++ b/src/test/java/org/htmlunit/archunit/ArchitectureTest.java @@ -24,6 +24,7 @@ import java.util.function.Supplier; import org.apache.commons.lang3.StringUtils; +import org.htmlunit.corejs.javascript.Scriptable; import org.htmlunit.javascript.configuration.JsxClass; import org.htmlunit.javascript.configuration.JsxClasses; import org.htmlunit.javascript.configuration.JsxConstant; @@ -34,6 +35,7 @@ import org.junit.runner.RunWith; import com.tngtech.archunit.base.DescribedPredicate; +import com.tngtech.archunit.core.domain.JavaClass; import com.tngtech.archunit.core.domain.JavaMethod; import com.tngtech.archunit.core.domain.JavaModifier; import com.tngtech.archunit.core.importer.ImportOption; @@ -119,6 +121,16 @@ public class ArchitectureTest { .andShould().haveModifier(JavaModifier.STATIC) .andShould().haveModifier(JavaModifier.FINAL); + /** + * Every JsxConstant should be a string, int, or long. + */ + @ArchTest + public static final ArchRule jsxConstantType = fields() + .that().areAnnotatedWith(JsxConstant.class) + .should().haveRawType(String.class) + .orShould().haveRawType("int") + .orShould().haveRawType("long"); + /** * JsxGetter/Setter/Functions are always in the javascript package. */ @@ -144,25 +156,230 @@ public class ArchitectureTest { .should().beDeclaredInClassesThat().areAnnotatedWith(JsxClass.class) .orShould().beDeclaredInClassesThat().areAnnotatedWith(JsxClasses.class); - /** - * JsxConstants should not defined as short. - */ - @ArchTest - public static final ArchRule jsxConstantReturnType = fields() - .that().areAnnotatedWith(JsxConstant.class) - .should().notHaveRawType("short") - .andShould().notHaveRawType("float"); + private static final DescribedPredicate isAssignableToScriptable = + new DescribedPredicate("@is not assignable to Scriptable") { + @Override + public boolean test(final JavaClass javaClass) { + return javaClass.isAssignableTo(Scriptable.class); + } + }; /** - * JsxGetter/Setter/Functions should not return a short. + * JsxGetter should only return Scriptable's. */ @ArchTest - public static final ArchRule jsxAnnotationReturnType = methods() - .that().areAnnotatedWith(JsxGetter.class) - .or().areAnnotatedWith(JsxSetter.class) - .or().areAnnotatedWith(JsxFunction.class) - .should().notHaveRawReturnType("short") - .andShould().notHaveRawReturnType("float"); + public static final ArchRule jsxGetterReturnType = methods() + .that() + .areAnnotatedWith(JsxGetter.class) + .and().doNotHaveFullName("org.htmlunit.javascript.host.History.getState()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.MimeType.getEnabledPlugin()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Navigator.getDoNotTrack()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Navigator.getMimeTypes()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Navigator.getPlugins()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.URL.getOrigin()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getClientInformation()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getControllers()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getEvent()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getFrames_js()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getIsSecureContext()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getLength()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getOffscreenBuffering()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getOpener()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getParent()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getSelf()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.getTop()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.canvas.CanvasRenderingContext2D.getFillStyle()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.canvas.CanvasRenderingContext2D.getGlobalAlpha()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.canvas.CanvasRenderingContext2D.getLineWidth()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.canvas.CanvasRenderingContext2D.getStrokeStyle()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.css.CSSStyleDeclaration.getZIndex()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.AbstractRange.getEndContainer()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.AbstractRange.getStartContainer()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.CharacterData.getData()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.DOMException.getCode()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.DOMException.getFilename()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.DOMException.getLineNumber()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.DOMException.getMessage()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getActiveElement()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getAnchors()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getApplets()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getDefaultView()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getEmbeds()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getForms()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getHead()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getImages()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getLinks()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getPlugins()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getScripts()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.getParentNode()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.NodeIterator.getFilter()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Range.getCommonAncestorContainer()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.TreeWalker.getFilter()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.XPathResult.getNumberValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.draganddrop.DataTransferItem.getKind()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.draganddrop.DataTransferItem.getType()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.BeforeUnloadEvent.getReturnValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.CustomEvent.getDetail()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.Event.getComposed()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.Event.getReturnValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.Event.getSrcElement()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.Event.getTarget()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.HashChangeEvent.getNewURL()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.HashChangeEvent.getOldURL()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.InputEvent.getData()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.InputEvent.getInputType()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.MessageEvent.getData()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.MessageEvent.getPorts()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.PointerEvent.getAltitudeAngle()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.PointerEvent.getAzimuthAngle()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.PointerEvent.getPressure()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.PopStateEvent.getState()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.ProgressEvent.getLoaded()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.TextEvent.getData()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.event.UIEvent.getView()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.file.FileReader.getResult()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.geo.GeolocationCoordinates.getAccuracy()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.geo.GeolocationCoordinates.getLatitude()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.geo.GeolocationCoordinates.getLongitude()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLButtonElement.getValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLDataListElement.getOptions()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLElement.getOffsetParent_js()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLInputElement.getFiles()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLInputElement.getSelectionEnd()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLInputElement.getSelectionStart()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getHigh()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getLow()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getMax()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getMin()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getOptimum()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMeterElement.getValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLPreElement.getWidth_js()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLProgressElement.getMax()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLProgressElement.getValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.getCaption()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.getTBodies()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.getTFoot()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.getTHead()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableRowElement.getCells()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTextAreaElement.getMaxLength()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTextAreaElement.getMinLength()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTitleElement.getText()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.RowContainer.getRows()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.AudioParam.getDefaultValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.AudioParam.getMaxValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.AudioParam.getMinValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.AudioParam.getValue()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.network.NetworkInformation.getDownlink()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getA()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getB()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getC()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getD()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getE()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGMatrix.getF()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGRect.getHeight()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGRect.getWidth()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGRect.getX()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGRect.getY()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.worker.DedicatedWorkerGlobalScope.getSelf()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.xml.XMLHttpRequest.getResponse()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.xml.XMLHttpRequest.getResponseXML()") + + .should().haveRawReturnType(String.class) + .orShould().haveRawReturnType("int") + .orShould().haveRawReturnType("long") + .orShould().haveRawReturnType("boolean") + .orShould().haveRawReturnType(isAssignableToScriptable); + + /** + * JsxFunctions should only return Scriptable's. + */ + @ArchTest + public static final ArchRule jsxFunctionReturnType = methods() + .that() + .areAnnotatedWith(JsxFunction.class) + .and().doNotHaveFullName("org.htmlunit.javascript.host.Element.insertAdjacentElement(java.lang.String, java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.External.isSearchProviderInstalled()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.FontFaceSet.load(java.lang.String, java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.SimpleArray.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.SimpleArray.namedItem(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Storage.getItem(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.URLSearchParams.entries()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.URLSearchParams.keys()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.URLSearchParams.values()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.setInterval(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.Scriptable, [Ljava.lang.Object;, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.Window.setTimeout(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.Scriptable, [Ljava.lang.Object;, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.canvas.IntersectionObserver.takeRecords()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.decrypt()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.deriveBits()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.deriveKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.digest()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.encrypt()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.exportKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.generateKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.importKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.sign()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.unwrapKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.verify()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.crypto.SubtleCrypto.wrapKey()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.css.CSSRuleList.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.css.StyleSheetList.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.DOMTokenList.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.adoptNode(org.htmlunit.javascript.host.dom.Node)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createCDATASection(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createComment(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createDocumentFragment()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createElement(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createElementNS(java.lang.String, java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createProcessingInstruction(java.lang.String, java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createTextNode(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.createTreeWalker(org.htmlunit.javascript.host.dom.Node, double, org.htmlunit.corejs.javascript.Scriptable, boolean)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.elementFromPoint(int, int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Document.getElementsByTagNameNS(java.lang.Object, java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.appendChild(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.cloneNode(boolean)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.getRootNode()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.insertBefore(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.Scriptable, [Ljava.lang.Object;, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.removeChild(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Node.replaceChild(java.lang.Object, java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.NodeList.item(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Range.cloneRange()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Range.compareBoundaryPoints(int, org.htmlunit.javascript.host.dom.Range)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.dom.Text.splitText(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.file.Blob.arrayBuffer()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.file.Blob.text()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLCanvasElement.getContext(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLCollection.item(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLCollection.namedItem(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLDocument.open(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLFormControlsCollection.namedItem(java.lang.String)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLMediaElement.play()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLOptionsCollection.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLSelectElement.item(int)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.createCaption()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.createTBody()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.createTFoot()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableElement.createTHead()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.HTMLTableRowElement.insertCell(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.html.RowContainer.insertRow(java.lang.Object)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.intl.V8BreakIterator.resolvedOptions()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.BaseAudioContext.decodeAudioData(org.htmlunit.corejs.javascript.typedarrays.NativeArrayBuffer, org.htmlunit.corejs.javascript.Function, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.media.MediaDevices.getUserMedia()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.performance.Performance.now()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.performance.PerformanceNavigation.toJSON()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGPathElement.getTotalLength()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.svg.SVGTextContentElement.getComputedTextLength()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.worker.DedicatedWorkerGlobalScope.setInterval(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.Scriptable, [Ljava.lang.Object;, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.worker.DedicatedWorkerGlobalScope.setTimeout(org.htmlunit.corejs.javascript.Context, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.Scriptable, [Ljava.lang.Object;, org.htmlunit.corejs.javascript.Function)") + .and().doNotHaveFullName("org.htmlunit.javascript.host.xml.FormData.keys()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.xml.FormData.values()") + .and().doNotHaveFullName("org.htmlunit.javascript.host.xml.XSLTProcessor.getParameter(java.lang.String, java.lang.String)") + + .should().haveRawReturnType(String.class) + .orShould().haveRawReturnType("int") + .orShould().haveRawReturnType("long") + .orShould().haveRawReturnType("boolean") + .orShould().haveRawReturnType("void") + .orShould().haveRawReturnType(isAssignableToScriptable); /** * JsxConstructor should not used for constructors.