Title: [281770] trunk
Revision
281770
Author
[email protected]
Date
2021-08-30 11:30:23 -0700 (Mon, 30 Aug 2021)

Log Message

SubmitEvent.submitter property isn't set for <button type="submit">
https://bugs.webkit.org/show_bug.cgi?id=229660

Reviewed by Ryosuke Niwa.

Source/WebCore:

Make sure HTMLButtonElement::defaultEventHandler() properly passes |this| as submitter
when calling HTMLFormElement::submitIfPossible(). This was causing the SubmitEvent.submitter
property to not be set when submitting a form by clicking a `<button type="submit">`.

Test: fast/forms/submit-button-submit-event.html

* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):

LayoutTests:

Add layout test coverage.

* fast/forms/submit-button-submit-event-expected.txt: Added.
* fast/forms/submit-button-submit-event.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281769 => 281770)


--- trunk/LayoutTests/ChangeLog	2021-08-30 18:22:32 UTC (rev 281769)
+++ trunk/LayoutTests/ChangeLog	2021-08-30 18:30:23 UTC (rev 281770)
@@ -1,3 +1,15 @@
+2021-08-30  Chris Dumez  <[email protected]>
+
+        SubmitEvent.submitter property isn't set for <button type="submit">
+        https://bugs.webkit.org/show_bug.cgi?id=229660
+
+        Reviewed by Ryosuke Niwa.
+
+        Add layout test coverage.
+
+        * fast/forms/submit-button-submit-event-expected.txt: Added.
+        * fast/forms/submit-button-submit-event.html: Added.
+
 2021-08-30  Ayumi Kojima  <[email protected]>
 
         [ BigSur arm64 EWS ] ASSERTION FAILED: !needsLayout() ./rendering/RenderView.cpp(305) : virtual void WebCore::RenderView::paint(WebCore::PaintInfo &, const WebCore::LayoutPoint &).

Added: trunk/LayoutTests/fast/forms/submit-button-submit-event-expected.txt (0 => 281770)


--- trunk/LayoutTests/fast/forms/submit-button-submit-event-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-button-submit-event-expected.txt	2021-08-30 18:30:23 UTC (rev 281770)
@@ -0,0 +1,10 @@
+Tests that SubmitEvent.submitter property is properly set for .
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+
+PASS submitEvent.submitter is testButton
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/submit-button-submit-event.html (0 => 281770)


--- trunk/LayoutTests/fast/forms/submit-button-submit-event.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/submit-button-submit-event.html	2021-08-30 18:30:23 UTC (rev 281770)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<form id="testForm" action="" method="GET" style="display:none">
+<input type="text" name="title" value="foo">
+<button type="submit" name="action" value="submit" id="testButton">Submit</button>
+</form>
+<script>
+description("Tests that SubmitEvent.submitter property is properly set for <button type='submit'>.");
+jsTestIsAsync = true;
+
+_onload_ = () => {
+    testButton =  document.getElementById("testButton");
+    document.getElementById("testForm")._onsubmit_ = (_submitEvent) => {
+        submitEvent = _submitEvent;
+        shouldBe("submitEvent.submitter", "testButton");
+        finishJSTest();
+    };
+    testButton.click();
+};
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (281769 => 281770)


--- trunk/Source/WebCore/ChangeLog	2021-08-30 18:22:32 UTC (rev 281769)
+++ trunk/Source/WebCore/ChangeLog	2021-08-30 18:30:23 UTC (rev 281770)
@@ -1,3 +1,19 @@
+2021-08-30  Chris Dumez  <[email protected]>
+
+        SubmitEvent.submitter property isn't set for <button type="submit">
+        https://bugs.webkit.org/show_bug.cgi?id=229660
+
+        Reviewed by Ryosuke Niwa.
+
+        Make sure HTMLButtonElement::defaultEventHandler() properly passes |this| as submitter
+        when calling HTMLFormElement::submitIfPossible(). This was causing the SubmitEvent.submitter
+        property to not be set when submitting a form by clicking a `<button type="submit">`.
+
+        Test: fast/forms/submit-button-submit-event.html
+
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::defaultEventHandler):
+
 2021-08-30  Alan Bujtas  <[email protected]>
 
         [IFC][Integration] Remove unused bidi handling

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (281769 => 281770)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-08-30 18:22:32 UTC (rev 281769)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-08-30 18:30:23 UTC (rev 281770)
@@ -138,7 +138,7 @@
             if (auto currentForm = form()) {
                 if (m_type == SUBMIT) {
                     SetForScope<bool> activatedSubmitState(m_isActivatedSubmit, true);
-                    currentForm->submitIfPossible(&event);
+                    currentForm->submitIfPossible(&event, this);
                 }
 
                 if (m_type == RESET)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to