Changeset 293444 in webkit
- Timestamp:
- Apr 26, 2022 12:31:41 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/DOMFormData.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLButtonElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLFormElement.cpp (modified) (7 diffs)
-
Source/WebCore/html/HTMLFormElement.h (modified) (2 diffs)
-
Source/WebCore/html/SubmitInputType.cpp (modified) (1 diff)
-
Source/WebCore/loader/FormSubmission.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r293418 r293444 1 2022-04-26 Ziran Sun <zsun@igalia.com> 2 3 Constructed FormData object should not contain an entry for the submit button that was used to submit the form 4 https://bugs.webkit.org/show_bug.cgi?id=239070 5 6 Reviewed by Chris Dumez. 7 8 Update test expectation as the sub-test is now passing. 9 * web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt: 10 1 11 2022-04-26 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/form-submission-0/constructing-form-data-set-expected.txt
r288955 r293444 22 22 PASS Entries added to "formData" IDL attribute should be submitted. 23 23 PASS Entries added to the "formdata" IDL attribute shouldn't be newline normalized in the resulting FormData 24 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 24 PASS The constructed FormData object should not contain an entry for the submit button that was used to submit the form. 25 25 -
trunk/Source/WebCore/ChangeLog
r293443 r293444 1 2022-04-26 Ziran Sun <zsun@igalia.com> 2 3 Constructed FormData object should not contain an entry for the submit button that was used to submit the form 4 https://bugs.webkit.org/show_bug.cgi?id=239070 5 6 Reviewed by Chris Dumez. 7 8 When the activedSubmit flag is set for a submit button, its value is appended to a FormData. In the case of form 9 submission called in submit event handler, we include submit button when build FormData. The submit button should 10 not be included though. This patch correct it by calling set the activatedSubmit flag just before or after building 11 FormData. 12 13 Part of the patch is an import of Chromium CL at 14 https://codereview.chromium.org/2340213002 15 16 * html/DOMFormData.cpp: 17 (WebCore::DOMFormData::create): 18 * html/HTMLButtonElement.cpp: 19 (WebCore::HTMLButtonElement::defaultEventHandler): 20 * html/HTMLFormElement.cpp: 21 (WebCore::HTMLFormElement::submit): 22 (WebCore::HTMLFormElement::constructEntryList): 23 * html/HTMLFormElement.h: 24 * html/SubmitInputType.cpp: 25 (WebCore::SubmitInputType::handleDOMActivateEvent): 26 * loader/FormSubmission.cpp: 27 (WebCore::FormSubmission::create): 28 1 29 2022-04-26 Simon Fraser <simon.fraser@apple.com> 2 30 -
trunk/Source/WebCore/html/DOMFormData.cpp
r286772 r293444 49 49 return formData; 50 50 51 auto result = form->constructEntryList( WTFMove(formData), nullptr);51 auto result = form->constructEntryList(nullptr, WTFMove(formData), nullptr); 52 52 53 53 if (!result) -
trunk/Source/WebCore/html/HTMLButtonElement.cpp
r293285 r293444 142 142 143 143 if (auto currentForm = form()) { 144 if (m_type == SUBMIT) { 145 SetForScope activatedSubmitState(m_isActivatedSubmit, true); 144 if (m_type == SUBMIT) 146 145 currentForm->submitIfPossible(&event, this); 147 }148 146 149 147 if (m_type == RESET) -
trunk/Source/WebCore/html/HTMLFormElement.cpp
r293309 r293444 324 324 325 325 if (m_shouldSubmit) 326 submit(event, true,!submitter, trigger, submitter);326 submit(event, !submitter, trigger, submitter); 327 327 } 328 328 329 329 void HTMLFormElement::submit() 330 330 { 331 submit(nullptr, false,true, NotSubmittedByJavaScript);331 submit(nullptr, true, NotSubmittedByJavaScript); 332 332 } 333 333 334 334 void HTMLFormElement::submitFromJavaScript() 335 335 { 336 submit(nullptr, false,UserGestureIndicator::processingUserGesture(), SubmittedByJavaScript);336 submit(nullptr, UserGestureIndicator::processingUserGesture(), SubmittedByJavaScript); 337 337 } 338 338 … … 394 394 } 395 395 396 void HTMLFormElement::submit(Event* event, bool activateSubmitButton, boolprocessingUserGesture, FormSubmissionTrigger trigger, HTMLFormControlElement* submitter)396 void HTMLFormElement::submit(Event* event, bool processingUserGesture, FormSubmissionTrigger trigger, HTMLFormControlElement* submitter) 397 397 { 398 398 // The submitIfPossible function also does this check, but we need to do it here … … 417 417 m_wasUserSubmitted = processingUserGesture; 418 418 419 auto firstSuccessfulSubmitButton = findSubmitButton(submitter, activateSubmitButton); 420 if (firstSuccessfulSubmitButton) 421 firstSuccessfulSubmitButton->setActivatedSubmit(true); 419 if (event && !submitter) { 420 // In a case of implicit submission without a submit button, 'submit' event handler might add a submit button. We search for a submit button again. 421 auto associatedElements = copyAssociatedElementsVector(); 422 for (auto& element : associatedElements) { 423 if (auto* control = dynamicDowncast<HTMLFormControlElement>(element.get()); control && control->isSuccessfulSubmitButton()) { 424 submitter = control; 425 break; 426 } 427 } 428 } 422 429 423 430 Ref protectedThis { *this }; // Form submission can execute arbitary JavaScript. … … 444 451 else 445 452 frame->loader().submitForm(WTFMove(formSubmission)); 446 447 if (firstSuccessfulSubmitButton)448 firstSuccessfulSubmitButton->setActivatedSubmit(false);449 453 450 454 m_shouldSubmit = false; … … 1017 1021 } 1018 1022 1019 RefPtr<DOMFormData> HTMLFormElement::constructEntryList(Ref <DOMFormData>&& domFormData, StringPairVector* formValues)1023 RefPtr<DOMFormData> HTMLFormElement::constructEntryList(RefPtr<HTMLFormControlElement>&& submitter, Ref<DOMFormData>&& domFormData, StringPairVector* formValues) 1020 1024 { 1021 1025 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-form-data-set … … 1026 1030 1027 1031 SetForScope isConstructingEntryListScope(m_isConstructingEntryList, true); 1032 1033 if (submitter) 1034 submitter->setActivatedSubmit(true); 1028 1035 1029 1036 for (auto& control : this->copyAssociatedElementsVector()) { … … 1041 1048 1042 1049 dispatchEvent(FormDataEvent::create(eventNames().formdataEvent, Event::CanBubble::Yes, Event::IsCancelable::No, Event::IsComposed::No, domFormData.copyRef())); 1050 1051 if (submitter) 1052 submitter->setActivatedSubmit(false); 1043 1053 1044 1054 return domFormData->clone(); -
trunk/Source/WebCore/html/HTMLFormElement.h
r292960 r293444 128 128 static HTMLFormElement* findClosestFormAncestor(const Element&); 129 129 130 RefPtr<DOMFormData> constructEntryList(Ref <DOMFormData>&&, StringPairVector*);130 RefPtr<DOMFormData> constructEntryList(RefPtr<HTMLFormControlElement>&&, Ref<DOMFormData>&&, StringPairVector*); 131 131 132 132 private: … … 147 147 void copyNonAttributePropertiesFromElement(const Element&) final; 148 148 149 void submit(Event*, bool activateSubmitButton, boolprocessingUserGesture, FormSubmissionTrigger, HTMLFormControlElement* submitter = nullptr);149 void submit(Event*, bool processingUserGesture, FormSubmissionTrigger, HTMLFormControlElement* submitter = nullptr); 150 150 151 151 void submitDialog(Ref<FormSubmission>&&); -
trunk/Source/WebCore/html/SubmitInputType.cpp
r288955 r293444 75 75 protectedElement->document().updateLayoutIgnorePendingStylesheets(); 76 76 77 protectedElement->setActivatedSubmit(true);78 77 if (RefPtr currentForm = protectedElement->form()) 79 78 currentForm->submitIfPossible(&event, element()); // Event handlers can run. 80 protectedElement->setActivatedSubmit(false);81 79 event.setDefaultHandled(); 82 80 } -
trunk/Source/WebCore/loader/FormSubmission.cpp
r293326 r293444 214 214 StringPairVector formValues; 215 215 216 auto result = form.constructEntryList( WTFMove(domFormData), &formValues);216 auto result = form.constructEntryList(submitter.copyRef(), WTFMove(domFormData), &formValues); 217 217 RELEASE_ASSERT(result); 218 218 domFormData = result.releaseNonNull();
Note: See TracChangeset
for help on using the changeset viewer.