Skip to content

XMLHttpRequest: Change to more consistent event invocation order - #287

Merged
rbri merged 1 commit into
HtmlUnit:masterfrom
atnak:xhr_event_invocation_order
Jan 7, 2021
Merged

XMLHttpRequest: Change to more consistent event invocation order#287
rbri merged 1 commit into
HtmlUnit:masterfrom
atnak:xhr_event_invocation_order

Conversation

@atnak

@atnak atnak commented Jan 7, 2021

Copy link
Copy Markdown
Contributor

Problem in brief

This PR changes the invocation order of events added to XMLHttpRequest, through both addEventListener() and on-handlers, to be more consistent with major browser such as Chrome / FF / IE, as well as other events already implemented in HtmlUnit that use EventTarget's framework.

Technical details

This is done by using the AT_TARGET invocation feature previously added to EventTarget, which is a more robust implementation than the custom implementation in XMLHttpRequest.

Consequently, the use of EventTarget.executeEventLocally() to handle XMLHttpRequest's events also has this added benefits:

  • window.currentEvent is now set correctly throughout the event invocation
  • event.eventPhase is set to a value consistent with major browsers

Notes

This commit changes the invocation order of events added to XMLHttpRequest,
through both addEventListener() and on-handlers, to be more consistent with
major browser such as Chrome / FF / IE, as well as other events already
implemented in HtmlUnit through EventTarget.

This is done by using the AT_TARGET invocation feature already supplied by
EventTarget in a prior commit which is of a more robust implementation
than the custom implementation in XMLHttpRequest.
@rbri
rbri merged commit ff368a9 into HtmlUnit:master Jan 7, 2021
@rbri

rbri commented Jan 7, 2021

Copy link
Copy Markdown
Member

Many thanks for this great contribution.

@atnak
atnak deleted the xhr_event_invocation_order branch January 8, 2021 02:04
rbri added a commit that referenced this pull request Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants