Title: [286988] trunk
Revision
286988
Author
commit-qu...@webkit.org
Date
2021-12-13 15:31:19 -0800 (Mon, 13 Dec 2021)

Log 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 <and...@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):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (286987 => 286988)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-13 23:31:19 UTC (rev 286988)
@@ -1,3 +1,12 @@
+2021-12-13  Andreu Botella  <and...@andreubotella.com>
+
+        A FormData constructed in the form's submit event listener shouldn't include the submitter
+        https://bugs.webkit.org/show_bug.cgi?id=234069
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt:
+
 2021-12-13  Antti Koivisto  <an...@apple.com>
 
         [CSS Cascade Layers] Layers specified in import rules can not be reordered on media query evaluation

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt (286987 => 286988)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt	2021-12-13 23:31:19 UTC (rev 286988)
@@ -21,5 +21,5 @@
 PASS "formData" IDL attribute should have entries for form-associated elements in the first event handler, and the second handler can read entries set by the first handler.
 PASS Entries added to "formData" IDL attribute should be submitted.
 PASS Entries added to the "formdata" IDL attribute shouldn't be newline normalized in the resulting FormData
-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
+PASS The constructed FormData object should not contain an entry for the submit button that was used to submit the form.
 

Modified: trunk/Source/WebCore/ChangeLog (286987 => 286988)


--- trunk/Source/WebCore/ChangeLog	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/Source/WebCore/ChangeLog	2021-12-13 23:31:19 UTC (rev 286988)
@@ -1,3 +1,33 @@
+2021-12-13  Andreu Botella  <and...@andreubotella.com>
+
+        A FormData constructed in the form's submit event listener shouldn't include the submitter
+        https://bugs.webkit.org/show_bug.cgi?id=234069
+
+        Reviewed by Chris Dumez.
+
+        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):
+
 2021-12-13  Jean-Yves Avenard  <j...@apple.com>
 
         Add SharedBufferBuilder class

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (286987 => 286988)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-12-13 23:31:19 UTC (rev 286988)
@@ -146,7 +146,6 @@
 
             if (auto currentForm = form()) {
                 if (m_type == SUBMIT) {
-                    SetForScope<bool> activatedSubmitState(m_isActivatedSubmit, true);
                     currentForm->submitIfPossible(&event, this);
                 }
 

Modified: trunk/Source/WebCore/html/ImageInputType.cpp (286987 => 286988)


--- trunk/Source/WebCore/html/ImageInputType.cpp	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/Source/WebCore/html/ImageInputType.cpp	2021-12-13 23:31:19 UTC (rev 286988)
@@ -87,8 +87,6 @@
 
     Ref<HTMLFormElement> protectedForm(*protectedElement->form());
 
-    protectedElement->setActivatedSubmit(true);
-
     m_clickLocation = IntPoint();
     if (event.underlyingEvent()) {
         Event& underlyingEvent = *event.underlyingEvent();
@@ -106,7 +104,6 @@
     if (auto currentForm = protectedElement->form())
         currentForm->submitIfPossible(&event); // Event handlers can run.
 
-    protectedElement->setActivatedSubmit(false);
     event.setDefaultHandled();
 }
 

Modified: trunk/Source/WebCore/html/SubmitInputType.cpp (286987 => 286988)


--- trunk/Source/WebCore/html/SubmitInputType.cpp	2021-12-13 23:14:37 UTC (rev 286987)
+++ trunk/Source/WebCore/html/SubmitInputType.cpp	2021-12-13 23:31:19 UTC (rev 286988)
@@ -74,10 +74,8 @@
     // the Form or button relationships.
     protectedElement->document().updateLayoutIgnorePendingStylesheets();
 
-    protectedElement->setActivatedSubmit(true);
     if (RefPtr currentForm = protectedElement->form())
         currentForm->submitIfPossible(&event, element()); // Event handlers can run.
-    protectedElement->setActivatedSubmit(false);
     event.setDefaultHandled();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to