Throw a binding exception when the submission attribute does not reference a valid xforms:submission element. Bug 279552, patch by smaug@welho.com, r=aaronr@us.ibm.com, sr=me.
git-svn-id: svn://10.0.0.236/trunk@168655 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -58,9 +58,10 @@ nsXFormsSendElement::HandleAction(nsIDOMEvent* aEvent,
|
||||
if (!mElement)
|
||||
return NS_OK;
|
||||
|
||||
nsAutoString submission;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("submission"), submission);
|
||||
if (submission.IsEmpty())
|
||||
NS_NAMED_LITERAL_STRING(submission, "submission");
|
||||
nsAutoString submissionID;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("submission"), submissionID);
|
||||
if (submissionID.IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> doc;
|
||||
@@ -69,11 +70,11 @@ nsXFormsSendElement::HandleAction(nsIDOMEvent* aEvent,
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> el;
|
||||
doc->GetElementById(submission, getter_AddRefs(el));
|
||||
if (!el)
|
||||
return NS_OK;
|
||||
|
||||
//XXX Check the element type when we have the submission element
|
||||
doc->GetElementById(submissionID, getter_AddRefs(el));
|
||||
|
||||
if (!el || !nsXFormsUtils::IsXFormsElement(el, submission)) {
|
||||
return nsXFormsUtils::DispatchEvent(mElement, eEvent_BindingException);
|
||||
}
|
||||
|
||||
return nsXFormsUtils::DispatchEvent(el, eEvent_Submit);
|
||||
}
|
||||
|
||||
@@ -159,8 +159,9 @@ nsXFormsSubmitElement::HandleDefault(nsIDOMEvent *aEvent, PRBool *aHandled)
|
||||
if (!(*aHandled = type.EqualsLiteral("DOMActivate")))
|
||||
return NS_OK;
|
||||
|
||||
NS_NAMED_LITERAL_STRING(submission, "submission");
|
||||
nsAutoString submissionID;
|
||||
mElement->GetAttribute(NS_LITERAL_STRING("submission"), submissionID);
|
||||
mElement->GetAttribute(submission, submissionID);
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> ownerDoc;
|
||||
mElement->GetOwnerDocument(getter_AddRefs(ownerDoc));
|
||||
@@ -168,7 +169,11 @@ nsXFormsSubmitElement::HandleDefault(nsIDOMEvent *aEvent, PRBool *aHandled)
|
||||
|
||||
nsCOMPtr<nsIDOMElement> submissionElement;
|
||||
ownerDoc->GetElementById(submissionID, getter_AddRefs(submissionElement));
|
||||
NS_ENSURE_STATE(submissionElement);
|
||||
|
||||
if (!submissionElement ||
|
||||
!nsXFormsUtils::IsXFormsElement(submissionElement, submission)) {
|
||||
return nsXFormsUtils::DispatchEvent(mElement, eEvent_BindingException);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMEventTarget> targ = do_QueryInterface(submissionElement);
|
||||
NS_ASSERTION(targ, "All elements should support nsIDOMEventTarget");
|
||||
|
||||
Reference in New Issue
Block a user