github web-platform-tests/wpt merge_pr_47347

latest releases: merge_pr_49470, epochs/three_hourly/2024-12-03_06H, epochs/six_hourly/2024-12-03_06H...
5 months ago

part 2: Make PresShell not use non-element event target when target frame is destroyed and the event wants Element target

When event target frame is destroyed, PresShell::NotifyDestroyingFrame updates
current event target content to the frame content. However, event target of
some DOM events need to be Element. Therefore,
PresShell::mCurrentEventTarget needs to store at least the handling
EventMessage to consider whether the event target can be non-element content
node or only element node. So, we need to make PresShell::EventTargetInfo
store EventMessage. Then, we can make PresShell::NotifyDestroyingFrame
prefer inclusive ancestor element as new event target from the EventMessage.

Although I don't understand what's going on the reported case, but I found the
simple case when event target is changed to a Text with the assertion in
PresShell::DispatchEventToDOM. Therefore, this patch has a new test.

Note that if target frame is a frame for element, e.g., when event target is
a focused element, IsForbiddenDispatchingToNonElementContent result won't
change the behavior. Therefore, its implementation is not optimized for
non-user input events.

Differential Revision: https://phabricator.services.mozilla.com/D217205

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1905267
gecko-commit: d4221479caa6db543c42cd236b82c22ddf677c19
gecko-reviewers: smaug

Don't miss a new wpt release

NewReleases is sending notifications on new releases.