From d9cb8185cca7c929e3e8af00802f186fd7ae045e Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Tue, 15 Jul 2025 15:48:55 +0100 Subject: [PATCH] LibWeb: Include submitter name and value when constructing FormData This fixes the SSO buttons on OpenAI's login page giving "Unknown error" --- Libraries/LibWeb/XHR/FormData.cpp | 4 ++-- ...tructor-takes-name-and-value-of-submitter.txt | 1 + .../xhr/formdata/constructor-submitter.txt | 9 ++++----- ...ructor-takes-name-and-value-of-submitter.html | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/XHR/FormData-constructor-takes-name-and-value-of-submitter.txt create mode 100644 Tests/LibWeb/Text/input/XHR/FormData-constructor-takes-name-and-value-of-submitter.html diff --git a/Libraries/LibWeb/XHR/FormData.cpp b/Libraries/LibWeb/XHR/FormData.cpp index 8598d78c94a..cbda6def0a2 100644 --- a/Libraries/LibWeb/XHR/FormData.cpp +++ b/Libraries/LibWeb/XHR/FormData.cpp @@ -43,8 +43,8 @@ WebIDL::ExceptionOr> FormData::construct_impl(JS::Realm& realm } } - // 2. Let list be the result of constructing the entry list for form. - auto entry_list = TRY(construct_entry_list(realm, *form)); + // 2. Let list be the result of constructing the entry list for form and submitter. + auto entry_list = TRY(construct_entry_list(realm, *form, submitter)); // 3. If list is null, then throw an "InvalidStateError" DOMException. if (!entry_list.has_value()) return WebIDL::InvalidStateError::create(realm, "Form element does not contain any entries."_string); diff --git a/Tests/LibWeb/Text/expected/XHR/FormData-constructor-takes-name-and-value-of-submitter.txt b/Tests/LibWeb/Text/expected/XHR/FormData-constructor-takes-name-and-value-of-submitter.txt new file mode 100644 index 00000000000..a690a924a8d --- /dev/null +++ b/Tests/LibWeb/Text/expected/XHR/FormData-constructor-takes-name-and-value-of-submitter.txt @@ -0,0 +1 @@ +'test-button-name' = 'test-button-value' diff --git a/Tests/LibWeb/Text/expected/wpt-import/xhr/formdata/constructor-submitter.txt b/Tests/LibWeb/Text/expected/wpt-import/xhr/formdata/constructor-submitter.txt index 51492179cd0..d12e788c504 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/xhr/formdata/constructor-submitter.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/xhr/formdata/constructor-submitter.txt @@ -2,14 +2,13 @@ Harness status: OK Found 9 tests -6 Pass -3 Fail +9 Pass Pass FormData construction should allow a null submitter Pass FormData construction should allow an undefined form and an undefined submitter Pass FormData construction should allow an undefined form and a null submitter Pass FormData construction should throw a TypeError if a non-null submitter is not a submit button Pass FormData construction should throw a 'NotFoundError' DOMException if a non-null submitter is not owned by the form -Fail The constructed FormData object should contain an in-tree-order entry for a named submit button submitter +Pass The constructed FormData object should contain an in-tree-order entry for a named submit button submitter Pass The constructed FormData object should not contain an entry for an unnamed submit button submitter -Fail The constructed FormData object should contain in-tree-order entries for an activated Image Button submitter -Fail The constructed FormData object should contain in-tree-order entries for an unactivated Image Button submitter \ No newline at end of file +Pass The constructed FormData object should contain in-tree-order entries for an activated Image Button submitter +Pass The constructed FormData object should contain in-tree-order entries for an unactivated Image Button submitter \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/XHR/FormData-constructor-takes-name-and-value-of-submitter.html b/Tests/LibWeb/Text/input/XHR/FormData-constructor-takes-name-and-value-of-submitter.html new file mode 100644 index 00000000000..6fc678eaaf1 --- /dev/null +++ b/Tests/LibWeb/Text/input/XHR/FormData-constructor-takes-name-and-value-of-submitter.html @@ -0,0 +1,16 @@ + +
+ +
+ +