Changeset 289615 in webkit


Ignore:
Timestamp:
Feb 11, 2022 2:52:38 AM (5 months ago)
Author:
commit-queue@webkit.org
Message:

Clicking on an <input type="image"> will submit the form with null submitter
https://bugs.webkit.org/show_bug.cgi?id=236324

LayoutTests/imported/w3c:

Add a test to make sure that when the form is submitted through an <input type="image">
control, the submitter field of the submit event is that control.

Patch by Andreu Botella <andreu@andreubotella.com> on 2022-02-11
Reviewed by Carlos Garcia Campos.

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

Source/WebCore:

Patch by Andreu Botella <andreu@andreubotella.com> on 2022-02-11
Reviewed by Carlos Garcia Campos.

If you submit a form by clicking on an <input type="image"> control, the control will be in
the form's entry list, but the submitter field in the submit event will be null. This is
wrong per the spec, and caused because the call to HTMLFormElement::submitIfPossible() in
ImageInputType::handleDOMActivateEvent() calls it with one argument, rather than passing
the element as the submitter.

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

  • html/ImageInputType.cpp:

(WebCore::ImageInputType::handleDOMActivateEvent):

Location:
trunk
Files:
5 edited

Legend:

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

    r289612 r289615  
     12022-02-11  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Clicking on an <input type="image"> will submit the form with null submitter
     4        https://bugs.webkit.org/show_bug.cgi?id=236324
     5
     6        Add a test to make sure that when the form is submitted through an <input type="image">
     7        control, the `submitter` field of the submit event is that control.
     8
     9        Reviewed by Carlos Garcia Campos.
     10
     11        * web-platform-tests/html/semantics/forms/form-submission-0/form-submission-algorithm-expected.txt:
     12        * web-platform-tests/html/semantics/forms/form-submission-0/form-submission-algorithm.html:
     13
    1142022-02-11  Youenn Fablet  <youenn@apple.com>
    215
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-submission-algorithm-expected.txt

    r284818 r289615  
     1
    12
    23
     
    1516PASS If form's firing submission events is true, then return; 'submit' event
    1617PASS firing an event named submit; clicking a submit button
     18PASS firing an event named submit; clicking an image button
    1719PASS firing an event named submit; form.requestSubmit()
    1820PASS firing an event named submit; form.requestSubmit(null)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-submission-algorithm.html

    r263987 r289615  
    8585
    8686promise_test(async () => {
     87  let form = populateForm('<input type=image name=n1>');
     88  let iframe = form.previousSibling;
     89  let submitter = form.querySelector('input[type=image]');
     90  let event;
     91  form.addEventListener('submit', e => { event = e; });
     92  submitter.click();
     93  await loadPromise(iframe);
     94  assert_true(event.bubbles);
     95  assert_true(event.cancelable);
     96  assert_equals(event.submitter, submitter);
     97  assert_true(event instanceof SubmitEvent);
     98}, 'firing an event named submit; clicking an image button');
     99
     100promise_test(async () => {
    87101  let form = populateForm('');
    88102  let iframe = form.previousSibling;
  • trunk/Source/WebCore/ChangeLog

    r289612 r289615  
     12022-02-11  Andreu Botella  <andreu@andreubotella.com>
     2
     3        Clicking on an <input type="image"> will submit the form with null submitter
     4        https://bugs.webkit.org/show_bug.cgi?id=236324
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        If you submit a form by clicking on an <input type="image"> control, the control will be in
     9        the form's entry list, but the submitter field in the submit event will be null. This is
     10        wrong per the spec, and caused because the call to `HTMLFormElement::submitIfPossible()` in
     11        `ImageInputType::handleDOMActivateEvent()` calls it with one argument, rather than passing
     12        the element as the submitter.
     13
     14        Tests: imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/form-submission-algorithm.html
     15
     16        * html/ImageInputType.cpp:
     17        (WebCore::ImageInputType::handleDOMActivateEvent):
     18
    1192022-02-11  Youenn Fablet  <youenn@apple.com>
    220
  • trunk/Source/WebCore/html/ImageInputType.cpp

    r288955 r289615  
    105105
    106106    if (auto currentForm = protectedElement->form())
    107         currentForm->submitIfPossible(&event); // Event handlers can run.
     107        currentForm->submitIfPossible(&event, element()); // Event handlers can run.
    108108
    109109    protectedElement->setActivatedSubmit(false);
Note: See TracChangeset for help on using the changeset viewer.