Skip to content

Add FormData.constructor submitter tests#37895

Merged
annevk merged 1 commit intoweb-platform-tests:masterfrom
jenseng:form-data-submitter
Jan 27, 2023
Merged

Add FormData.constructor submitter tests#37895
annevk merged 1 commit intoweb-platform-tests:masterfrom
jenseng:form-data-submitter

Conversation

@jenseng
Copy link
Copy Markdown
Contributor

@jenseng jenseng commented Jan 12, 2023

Add 7 new tests around the FormData.constructor submitter argument (new feature proposed here). This is ready for review in the context of that proposal, but shouldn't be merged until it is accepted.

  • For implementations of the existing spec, it's expected that 5 of these will fail and 2 will succeed (FormData construction should allow a null submitter and The constructed FormData object should not contain an entry for an unnamed submit button submitter), as can be seen here.
  • For implementations of the proposal (e.g. here), they should all pass.

@jenseng jenseng changed the title WIP: Add FormData.constructor submitter tests Add FormData.constructor submitter tests Jan 12, 2023
@jenseng jenseng marked this pull request as ready for review January 25, 2023 17:39
@jenseng
Copy link
Copy Markdown
Contributor Author

jenseng commented Jan 25, 2023

Although this file contains a bunch of existing FormData constructor tests, I just noticed there are even more over in xhr/formdata. Should I move these new tests over there instead?

let entries = [...formData.entries()];

assert_deep_equals(entries, [["n1", "v1"], ["n3", "v3"]]);
}, 'The constructed FormData object should not contain entries for an unactivated Image Button submitter');
Copy link
Copy Markdown
Contributor Author

@jenseng jenseng Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this test is correct based on my reading of the spec, i.e. before this algorithm was invoked the user indicated a coordinate would imply that no entries should be added in the negative case. But it could also be argued that that is undefined behavior, since it doesn't explicitly continue in the prose.

In looking at implementations of the algorithm however, it seems that the major implementors (Blink, WebKit, Gecko) default the coordinate to 0:0, e.g. see screenshots here and here (an un-activated Image Button submitter is used when constructing the entry list).

Would y'all recommend:

  1. Leaving this test in (and getting that fixed in implementations), OR
  2. Removing the test and considering it undefined behavior, since the spec is slightly unclear, OR
  3. Changing the test to expect a 0:0 coordinate, and clarifying the HTML spec, OR
  4. Something else?

As far as fixing implementations to check the activated-ness, my hunch is that should be fairly safe/straightforward, since in normal submissions the submitter would have activated. I think it's only with the new FormData submitter parameter that there might be an unactivated submitter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think 3 makes the most sense here. Thanks for catching that!

cc @domenic @tkent-google

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

@annevk annevk Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So @jenseng as for next steps:

  1. Leave the test in, but change the pass condition.
  2. File an issue against or directly PR HTML.

Given my demo above this is a (long overdue given how fundamental the algorithm is) bug fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@annevk sounds good, I'll tweak the test accordingly and file a separate issue/PR.

One slight clarification though, does your test actually demonstrate a bug in the spec? The click() method should trigger the activation behavior, and when an Image Button is activated it sets the coordinate to (0,0) if the user didn't explicitly pick one.

I think the ambiguity/discrepancy is just for Image Button submitters that were not explicitly activated (e.g. when using aForm.requestSubmit(aSubmitter) or the proposed new FormData(aForm, aSubmitter). Let me know If I'm missing something.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenseng
Copy link
Copy Markdown
Contributor Author

jenseng commented Jan 26, 2023

Ok, made the unactivated Image Button submitter test expect a (0,0) coordinate, and also added a test for an explicit null submitter.

Also refactored/moved the new tests over into xhr/formdata, as that feels like a better spot for them.

All tests pass on my Blink/Gecko/WebKit POCs 🥳

chromium-wpt-export-bot pushed a commit that referenced this pull request Jan 28, 2023
This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: #37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
webkit-early-warning-system pushed a commit to jenseng/WebKit that referenced this pull request Jan 30, 2023
https://bugs.webkit.org/show_bug.cgi?id=251220

Reviewed by Chris Dumez

Implement the new submitter parameter to the FormData constructor
Spec PR: whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Test: imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter.html

* LayoutTests/imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter.html: Added.
* Source/WebCore/html/DOMFormData.cpp:
(WebCore::DOMFormData::create): add submitter support
* Source/WebCore/html/DOMFormData.h: update signature
* Source/WebCore/html/DOMFormData.idl: update interface
* Source/WebCore/html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::requestSubmit): improve error messages#

Canonical link: https://commits.webkit.org/259558@main
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 2, 2023
…bidl,smaug

Also improve error messages for current submitter validations

Spec PR: whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Differential Revision: https://phabricator.services.mozilla.com/D167576
aarongable pushed a commit to chromium/chromium that referenced this pull request Feb 3, 2023
This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}
chromium-wpt-export-bot pushed a commit that referenced this pull request Feb 3, 2023
This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: #37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}
chromium-wpt-export-bot pushed a commit that referenced this pull request Feb 3, 2023
This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: #37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Feb 3, 2023
…bidl,smaug

Also improve error messages for current submitter validations

Spec PR: whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Differential Revision: https://phabricator.services.mozilla.com/D167576
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 5, 2023
…ata constructor, a=testonly

Automatic update from web-platform-tests
Add optional submitter argument to FormData constructor

This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}

--

wpt-commits: 181fc870aeae110d95537bac969f76caa55d5112
wpt-pr: 38242
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Feb 7, 2023
…ata constructor, a=testonly

Automatic update from web-platform-tests
Add optional submitter argument to FormData constructor

This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: web-platform-tests/wpt#37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}

--

wpt-commits: 181fc870aeae110d95537bac969f76caa55d5112
wpt-pr: 38242
marcoscaceres pushed a commit that referenced this pull request Mar 28, 2023
This patch adds support for the new submitter argument to the FormData constructor.

Spec: https://xhr.spec.whatwg.org/#interface-formdata
Spec PR (merged): whatwg/xhr#366
WPT PR: #37895

Bug: 1410542
Change-Id: If17f782f75ae40ae21241c169afc52761fc89544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4189297
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1100734}
Bishwarupjee pushed a commit to Bishwarupjee/xhr that referenced this pull request Jan 31, 2024
Rinkubot pushed a commit to Rinkubot/Webkit- that referenced this pull request Nov 5, 2025
    Add optional submitter parameter to FormData constructor
    https://bugs.webkit.org/show_bug.cgi?id=251220

    Reviewed by Chris Dumez

    Implement the new submitter parameter to the FormData constructor
    Spec PR: whatwg/xhr#366
    WPT PR: web-platform-tests/wpt#37895

    Test: imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter.html

    * LayoutTests/imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter-expected.txt: Added.
    * LayoutTests/imported/w3c/web-platform-tests/xhr/formdata/constructor-submitter.html: Added.
    * Source/WebCore/html/DOMFormData.cpp:
    (WebCore::DOMFormData::create): add submitter support
    * Source/WebCore/html/DOMFormData.h: update signature
    * Source/WebCore/html/DOMFormData.idl: update interface
    * Source/WebCore/html/HTMLFormElement.cpp:
    (WebCore::HTMLFormElement::requestSubmit): improve error messages#

    Canonical link: https://commits.webkit.org/259558@main

Canonical link: https://commits.webkit.org/259548.340@safari-7615-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants