Bug 1236991 - part 5: <output> elements don't submit, and so shouldn't get form validation errors in tooltips, r?enndeakin draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 11 Apr 2016 16:12:05 +0100
changeset 349467 e87a81e8f9a3a6ce3ab536d2e15e3c43feea7f35
parent 349466 40cad79518ee808430cb2acac09953ab3cd9e88d
child 349468 25bda1fcc3fad5b44c0b341f1d2e14261449b0cd
push id15095
push usergijskruitbosch@gmail.com
push dateMon, 11 Apr 2016 16:49:08 +0000
reviewersenndeakin
bugs1236991
milestone48.0a1
Bug 1236991 - part 5: <output> elements don't submit, and so shouldn't get form validation errors in tooltips, r?enndeakin MozReview-Commit-ID: 9tUxAeiidYA
embedding/browser/nsDocShellTreeOwner.cpp
--- a/embedding/browser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/nsDocShellTreeOwner.cpp
@@ -1104,26 +1104,28 @@ nsDefaultTooltipTextProvider::GetNodeTex
   // If the element implement the constraint validation API and has no title,
   // show the validation message, if any.
   nsCOMPtr<nsIConstraintValidation> cvElement = do_QueryInterface(current);
   if (cvElement) {
     nsCOMPtr<nsIContent> content = do_QueryInterface(cvElement);
     nsCOMPtr<nsIAtom> titleAtom = NS_Atomize("title");
 
     nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(content);
-    bool formHasNoValidate = false;
-    mozilla::dom::Element* form = formControl->GetFormElement();
-    if (form) {
-      nsCOMPtr<nsIAtom> noValidateAtom = NS_Atomize("novalidate");
-      formHasNoValidate = form->HasAttr(kNameSpaceID_None, noValidateAtom);
-    }
+    if (formControl->IsSubmittableControl()) {
+      bool formHasNoValidate = false;
+      mozilla::dom::Element* form = formControl->GetFormElement();
+      if (form) {
+        nsCOMPtr<nsIAtom> noValidateAtom = NS_Atomize("novalidate");
+        formHasNoValidate = form->HasAttr(kNameSpaceID_None, noValidateAtom);
+      }
 
-    if (!content->HasAttr(kNameSpaceID_None, titleAtom) && !formHasNoValidate) {
-      cvElement->GetValidationMessage(outText);
-      found = !outText.IsEmpty();
+      if (!content->HasAttr(kNameSpaceID_None, titleAtom) && !formHasNoValidate) {
+        cvElement->GetValidationMessage(outText);
+        found = !outText.IsEmpty();
+      }
     }
   }
 
   while (!found && current) {
     nsCOMPtr<nsIDOMElement> currElement(do_QueryInterface(current));
     if (currElement) {
       nsCOMPtr<nsIContent> content(do_QueryInterface(currElement));
       if (content) {