Skip to content

Commit

Permalink
test jsx getter and function return types
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Oct 16, 2024
1 parent 759fa09 commit 08de80d
Show file tree
Hide file tree
Showing 8 changed files with 282 additions and 63 deletions.
1 change: 1 addition & 0 deletions checkstyle_suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<suppress checks="JavadocPackage" files=".*Test.java|StandardsMode.java|StandardsMode.java|ElementTestSource.java|BrowserStatement.java|Patch.java|BrowserVersionClassRunnerWithParameters.java|ToRunWithRealBrowsers.java|PatchedHtmlUnitKeyboard.java|CanvasRenderingContext2D2Test2.java"/>
<suppress checks="JavadocMethod" files="HtmlDomTreeWalker.java" />

<suppress checks="LineLength" files="ArchitectureTest.java"/>
<suppress checks="LineLength" files="BrowserVersion.java"/>
<suppress checks="LineLength" files="JavaScriptEngine.java"/>
<suppress checks="LineLength" files="EncodingSniffer.java"/>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/htmlunit/javascript/host/MessagePort.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/htmlunit/javascript/host/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -1269,7 +1269,7 @@ public Object getOnblur() {
* @return the {@code onclick} property
*/
@JsxGetter
public Object getOnclick() {
public Function getOnclick() {
return getEventHandler(MouseEvent.TYPE_CLICK);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down
30 changes: 15 additions & 15 deletions src/main/java/org/htmlunit/javascript/host/dom/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public int getClientWidth() {
*/
@Override
@JsxGetter({CHROME, EDGE})
public Object getOnload() {
public Function getOnload() {
return super.getOnload();
}

Expand All @@ -240,7 +240,7 @@ public void setOnblur(final Object handler) {
*/
@Override
@JsxGetter({CHROME, EDGE})
public Object getOnblur() {
public Function getOnblur() {
return super.getOnblur();
}

Expand All @@ -258,7 +258,7 @@ public void setOnfocus(final Object handler) {
*/
@Override
@JsxGetter({CHROME, EDGE})
public Object getOnfocus() {
public Function getOnfocus() {
return super.getOnfocus();
}

Expand All @@ -276,7 +276,7 @@ public void setOnerror(final Object handler) {
*/
@Override
@JsxGetter({CHROME, EDGE})
public Object getOnerror() {
public Function getOnerror() {
return super.getOnerror();
}

Expand Down
Loading

0 comments on commit 08de80d

Please sign in to comment.