Bug 1366361 - Part 1: .action/formAction should return the document's URL if @action/formaction is missing or empty. r=smaug

MozReview-Commit-ID: H4CK0SVpaCv
This commit is contained in:
Jessica Jong
2017-07-17 14:17:19 +08:00
parent 8a500e9ebc
commit 19243ff95e
6 changed files with 53 additions and 1 deletions

View File

@@ -1585,6 +1585,27 @@ HTMLFormElement::FlushPendingSubmission()
}
}
void
HTMLFormElement::GetAction(nsString& aValue)
{
if (!GetAttr(kNameSpaceID_None, nsGkAtoms::action, aValue) ||
aValue.IsEmpty()) {
nsIDocument* document = OwnerDoc();
nsIURI* docURI = document->GetDocumentURI();
if (docURI) {
nsAutoCString spec;
nsresult rv = docURI->GetSpec(spec);
if (NS_FAILED(rv)) {
return;
}
CopyUTF8toUTF16(spec, aValue);
}
} else {
GetURIAttr(nsGkAtoms::action, nullptr, aValue);
}
}
nsresult
HTMLFormElement::GetActionURL(nsIURI** aActionURL,
nsIContent* aOriginatingElement)