Closed Bug 2078813 Opened 1 month ago Closed 1 month ago

[wpt-sync] Sync PR 63303 - Keep following links when clicking controls inside them

Categories

(Core :: DOM: Core & HTML, task, P4)

task

Tracking

()

RESOLVED FIXED
160 Branch
Tracking Status
firefox160 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 63303 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/63303
Details from upstream follow.

Mason Freed <masonf@chromium.org> wrote:

Keep following links when clicking controls inside them

Before CleanUpActivationBehavior [1], activation behavior ran from
default event handlers (via DOMActivate). Those handlers bubble from
the target up the event path until one of them marks the click as
handled. For example, clicking \<a href>\<button>...\</button>\</a> ran
the button's default handler, which did nothing, and then the
anchor's default handler, which followed the link. Clicking the same
button when it submits or resets a form, or clicking a checkbox or
radio button, marks the click as handled, so the link is not
followed. Popover and command buttons do not mark the click as
handled, so both the popover/command and the link run. Gecko and
WebKit behave the same way for the simple button-in-link case.

CleanUpActivationBehavior moved activation behavior into
EventDispatcher, following the DOM Standard [2]: the activation
target is chosen before dispatch, and only its activation behavior
runs. Every \<button> and \<input> has activation behavior per the HTML
Standard [3][4], so a control inside a link always became the
activation target and the link was never followed. That broke
content.

The HTML Standard is likely to change to match what browsers do:

See https://github.com/whatwg/html/issues/10032#issuecomment-5879250134

This CL restores the legacy behavior under CleanUpActivationBehavior.
After the activation target's activation behavior runs, the
dispatcher walks the rest of the event path in bubbling order,
interleaved with the default event handlers. For each node after the
activation target that has activation behavior, it runs that
behavior, until the click is canceled or marked as handled. Whether a
node has activation behavior is checked at that point, after event
listeners have run, as the default event handlers did. This means
changes made during dispatch (e.g. changing a button's type, adding
commandfor/command or popovertarget, or giving the anchor an href)
have the same effect as before. Interleaving with the default event
handlers lets ancestors such as \<label>, whose click handling is in
its default event handler, handle the click before an enclosing link
is followed.

Tests:

  • New html/semantics/forms/the-button-element/
    controls-inside-link-activation.tentative.html covers \<button> and
    \<input> inside a link, for form submission and reset, popovertarget,
    commandfor/command, image, checkbox, radio, and controls without
    activation behavior. Each behavior is tested when present before
    the click, added during the click, and removed during the click.
    It also covers the link gaining or losing href during the click,
    and a canceled click. It passes with CleanUpActivationBehavior
    enabled and disabled. This test is tentative because it doesn't
    match the spec, but it does match browser behavior.
  • dom/events/Event-dispatch-single-activation-behavior.html gets a
    baseline with 7 failing subtests (e.g. \<a>\<label>\<button
    type=button>, where the link is followed). These assert the current
    spec.

See also: https://crrev.com/c/8278919/comment/37da8d8b_d452e3da/

[1] https://crrev.com/c/8278919
[2] https://dom.spec.whatwg.org/#concept-event-dispatch
[3] https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element:activation-behaviour
[4] https://html.spec.whatwg.org/multipage/input.html#the-input-element:activation-behaviour

Bug: 563000231
Change-Id: I48b5f2ffb58d08f9201b23188fb49a5bd5620b04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8463211
Auto-Submit: Mason Freed \<masonf@chromium.org>
Commit-Queue: David Baron \<dbaron@chromium.org>
Reviewed-by: David Baron \<dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1711896}

Component: web-platform-tests → DOM: Core & HTML
Product: Testing → Core

CI Results

Ran 11 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 220 tests and 4 subtests

Status Summary

Firefox

OK : 2[GitHub] 95[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS : 15[GitHub] 19[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 113[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 122[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview] 125[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 38[GitHub] 182[Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt] 263[Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 265[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview]
TIMEOUT: 3[Gecko-linux2204-64-wayland-debug, Gecko-linux2204-64-wayland-opt] 4[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
ERROR : 1
NOTRUN : 1

Chrome

OK : 2
PASS : 16
FAIL : 37

Safari

OK : 2
PASS : 49
FAIL : 4

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

Status: NEW → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 160 Branch
You need to log in before you can comment on or make changes to this bug.