зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1820403 - Skip parts of form submission when the method is dialog. r=dom-core,sefeng
https://github.com/whatwg/html/pull/8943 moved dialog submission in the form submission algorithm from step 24 to step 11. Differential Revision: https://phabricator.services.mozilla.com/D183168
This commit is contained in:
Родитель
9f044bb607
Коммит
683c902afb
|
@ -854,7 +854,7 @@ nsresult HTMLFormElement::SubmitSubmission(
|
|||
return rv;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submit-dialog
|
||||
// https://html.spec.whatwg.org/#concept-form-submit step 11
|
||||
nsresult HTMLFormElement::SubmitDialog(DialogFormSubmission* aFormSubmission) {
|
||||
// Close the dialog subject. If there is a result, let that be the return
|
||||
// value.
|
||||
|
|
|
@ -778,6 +778,32 @@ nsresult HTMLFormSubmission::GetFromForm(HTMLFormElement* aForm,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
// Get method (default: GET)
|
||||
int32_t method = NS_FORM_METHOD_GET;
|
||||
if (aSubmitter && aSubmitter->HasAttr(nsGkAtoms::formmethod)) {
|
||||
GetEnumAttr(aSubmitter, nsGkAtoms::formmethod, &method);
|
||||
} else {
|
||||
GetEnumAttr(aForm, nsGkAtoms::method, &method);
|
||||
}
|
||||
|
||||
if (method == NS_FORM_METHOD_DIALOG) {
|
||||
HTMLDialogElement* dialog = aForm->FirstAncestorOfType<HTMLDialogElement>();
|
||||
|
||||
// If there isn't one, do nothing.
|
||||
if (!dialog) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString result;
|
||||
if (aSubmitter) {
|
||||
aSubmitter->ResultForDialogSubmit(result);
|
||||
}
|
||||
*aFormSubmission = new DialogFormSubmission(result, aEncoding, dialog);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(method != NS_FORM_METHOD_DIALOG);
|
||||
|
||||
// Get action
|
||||
nsCOMPtr<nsIURI> actionURL;
|
||||
rv = aForm->GetActionURL(getter_AddRefs(actionURL), aSubmitter);
|
||||
|
@ -823,34 +849,6 @@ nsresult HTMLFormSubmission::GetFromForm(HTMLFormElement* aForm,
|
|||
GetEnumAttr(aForm, nsGkAtoms::enctype, &enctype);
|
||||
}
|
||||
|
||||
// Get method (default: GET)
|
||||
int32_t method = NS_FORM_METHOD_GET;
|
||||
if (aSubmitter && aSubmitter->HasAttr(nsGkAtoms::formmethod)) {
|
||||
GetEnumAttr(aSubmitter, nsGkAtoms::formmethod, &method);
|
||||
} else {
|
||||
GetEnumAttr(aForm, nsGkAtoms::method, &method);
|
||||
}
|
||||
|
||||
if (method == NS_FORM_METHOD_DIALOG) {
|
||||
HTMLDialogElement* dialog = aForm->FirstAncestorOfType<HTMLDialogElement>();
|
||||
|
||||
// If there isn't one, or if it does not have an open attribute, do
|
||||
// nothing.
|
||||
if (!dialog || !dialog->Open()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsAutoString result;
|
||||
if (aSubmitter) {
|
||||
aSubmitter->ResultForDialogSubmit(result);
|
||||
}
|
||||
*aFormSubmission =
|
||||
new DialogFormSubmission(result, actionURL, target, aEncoding, dialog);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(method != NS_FORM_METHOD_DIALOG);
|
||||
|
||||
// Choose encoder
|
||||
if (method == NS_FORM_METHOD_POST && enctype == NS_FORM_ENCTYPE_MULTIPART) {
|
||||
*aFormSubmission =
|
||||
|
|
|
@ -39,6 +39,7 @@ class HTMLFormSubmission {
|
|||
*
|
||||
* @param aForm the form to get a submission object based on
|
||||
* @param aSubmitter the submitter element (can be null)
|
||||
* @param aEncoding the submiter element's encoding
|
||||
* @param aFormSubmission the form submission object (out param)
|
||||
*/
|
||||
static nsresult GetFromForm(HTMLFormElement* aForm,
|
||||
|
@ -168,11 +169,9 @@ class EncodingFormSubmission : public HTMLFormSubmission {
|
|||
|
||||
class DialogFormSubmission final : public HTMLFormSubmission {
|
||||
public:
|
||||
DialogFormSubmission(nsAString& aResult, nsIURI* aActionURL,
|
||||
const nsAString& aTarget,
|
||||
NotNull<const Encoding*> aEncoding,
|
||||
DialogFormSubmission(nsAString& aResult, NotNull<const Encoding*> aEncoding,
|
||||
HTMLDialogElement* aDialogElement)
|
||||
: HTMLFormSubmission(aActionURL, aTarget, aEncoding),
|
||||
: HTMLFormSubmission(nullptr, u""_ns, aEncoding),
|
||||
mDialogElement(aDialogElement),
|
||||
mReturnValue(aResult) {}
|
||||
nsresult AddNameValuePair(const nsAString& aName,
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
[dialog-form-submission-unusual.html]
|
||||
[A form's action and rel=noopener are ignored during submission]
|
||||
expected: FAIL
|
||||
|
||||
[A form's action and rel=noopener are ignored during submission, part 2]
|
||||
expected: FAIL
|
Загрузка…
Ссылка в новой задаче