[Platform-provided behaviors] Enable form submission [chromium/src : main]

0 views
Skip to first unread message

Ana Sollano Kim (Gerrit)

unread,
Apr 2, 2026, 2:58:35 PM (yesterday) Apr 2
to Dan Clark, Mason Freed, Leo Lee, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, AyeAye, blink-rev...@chromium.org, loading...@chromium.org, blink-revie...@chromium.org, dominicc+...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org
Attention needed from Dan Clark and Mason Freed

Ana Sollano Kim voted and added 1 comment

Votes added by Ana Sollano Kim

Commit-Queue+1

1 comment

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Ana Sollano Kim . resolved

Please take a look when you get the chance 😊

Open in Gerrit

Related details

Attention is currently required from:
  • Dan Clark
  • Mason Freed
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ifa93f060594e789a45d1b1809023427c4fcabf69
Gerrit-Change-Number: 7727461
Gerrit-PatchSet: 3
Gerrit-Owner: Ana Sollano Kim <anso...@microsoft.com>
Gerrit-Reviewer: Ana Sollano Kim <anso...@microsoft.com>
Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
Gerrit-CC: Leo Lee <leo...@microsoft.com>
Gerrit-CC: Nate Chapin <jap...@chromium.org>
Gerrit-Attention: Mason Freed <mas...@chromium.org>
Gerrit-Attention: Dan Clark <dan...@microsoft.com>
Gerrit-Comment-Date: Thu, 02 Apr 2026 18:58:25 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Dan Clark (Gerrit)

unread,
Apr 2, 2026, 9:56:26 PM (23 hours ago) Apr 2
to Ana Sollano Kim, Mason Freed, Leo Lee, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, AyeAye, blink-rev...@chromium.org, loading...@chromium.org, blink-revie...@chromium.org, dominicc+...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org
Attention needed from Ana Sollano Kim and Mason Freed

Dan Clark added 14 comments

Patchset-level comments
Dan Clark . resolved

Great to see this coming together!

File third_party/blink/renderer/core/html/custom/element_internals.cc
Line 454, Patchset 3 (Latest): DCHECK(RuntimeEnabledFeatures::ElementInternalsBehaviorsEnabled());
Dan Clark . unresolved

Can this be `CHECK`?

