Bug 595922 - tooltips should not show form validation message if the form element has @novalidate. r+a=sicking
This commit is contained in:
@@ -2816,7 +2816,8 @@ function FillInHTMLTooltip(tipElement)
|
|||||||
tipElement instanceof HTMLTextAreaElement ||
|
tipElement instanceof HTMLTextAreaElement ||
|
||||||
tipElement instanceof HTMLSelectElement ||
|
tipElement instanceof HTMLSelectElement ||
|
||||||
tipElement instanceof HTMLButtonElement) &&
|
tipElement instanceof HTMLButtonElement) &&
|
||||||
!tipElement.hasAttribute('title')) {
|
!tipElement.hasAttribute('title') &&
|
||||||
|
(!tipElement.form || !tipElement.form.noValidate)) {
|
||||||
// If the element is barred from constraint validation or valid,
|
// If the element is barred from constraint validation or valid,
|
||||||
// the validation message will be the empty string.
|
// the validation message will be the empty string.
|
||||||
titleText = tipElement.validationMessage;
|
titleText = tipElement.validationMessage;
|
||||||
|
|||||||
@@ -26,6 +26,12 @@ function check(aElementName, aBarred, aType) {
|
|||||||
ok (!FillInHTMLTooltip(e),
|
ok (!FillInHTMLTooltip(e),
|
||||||
"No tooltip should be shown if the title attribute is set");
|
"No tooltip should be shown if the title attribute is set");
|
||||||
|
|
||||||
|
e.removeAttribute('title');
|
||||||
|
content.setAttribute('novalidate', '');
|
||||||
|
ok (!FillInHTMLTooltip(e),
|
||||||
|
"No tooltip should be shown if the novalidate attribute is set on the form owner");
|
||||||
|
content.removeAttribute('novalidate');
|
||||||
|
|
||||||
content.removeChild(e);
|
content.removeChild(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +90,6 @@ function test () {
|
|||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
content.location =
|
content.location =
|
||||||
"data:text/html,<!DOCTYPE html><html><body><div id='content'></div></body></html>";
|
"data:text/html,<!DOCTYPE html><html><body><form id='content'></form></body></html>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1111,7 +1111,17 @@ DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnichar **aText,
|
|||||||
if (cvElement) {
|
if (cvElement) {
|
||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(cvElement);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(cvElement);
|
||||||
nsCOMPtr<nsIAtom> titleAtom = do_GetAtom("title");
|
nsCOMPtr<nsIAtom> titleAtom = do_GetAtom("title");
|
||||||
if (content->HasAttr(kNameSpaceID_None, titleAtom)) {
|
|
||||||
|
nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(content);
|
||||||
|
PRBool formHasNoValidate = PR_FALSE;
|
||||||
|
mozilla::dom::Element* form = formControl->GetFormElement();
|
||||||
|
if (form) {
|
||||||
|
nsCOMPtr<nsIAtom> noValidateAtom = do_GetAtom("novalidate");
|
||||||
|
formHasNoValidate = form->HasAttr(kNameSpaceID_None, noValidateAtom);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!content->HasAttr(kNameSpaceID_None, titleAtom) &&
|
||||||
|
!formHasNoValidate) {
|
||||||
cvElement->GetValidationMessage(outText);
|
cvElement->GetValidationMessage(outText);
|
||||||
found = !outText.IsEmpty();
|
found = !outText.IsEmpty();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user