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 28661e4149..205a6049bc 100644 --- a/src/main/java/org/htmlunit/javascript/host/dom/Document.java +++ b/src/main/java/org/htmlunit/javascript/host/dom/Document.java @@ -777,7 +777,7 @@ public String getCharset() { * @return the value of this property */ @JsxGetter - public Object getAnchors() { + public HTMLCollection getAnchors() { final HTMLCollection anchors = new HTMLCollection(getDomNodeOrDie(), true); anchors.setIsMatchingPredicate( @@ -812,7 +812,7 @@ public Object getAnchors() { * @return the value of this property */ @JsxGetter - public Object getApplets() { + public HTMLCollection getApplets() { return new HTMLCollection(getDomNodeOrDie(), false); } @@ -1658,7 +1658,7 @@ public Object elementFromPoint(final int x, final int y) { * @return the value of the {@code forms} property */ @JsxGetter - public Object getForms() { + public HTMLCollection getForms() { final HTMLCollection forms = new HTMLCollection(getDomNodeOrDie(), false) { @Override public Object call(final Context cx, final Scriptable scope, @@ -1678,7 +1678,7 @@ public Object call(final Context cx, final Scriptable scope, * @return the value of the {@code embeds} property */ @JsxGetter - public Object getEmbeds() { + public HTMLCollection getEmbeds() { final HTMLCollection embeds = new HTMLCollection(getDomNodeOrDie(), false) { @Override public Object call(final Context cx, final Scriptable scope, @@ -1696,7 +1696,7 @@ public Object call(final Context cx, final Scriptable scope, * @return the value of the {@code embeds} property */ @JsxGetter - public Object getImages() { + public HTMLCollection getImages() { final HTMLCollection images = new HTMLCollection(getDomNodeOrDie(), false) { @Override public Object call(final Context cx, final Scriptable scope, @@ -1714,7 +1714,7 @@ public Object call(final Context cx, final Scriptable scope, * @return the value of the {@code scripts} property */ @JsxGetter - public Object getScripts() { + public HTMLCollection getScripts() { final HTMLCollection scripts = new HTMLCollection(getDomNodeOrDie(), false) { @Override public Object call(final Context cx, final Scriptable scope, @@ -1747,7 +1747,7 @@ public StyleSheetList getStyleSheets() { * @return the value of the {@code plugins} property */ @JsxGetter - public Object getPlugins() { + public HTMLCollection getPlugins() { return getEmbeds(); } @@ -1757,7 +1757,7 @@ public Object getPlugins() { * @return the value of this property */ @JsxGetter - public Object getLinks() { + public HTMLCollection getLinks() { final HTMLCollection links = new HTMLCollection(getDomNodeOrDie(), true); links.setEffectOnCacheFunction( diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLDataListElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLDataListElement.java index faa2ba3a4d..19f20daeb1 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLDataListElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLDataListElement.java @@ -49,7 +49,7 @@ public void jsConstructor() { * @return the {@code options} attribute */ @JsxGetter - public Object getOptions() { + public HTMLCollection getOptions() { if (options_ == null) { options_ = new HTMLCollection(getDomNodeOrDie(), false); options_.setIsMatchingPredicate( 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 ec00dccdcc..cd33fe6f8d 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLElement.java @@ -1076,11 +1076,11 @@ public int getOffsetTop() { * @see Reverse Engineering by Anne van Kesteren */ @JsxGetter(propertyName = "offsetParent") - public Object getOffsetParent_js() { + public HtmlUnitScriptable getOffsetParent_js() { return getOffsetParentInternal(getBrowserVersion().hasFeature(JS_OFFSET_PARENT_NULL_IF_FIXED)); } - private Object getOffsetParentInternal(final boolean returnNullIfFixed) { + private HtmlUnitScriptable getOffsetParentInternal(final boolean returnNullIfFixed) { DomNode currentElement = getDomNodeOrDie(); if (currentElement.getParentNode() == null) { diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLInputElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLInputElement.java index 5d9e22ef46..4deaf9df4d 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLInputElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLInputElement.java @@ -215,7 +215,7 @@ public int getTextLength() { * @return the selection start */ @JsxGetter - public Object getSelectionStart() { + public Integer getSelectionStart() { final DomNode dom = getDomNodeOrDie(); if (dom instanceof SelectableTextInput) { if ("number".equalsIgnoreCase(getType())) { @@ -256,7 +256,7 @@ public void setSelectionStart(final int start) { * @return the selection end */ @JsxGetter - public Object getSelectionEnd() { + public Integer getSelectionEnd() { final DomNode dom = getDomNodeOrDie(); if (dom instanceof SelectableTextInput) { if ("number".equalsIgnoreCase(getType())) { @@ -622,7 +622,7 @@ public void setAutocomplete(final String autocomplete) { * @return the {@code files} property */ @JsxGetter - public Object getFiles() { + public FileList getFiles() { final HtmlInput htmlInput = getDomNodeOrDie(); if (htmlInput instanceof HtmlFileInput) { final FileList list = new FileList(((HtmlFileInput) htmlInput).getFiles()); diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLPreElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLPreElement.java index 133897ecf9..d610093627 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLPreElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLPreElement.java @@ -47,7 +47,7 @@ public void jsConstructor() { * @return the {@code width} property */ @JsxGetter(propertyName = "width") - public Object getWidth_js() { + public Integer getWidth_js() { final String value = getDomNodeOrDie().getAttributeDirect("width"); final Integer intValue = HTMLCanvasElement.getValue(value); if (intValue != null) { diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLTableElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLTableElement.java index e0b816394b..3aed4f8250 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLTableElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLTableElement.java @@ -26,6 +26,7 @@ import org.htmlunit.html.HtmlTableFooter; import org.htmlunit.html.HtmlTableHeader; import org.htmlunit.html.HtmlTableRow; +import org.htmlunit.javascript.HtmlUnitScriptable; import org.htmlunit.javascript.JavaScriptEngine; import org.htmlunit.javascript.configuration.JsxClass; import org.htmlunit.javascript.configuration.JsxConstructor; @@ -63,7 +64,7 @@ public void jsConstructor() { * @return the table's caption element */ @JsxGetter - public Object getCaption() { + public HtmlUnitScriptable getCaption() { final List captions = getDomNodeOrDie().getElementsByTagName("caption"); if (captions.isEmpty()) { return null; @@ -94,7 +95,7 @@ public void setCaption(final Object o) { * @return the table's tfoot element */ @JsxGetter - public Object getTFoot() { + public HtmlUnitScriptable getTFoot() { final List tfoots = getDomNodeOrDie().getElementsByTagName("tfoot"); if (tfoots.isEmpty()) { return null; @@ -126,7 +127,7 @@ public void setTFoot(final Object o) { * @return the table's thead element */ @JsxGetter - public Object getTHead() { + public HtmlUnitScriptable getTHead() { final List theads = getDomNodeOrDie().getElementsByTagName("thead"); if (theads.isEmpty()) { return null; @@ -157,7 +158,7 @@ public void setTHead(final Object o) { * @return the tbody's in the table */ @JsxGetter - public Object getTBodies() { + public HtmlUnitScriptable getTBodies() { final HtmlTable table = (HtmlTable) getDomNodeOrDie(); final HTMLCollection bodies = new HTMLCollection(table, false); bodies.setElementsSupplier((Supplier> & Serializable) () -> new ArrayList<>(table.getBodies())); diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLTableRowElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLTableRowElement.java index 5a59ddbacd..1b311fce1d 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLTableRowElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLTableRowElement.java @@ -96,7 +96,7 @@ public int getSectionRowIndex() { * @return the cells in the row */ @JsxGetter - public Object getCells() { + public HTMLCollection getCells() { final HtmlTableRow row = (HtmlTableRow) getDomNodeOrDie(); final HTMLCollection cells = new HTMLCollection(row, false); diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLTextAreaElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLTextAreaElement.java index acfe777506..a823f3cdf5 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLTextAreaElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLTextAreaElement.java @@ -267,7 +267,7 @@ public void setReadOnly(final boolean readOnly) { * @return the maximum number of characters in this text area */ @JsxGetter - public Object getMaxLength() { + public int getMaxLength() { final String maxLength = getDomNodeOrDie().getAttribute("maxLength"); try { @@ -303,7 +303,7 @@ public void setMaxLength(final String maxLength) { * @return the minimum number of characters in this text area */ @JsxGetter - public Object getMinLength() { + public int getMinLength() { final String minLength = getDomNodeOrDie().getAttribute("minLength"); try { diff --git a/src/main/java/org/htmlunit/javascript/host/html/HTMLTitleElement.java b/src/main/java/org/htmlunit/javascript/host/html/HTMLTitleElement.java index 76f0f89089..1b0a76524c 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/HTMLTitleElement.java +++ b/src/main/java/org/htmlunit/javascript/host/html/HTMLTitleElement.java @@ -44,7 +44,7 @@ public void jsConstructor() { * @return the {@code text} attribute */ @JsxGetter - public Object getText() { + public String getText() { final HtmlTitle htmlTitle = (HtmlTitle) getDomNodeOrDie(); return htmlTitle.getText(); } diff --git a/src/main/java/org/htmlunit/javascript/host/html/RowContainer.java b/src/main/java/org/htmlunit/javascript/host/html/RowContainer.java index 2712712bc1..d3d3309dec 100644 --- a/src/main/java/org/htmlunit/javascript/host/html/RowContainer.java +++ b/src/main/java/org/htmlunit/javascript/host/html/RowContainer.java @@ -45,7 +45,7 @@ public class RowContainer extends HTMLElement { * @return the rows in the element */ @JsxGetter - public Object getRows() { + public HTMLCollection getRows() { final HTMLCollection rows = new HTMLCollection(getDomNodeOrDie(), false); rows.setIsMatchingPredicate( (Predicate & Serializable) diff --git a/src/test/java/org/htmlunit/archunit/ArchitectureTest.java b/src/test/java/org/htmlunit/archunit/ArchitectureTest.java index 8bc4c035a8..adde655f2d 100644 --- a/src/test/java/org/htmlunit/archunit/ArchitectureTest.java +++ b/src/test/java/org/htmlunit/archunit/ArchitectureTest.java @@ -201,16 +201,8 @@ public boolean test(final JavaClass javaClass) { .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()") @@ -230,63 +222,22 @@ public boolean test(final JavaClass javaClass) { .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(Integer.class) .orShould().haveRawReturnType("long") + .orShould().haveRawReturnType("double") + .orShould().haveRawReturnType(Double.class) .orShould().haveRawReturnType("boolean") .orShould().haveRawReturnType(isAssignableToScriptable);