File third_party/blink/renderer/core/html/forms/html_form_element.cc
Line 563, Patchset 3 (Latest): if (submit_button) {
Dan Clark . unresolved

I think we should still do this stuff in the `behavior` case. Any reason not to? We're looking for stuff associated with the form, not the button, so this should still work in the same way.

Line 632, Patchset 3 (Latest): submit_event_init->setSubmitter(event_submitter);
Dan Clark . unresolved

Can this whole thing just be this, without the dual casting with `event_submitter`?
`submit_event_init->setSubmitter(DynamicTo<HTMLElement>(submitter));`

File third_party/blink/renderer/core/html/forms/html_submit_button_behavior.cc
Line 41, Patchset 3 (Latest): if (!internals) {
Dan Clark . unresolved

Does it make sense to `CHECK` that we have an internals if `HandleActivation` is called? I'm not sure how it could be triggered if no element is associated.

Line 58, Patchset 3 (Latest): return disabled_ || (internals && internals->IsActuallyDisabled());
Dan Clark . unresolved

Seems `internals->IsActuallyDisabled()` does things like inherit the disabled state from ancestor elements. Are there tests that can be added for that?

File third_party/blink/renderer/core/html/html_element.cc
Line 197, Patchset 3 (Latest):HTMLSubmitButtonBehavior* FindSubmitBehavior(const HTMLElement& element) {
Dan Clark . unresolved

This helper is implemented in a couple places. Consider just putting it on Element (`SubmitBehavior()` would probably be a better name in that case).

File third_party/blink/renderer/core/loader/form_submission.cc
Line 304, Patchset 3 (Latest): if (behavior && !behavior->name().empty()) {
Dan Clark . unresolved

For my own understanding, where is the equivalent happening for the `HTMLFormControlElement` submitter case?

File third_party/blink/web_tests/external/wpt/custom-elements/form-associated/ElementInternals-submit-behavior.tentative.html
Line 60, Patchset 3 (Latest):function clickSubmitsForm(element) {
Dan Clark . unresolved

It'd be great to also use testdriver.js to ensure that user-initiated actions also submit the form, for:
-- user clicks on the custom element
-- user hits 'enter' on the custom element
-- user hits 'space' on the custom element
-- anything else I'm forgetting?

Or feel free to add these in a follow-up CL.

Line 200, Patchset 3 (Latest):promise_test(async () => {
Dan Clark . unresolved

Can you include tests for `formenctype` and `formmethod`, too?

Line 282, Patchset 3 (Latest):}, 'formAction on HTMLSubmitButtonBehavior overrides form action');
Dan Clark . unresolved

How is this test validating `'formAction on HTMLSubmitButtonBehavior overrides form action'`? `submitAndGetQuery` only checks `window.location.search` rather than the path name so it seems to me like this would pass whether the form sent the data to `'/should-not-be-used.html'` or to `'/common/blank.html'`.

Line 294, Patchset 3 (Latest): await submitAndCollectFormData(customSubmit);
Dan Clark . unresolved

Since this isn't using the result of `submitAndCollectFormData`, it's maybe simpler to do `assert_true(clickSubmitsForm(customSubmit), ...)` rather than reimplementing the `onsubmit` check inside this test.

Line 319, Patchset 3 (Latest): customSubmit.setAttribute('form', 'test-form');
Dan Clark . unresolved

This one is kind of interesting. We're using the attribute directly from the custom element rather than requiring it to be plumbed through to the behavior. In other cases like `disabled` we ignore the attr value on the custom element unless it's been plumbed through.

Is this the right behavior? Is it worth discussing more?

Line 333, Patchset 3 (Latest): this.attachInternals({ behaviors: [new HTMLSubmitButtonBehavior()] });
Dan Clark . unresolved

It doesn't need to be part of this change, but an idle thought: should we emit a console warning when someone uses SubmitButtonBehavior on a non-form-associated custom element? That seems like it'll be a common mistake.

Open in Gerrit

Related details

Attention is currently required from:
  • Ana Sollano Kim
  • Mason Freed
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ifa93f060594e789a45d1b1809023427c4fcabf69
    Gerrit-Change-Number: 7727461
    Gerrit-PatchSet: 3
    Gerrit-Owner: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Leo Lee <leo...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Attention: Mason Freed <mas...@chromium.org>
    Gerrit-Comment-Date: Fri, 03 Apr 2026 01:56:15 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    2:27 PM (7 hours ago) 2:27 PM
    to Ana Sollano Kim, Dan Clark, Leo Lee, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, AyeAye, blink-rev...@chromium.org, loading...@chromium.org, blink-revie...@chromium.org, dominicc+...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org
    Attention needed from Ana Sollano Kim

    Mason Freed voted and added 4 comments

    Votes added by Mason Freed

    Code-Review+1

    4 comments

    Patchset-level comments
    Mason Freed . resolved

    Dan's review is great. Other than his comments, just one nit of my own. So I'll mark it LGTM for now, from me.

    File third_party/blink/renderer/core/html/forms/html_form_element.cc
    Line 563, Patchset 3 (Latest): if (submit_button) {
    Dan Clark . unresolved

    I think we should still do this stuff in the `behavior` case. Any reason not to? We're looking for stuff associated with the form, not the button, so this should still work in the same way.

    Mason Freed

    +1, I think this is a bug. As-is, if submitting via a custom element, the use counters and unclosed element checks will be skipped.

    Line 627, Patchset 3 (Latest): // For behaviors, use `submitter` instead of `submit_button`.
    Mason Freed . unresolved

    I find the one-or-the-other behavior a bit confusing. Perhaps just add this here, to clarify it a little bit?

    ```
    CHECK(!submitter || !submit_button);
    ```

    File third_party/blink/renderer/core/loader/form_submission.cc
    Line 305, Patchset 3 (Latest): dom_form_data->AppendFromElement(behavior->name(), behavior->value());
    Mason Freed . unresolved

    Maybe add

    ```
    CHECK(!submit_button);
    ```

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ana Sollano Kim
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ifa93f060594e789a45d1b1809023427c4fcabf69
    Gerrit-Change-Number: 7727461
    Gerrit-PatchSet: 3
    Gerrit-Owner: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Leo Lee <leo...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Comment-Date: Fri, 03 Apr 2026 18:27:35 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Dan Clark <dan...@microsoft.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Mason Freed (Gerrit)

    unread,
    7:32 PM (1 hour ago) 7:32 PM
    to Ana Sollano Kim, Dan Clark, Leo Lee, Chromium LUCI CQ, chromium...@chromium.org, Nate Chapin, AyeAye, blink-re...@chromium.org, blink-rev...@chromium.org, loading...@chromium.org, blink-revie...@chromium.org, dominicc+...@chromium.org, blink-...@chromium.org, gavinp...@chromium.org
    Attention needed from Ana Sollano Kim

    Mason Freed voted and added 3 comments

    Votes added by Mason Freed

    Code-Review+1

    3 comments

    Patchset-level comments
    File-level comment, Patchset 6 (Latest):
    Mason Freed . resolved

    Still LGTM from me.

    File third_party/blink/renderer/core/html/forms/html_form_element.cc
    Line 627, Patchset 3: // For behaviors, use `submitter` instead of `submit_button`.
    Mason Freed . resolved

    I find the one-or-the-other behavior a bit confusing. Perhaps just add this here, to clarify it a little bit?

    ```
    CHECK(!submitter || !submit_button);
    ```

    Mason Freed

    Done

    File third_party/blink/renderer/core/loader/form_submission.cc
    Line 305, Patchset 3: dom_form_data->AppendFromElement(behavior->name(), behavior->value());
    Mason Freed . resolved

    Maybe add

    ```
    CHECK(!submit_button);
    ```

    Mason Freed

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ana Sollano Kim
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement satisfiedCode-Owners
    • requirement satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ifa93f060594e789a45d1b1809023427c4fcabf69
    Gerrit-Change-Number: 7727461
    Gerrit-PatchSet: 6
    Gerrit-Owner: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Reviewer: Dan Clark <dan...@microsoft.com>
    Gerrit-Reviewer: Mason Freed <mas...@chromium.org>
    Gerrit-CC: Leo Lee <leo...@microsoft.com>
    Gerrit-CC: Nate Chapin <jap...@chromium.org>
    Gerrit-Attention: Ana Sollano Kim <anso...@microsoft.com>
    Gerrit-Comment-Date: Fri, 03 Apr 2026 23:32:18 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: Yes
    Comment-In-Reply-To: Mason Freed <mas...@chromium.org>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages