Changeset 286988 in webkit


Ignore:
Timestamp:
Dec 13, 2021 3:31:19 PM (7 months ago)
Author:
commit-queue@webkit.org
Message:

A FormData constructed in the form's submit event listener shouldn't include the submitter
https://bugs.webkit.org/show_bug.cgi?id=234069

Patch by Andreu Botella <andreu@andreubotella.com> on 2021-12-13
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt:

Source/WebCore:

In the HTML spec, the "construct the entry list" algorithm takes an optional submitter
argument which it uses to determine whether a button should be included in the entry list.
The FormData constructor calls it with no optional arguments, so new FormData(form) should
never contain any buttons.

In WebKit, however, if a FormData object is constructed in the form's submit event
listener, it will contain the submitter button, if the form submission wasn't implicit. This
is because whether a form control is the submitter is tracked on the control, and activating
it sets that state for the duration of the form submission algorithm.

However, the form submission algorithm also sets a submitter's state, to deal with implicit
submissions. This is set only for the duration of the "construct the entry list" call, and
so there is no need to set the state when activating the button.

Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set.html

  • html/HTMLButtonElement.cpp:

(WebCore::HTMLButtonElement::defaultEventHandler):

  • html/ImageInputType.cpp:

(WebCore::ImageInputType::handleDOMActivateEvent):

  • html/SubmitInputType.cpp:

(WebCore::SubmitInputType::handleDOMActivateEvent):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r286972 r286988  
     12021-12-13  Andreu Botella  <andreu@andreubotella.com>
     2
     3        A FormData constructed in the form's submit event listener shouldn't include the submitter
     4        https://bugs.webkit.org/show_bug.cgi?id=234069
     5
     6        Reviewed by Chris Dumez.
     7
     8        * web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt:
     9
    1102021-12-13  Antti Koivisto  <antti@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt

    r286427 r286988  
    2222PASS Entries added to "formData" IDL attribute should be submitted.
    2323PASS Entries added to the "formdata" IDL attribute shouldn't be newline normalized in the resulting FormData
    24 FAIL The constructed FormData object should not contain an entry for the submit button that was used to submit the form. assert_false: expected false got true
     24PASS The constructed FormData object should not contain an entry for the submit button that was used to submit the form.
    2525
  • trunk/Source/WebCore/ChangeLog

    r286983 r286988  
     12021-12-13  Andreu Botella  <andreu@andreubotella.com>
     2
     3        A FormData constructed in the form's submit event listener shouldn't include the submitter
     4        https://bugs.webkit.org/show_bug.cgi?id=234069
     5
     6        Reviewed by Chris Dumez.
     7
     8        In the HTML spec, the "construct the entry list" algorithm takes an optional `submitter`
     9        argument which it uses to determine whether a button should be included in the entry list.
     10        The FormData constructor calls it with no optional arguments, so `new FormData(form)` should
     11        never contain any buttons.
     12
     13        In WebKit, however, if a `FormData` object is constructed in the form's `submit` event
     14        listener, it will contain the submitter button, if the form submission wasn't implicit. This
     15        is because whether a form control is the submitter is tracked on the control, and activating
     16        it sets that state for the duration of the form submission algorithm.
     17
     18        However, the form submission algorithm also sets a submitter's state, to deal with implicit
     19        submissions. This is set only for the duration of the "construct the entry list" call, and
     20        so there is no need to set the state when activating the button.
     21
     22        Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set.html
     23
     24        * html/HTMLButtonElement.cpp:
     25        (WebCore::HTMLButtonElement::defaultEventHandler):
     26        * html/ImageInputType.cpp:
     27        (WebCore::ImageInputType::handleDOMActivateEvent):
     28        * html/SubmitInputType.cpp:
     29        (WebCore::SubmitInputType::handleDOMActivateEvent):
     30
    1312021-12-13  Jean-Yves Avenard  <jya@apple.com>
    232
  • trunk/Source/WebCore/html/HTMLButtonElement.cpp

    r286762 r286988  
    147147            if (auto currentForm = form()) {
    148148                if (m_type == SUBMIT) {
    149                     SetForScope<bool> activatedSubmitState(m_isActivatedSubmit, true);
    150149                    currentForm->submitIfPossible(&event, this);
    151150                }
  • trunk/Source/WebCore/html/ImageInputType.cpp

    r286447 r286988  
    8888    Ref<HTMLFormElement> protectedForm(*protectedElement->form());
    8989
    90     protectedElement->setActivatedSubmit(true);
    91 
    9290    m_clickLocation = IntPoint();
    9391    if (event.underlyingEvent()) {
     
    107105        currentForm->submitIfPossible(&event); // Event handlers can run.
    108106
    109     protectedElement->setActivatedSubmit(false);
    110107    event.setDefaultHandled();
    111108}
  • trunk/Source/WebCore/html/SubmitInputType.cpp

    r286447 r286988  
    7575    protectedElement->document().updateLayoutIgnorePendingStylesheets();
    7676
    77     protectedElement->setActivatedSubmit(true);
    7877    if (RefPtr currentForm = protectedElement->form())
    7978        currentForm->submitIfPossible(&event, element()); // Event handlers can run.
    80     protectedElement->setActivatedSubmit(false);
    8179    event.setDefaultHandled();
    8280}
Note: See TracChangeset for help on using the changeset viewer.