Bring event host tests to WheelEvent-level coverage#1118
Draft
Copilot wants to merge 3 commits into
Draft
Conversation
Agent-Logs-Url: https://github.com/HtmlUnit/htmlunit/sessions/ce4e3b93-a5c2-46db-87b4-6f72659e8ee3 Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Agent-Logs-Url: https://github.com/HtmlUnit/htmlunit/sessions/ce4e3b93-a5c2-46db-87b4-6f72659e8ee3 Co-authored-by: rbri <2544132+rbri@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add test methods for event classes based on WheelEventTest
Bring event host tests to WheelEvent-level coverage
May 12, 2026
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR raises event host coverage in
org.htmlunit.javascript.host.eventto the same constructor/createEvent/in-window detail level used byWheelEventTest. It fills the missing standard test matrix across existing event tests and adds coverage for event classes that previously had no dedicated test file.Expand existing event tests
null, unknown symbol, arbitrary typedocument.createEvent(...)'EventName' in windowNormalize event dumps
WheelEventTestpattern:type,bubbles,cancelable,composedPopStateEvent→stateCloseEvent→code,reason,wasCleanHashChangeEvent→oldURL,newURLPointerEvent→ pointer-specific fields includingpersistentDeviceIdUIEvent→detail,view,whichAdd missing test classes
ClipboardEventTestIDBVersionChangeEventTestMIDIConnectionEventTestMIDIMessageEventTestMediaEncryptedEventTestMediaKeyMessageEventTestMediaQueryListEventTestMediaStreamEventTestMediaStreamTrackEventTestMouseScrollEventTestPromiseRejectionEventTestRTCDataChannelEventTestRTCPeerConnectionIceEventTestSecurityPolicyViolationEventTestSpeechSynthesisEventTestKeep browser support explicit
@JsxClass({CHROME, EDGE})→ defaultReferenceErrorfor Firefox@JsxClass({FF, FF_ESR})→ defaultReferenceErrorfor ChromiumExample of the standardized shape now used across event tests:
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
central.sonatype.com/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/htmlunit/htmlunit org.codehaus.plexus.classworlds.launcher.Launcher -Dtest=WheelEventTest,PopStateEventTest,WebGLContextEventTest test(dns block)/usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.14/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.14/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.14 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.14/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/htmlunit/htmlunit org.codehaus.plexus.classworlds.launcher.Launcher -Dtest=PopStateEventTest,UIEventTest,PointerEventTest,ClipboardEventTest,MouseScrollEventTest test grep crip�� g/htmlunit/javascript/host/event/UIEvent.java git /PointerEvent.java d " "$f" | sed "getopt --global java grep(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Goal
Every test class in
src/test/java/org/htmlunit/javascript/host/event/must reach the same detail level asWheelEventTest— the reference implementation.The Standard Test Pattern
Study
WheelEventTestcarefully — it is the reference. Every event test class must contain (at minimum) these 10 test methods, adapted for the specific event class:Required test methods (adapt alerts per browser support):
create_ctor—new EventName('type'), dump eventcreate_ctorWithoutType—new EventName()with no args →TypeError(use@HtmlUnitNYIif HtmlUnit doesn't throw)create_ctorNumericType—new EventName(42)→ works, logs42as typecreate_ctorNullType—new EventName(null)→ works, logsnullas typecreate_ctorUnknownType—new EventName(unknown)→ReferenceErrorcreate_ctorArbitraryType—new EventName('HtmlUnitEvent')→ workscreate_ctorAllDetails— full init dict with event-specific fields (bubbles, cancelable, composed, plus any event-class fields)create_ctorAllDetailsMissingData— empty init dict{}create_createEvent—document.createEvent('EventName')→NotSupportedError/DOMExceptioninWindow—'EventName' in window→trueorfalsedepending on browser supportBrowser-restriction rules:
@JsxClasshas no browser restriction → all browsers supported →@Alerts("true")forinWindow, no per-browser@Alertssplits needed for constructors@JsxClass({CHROME, EDGE})→DEFAULT = "ReferenceError"(FF/FF_ESR), specific Chrome/Edge alerts@JsxClass({FF, FF_ESR})→DEFAULT = "ReferenceError"(Chrome/Edge), specific FF alertsWork Items
A. Fix
PopStateEventTest(existing file needs enhancement)The existing file has
create_ctor,create_ctorWithDetails,create_createEvent,setState,dispatchEvent,dispatchEventWithoutInit,initPopStateEvent. Keep all existing tests. Add the missing standard tests:create_ctorWithoutType→TypeError(all browsers,@HtmlUnitNYIif needed)create_ctorNumericTypecreate_ctorNullTypecreate_ctorUnknownTypecreate_ctorArbitraryTypecreate_ctorAllDetailsMissingData—new PopStateEvent('popstate', {})inWindow→@Alerts("true")The DUMP_EVENT_FUNCTION for PopStateEvent logs:
event,event.type,event.bubbles,event.cancelable,event.composed,event.state.B. Enhance existing test files that lack standard tests
For each file below, read the current content and the corresponding main source class, then add all missing standard test methods. Keep all existing tests. Also add/update the
DUMP_EVENT_FUNCTIONif it doesn't log the standard 5 base properties yet, and add event-class-specific properties to the dump if the main source exposes them via@JsxGetter.Files to enhance (read each to see what's currently missing):
AudioProcessingEventTest— main:AudioProcessingEvent.java(check browser restrictions and any getters)BeforeInstallPromptEventTest— main:BeforeInstallPromptEvent.javaBeforeUnloadEventTest— main:BeforeUnloadEvent.javaBlobEventTest— main:BlobEvent.javaCloseEventTest— main:CloseEvent.java(hascode,reason,wasCleangetters — include in dump andcreate_ctorAllDetails)CompositionEventTest— main:CompositionEvent.javaCustomEventTest— main:CustomEvent.java(hasdetailgetter)DeviceMotionEventTest— main:DeviceMotionEvent.javaDeviceOrientationEventTest— main:DeviceOrientationEvent.javaDragEventTest— main:DragEvent.javaErrorEventTest— main:ErrorEvent.java(hasmessage,filename,lineno,colno,errorgetters)FocusEventTest— main:FocusEvent.javaGamepadEventTest— main:GamepadEvent.javaHashChangeEventTest— main:HashChangeEvent.java(hasoldURL,newURLgetters)InputEventTest— main:InputEvent.javaOfflineAudioCompletionEventTest— main:OfflineAudioCompletionEvent.javaPageTransitionEventTest— main:PageTransitionEvent.java(haspersistedgetter)PointerEventTest— main:PointerEvent.javaStorageEventTest— main:StorageEvent.javaSubmitEventTest— main:SubmitEvent.javaTextEventTest— main:TextEvent.javaTimeEventTest— main:TimeEvent.javaTouchEventTest— main:TouchEvent.javaTrackEventTest— main:TrackEvent.javaTransitionEventTest— main:TransitionEvent.javaThis pull request was created from Copilot chat.