Bug 605125 (2/5) - Make :-moz-ui-valid follow rules for :valid. r=bz a=jst
authorMounir Lamouri <mounir.lamouri@gmail.com>
Wed, 24 Nov 2010 01:14:44 +0100
changeset 58152 a5443d86c431c497301c3f110f4aecf8710671c7
parent 58151 27db143745a77ffbcaeb8acea9dd4f590d7f4fe7
child 58153 b47d30240391c05348822bf108245a560b0adb8e
push id17175
push usermlamouri@mozilla.com
push dateWed, 24 Nov 2010 10:15:50 +0000
treeherdermozilla-central@7f5cd850578e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, jst
bugs605125
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 605125 (2/5) - Make :-moz-ui-valid follow rules for :valid. r=bz a=jst
content/html/content/src/nsHTMLButtonElement.cpp
content/html/content/src/nsHTMLInputElement.cpp
content/html/content/src/nsHTMLSelectElement.cpp
content/html/content/src/nsHTMLTextAreaElement.cpp
layout/reftests/css-ui-valid/button/button-button.html
layout/reftests/css-ui-valid/button/button-disabled-fieldset-1.html
layout/reftests/css-ui-valid/button/button-disabled-fieldset-2.html
layout/reftests/css-ui-valid/button/button-disabled.html
layout/reftests/css-ui-valid/button/button-dyn-disabled.html
layout/reftests/css-ui-valid/button/button-dyn-not-disabled.html
layout/reftests/css-ui-valid/button/button-fieldset-legend-ref.html
layout/reftests/css-ui-valid/button/button-fieldset-legend.html
layout/reftests/css-ui-valid/button/button-fieldset-ref.html
layout/reftests/css-ui-valid/button/button-invalid.html
layout/reftests/css-ui-valid/button/button-ref.html
layout/reftests/css-ui-valid/button/button-reset.html
layout/reftests/css-ui-valid/button/button-type-barred.html
layout/reftests/css-ui-valid/button/button-type-invalid.html
layout/reftests/css-ui-valid/button/button-valid.html
layout/reftests/css-ui-valid/button/reftest.list
layout/reftests/css-ui-valid/button/style.css
layout/reftests/css-ui-valid/input/input-button-ref.html
layout/reftests/css-ui-valid/input/input-button.html
layout/reftests/css-ui-valid/input/input-customerror.html
layout/reftests/css-ui-valid/input/input-disabled-fieldset-1.html
layout/reftests/css-ui-valid/input/input-disabled-fieldset-2.html
layout/reftests/css-ui-valid/input/input-disabled.html
layout/reftests/css-ui-valid/input/input-dyn-disabled.html
layout/reftests/css-ui-valid/input/input-dyn-not-disabled.html
layout/reftests/css-ui-valid/input/input-dyn-not-readonly.html
layout/reftests/css-ui-valid/input/input-dyn-readonly.html
layout/reftests/css-ui-valid/input/input-email-invalid.html
layout/reftests/css-ui-valid/input/input-email-ref.html
layout/reftests/css-ui-valid/input/input-email-valid.html
layout/reftests/css-ui-valid/input/input-fieldset-legend-ref.html
layout/reftests/css-ui-valid/input/input-fieldset-legend.html
layout/reftests/css-ui-valid/input/input-fieldset-ref.html
layout/reftests/css-ui-valid/input/input-maxlength-invalid.html
layout/reftests/css-ui-valid/input/input-maxlength-valid.html
layout/reftests/css-ui-valid/input/input-pattern-invalid.html
layout/reftests/css-ui-valid/input/input-pattern-valid.html
layout/reftests/css-ui-valid/input/input-readonly.html
layout/reftests/css-ui-valid/input/input-ref.html
layout/reftests/css-ui-valid/input/input-required-invalid.html
layout/reftests/css-ui-valid/input/input-required-valid.html
layout/reftests/css-ui-valid/input/input-reset.html
layout/reftests/css-ui-valid/input/input-type-barred.html
layout/reftests/css-ui-valid/input/input-type-invalid.html
layout/reftests/css-ui-valid/input/input-url-invalid.html
layout/reftests/css-ui-valid/input/input-url-ref.html
layout/reftests/css-ui-valid/input/input-url-valid.html
layout/reftests/css-ui-valid/input/input-valid.html
layout/reftests/css-ui-valid/input/input-withtext-ref.html
layout/reftests/css-ui-valid/input/reftest.list
layout/reftests/css-ui-valid/input/style.css
layout/reftests/css-ui-valid/reftest.list
layout/reftests/css-ui-valid/select/reftest.list
layout/reftests/css-ui-valid/select/select-disabled-fieldset-1.html
layout/reftests/css-ui-valid/select/select-disabled-fieldset-2.html
layout/reftests/css-ui-valid/select/select-disabled-ref.html
layout/reftests/css-ui-valid/select/select-disabled.html
layout/reftests/css-ui-valid/select/select-dyn-disabled.html
layout/reftests/css-ui-valid/select/select-dyn-not-disabled.html
layout/reftests/css-ui-valid/select/select-fieldset-legend-ref.html
layout/reftests/css-ui-valid/select/select-fieldset-legend.html
layout/reftests/css-ui-valid/select/select-fieldset-ref.html
layout/reftests/css-ui-valid/select/select-invalid.html
layout/reftests/css-ui-valid/select/select-ref.html
layout/reftests/css-ui-valid/select/select-required-invalid.html
layout/reftests/css-ui-valid/select/select-required-multiple-invalid.html
layout/reftests/css-ui-valid/select/select-required-multiple-ref.html
layout/reftests/css-ui-valid/select/select-required-multiple-valid.html
layout/reftests/css-ui-valid/select/select-required-ref.html
layout/reftests/css-ui-valid/select/select-required-valid.html
layout/reftests/css-ui-valid/select/select-valid.html
layout/reftests/css-ui-valid/select/style.css
layout/reftests/css-ui-valid/textarea/reftest.list
layout/reftests/css-ui-valid/textarea/style.css
layout/reftests/css-ui-valid/textarea/textarea-customerror.html
layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-1.html
layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-2.html
layout/reftests/css-ui-valid/textarea/textarea-disabled.html
layout/reftests/css-ui-valid/textarea/textarea-dyn-disabled.html
layout/reftests/css-ui-valid/textarea/textarea-dyn-not-disabled.html
layout/reftests/css-ui-valid/textarea/textarea-dyn-not-readonly.html
layout/reftests/css-ui-valid/textarea/textarea-dyn-readonly.html
layout/reftests/css-ui-valid/textarea/textarea-fieldset-legend-ref.html
layout/reftests/css-ui-valid/textarea/textarea-fieldset-legend.html
layout/reftests/css-ui-valid/textarea/textarea-fieldset-ref.html
layout/reftests/css-ui-valid/textarea/textarea-maxlength-invalid.html
layout/reftests/css-ui-valid/textarea/textarea-maxlength-valid.html
layout/reftests/css-ui-valid/textarea/textarea-readonly.html
layout/reftests/css-ui-valid/textarea/textarea-ref.html
layout/reftests/css-ui-valid/textarea/textarea-required-invalid.html
layout/reftests/css-ui-valid/textarea/textarea-required-valid.html
layout/reftests/css-ui-valid/textarea/textarea-valid.html
layout/reftests/css-ui-valid/textarea/textarea-withtext-ref.html
layout/reftests/reftest.list
--- a/content/html/content/src/nsHTMLButtonElement.cpp
+++ b/content/html/content/src/nsHTMLButtonElement.cpp
@@ -648,22 +648,22 @@ nsHTMLButtonElement::AfterSetAttr(PRInt3
   if (aNameSpaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::type) {
       if (!aValue) {
         mType = kButtonDefaultType->value;
       }
 
       UpdateBarredFromConstraintValidation();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID |
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID |
                 NS_EVENT_STATE_MOZ_SUBMITINVALID;
     } else if (aName == nsGkAtoms::disabled) {
       UpdateBarredFromConstraintValidation();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     }
 
     if (aNotify && !states.IsEmpty()) {
       nsIDocument* doc = GetCurrentDoc();
       if (doc) {
         MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
         doc->ContentStatesChanged(this, nsnull, states);
       }
@@ -703,17 +703,17 @@ nsHTMLButtonElement::RestoreState(nsPres
 }
 
 nsEventStates
 nsHTMLButtonElement::IntrinsicState() const
 {
   nsEventStates state = nsGenericHTMLFormElement::IntrinsicState();
 
   if (IsCandidateForConstraintValidation()) {
-    state |= IsValid() ? NS_EVENT_STATE_VALID
+    state |= IsValid() ? NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID
                        : NS_EVENT_STATE_INVALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   }
 
   if (mForm && !mForm->GetValidity() && IsSubmitControl()) {
     state |= NS_EVENT_STATE_MOZ_SUBMITINVALID;
   }
 
   return state;
@@ -726,17 +726,18 @@ nsHTMLButtonElement::SetCustomValidity(c
 {
   nsIConstraintValidation::SetCustomValidity(aError);
 
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
     doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
                                             NS_EVENT_STATE_VALID |
-                                            NS_EVENT_STATE_MOZ_UI_INVALID);
+                                            NS_EVENT_STATE_MOZ_UI_INVALID |
+                                            NS_EVENT_STATE_MOZ_UI_VALID);
   }
 
   return NS_OK;
 }
 
 void
 nsHTMLButtonElement::UpdateBarredFromConstraintValidation()
 {
@@ -746,12 +747,12 @@ nsHTMLButtonElement::UpdateBarredFromCon
 }
 
 void
 nsHTMLButtonElement::FieldSetDisabledChanged(nsEventStates aStates, PRBool aNotify)
 {
   UpdateBarredFromConstraintValidation();
 
   aStates |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-             NS_EVENT_STATE_MOZ_UI_INVALID;
+             NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   nsGenericHTMLFormElement::FieldSetDisabledChanged(aStates, aNotify);
 }
 
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -895,16 +895,17 @@ nsHTMLInputElement::AfterSetAttr(PRInt32
                 NS_EVENT_STATE_SUPPRESSED |
                 NS_EVENT_STATE_LOADING |
                 NS_EVENT_STATE_MOZ_READONLY |
                 NS_EVENT_STATE_MOZ_READWRITE |
                 NS_EVENT_STATE_REQUIRED |
                 NS_EVENT_STATE_OPTIONAL |
                 NS_EVENT_STATE_VALID |
                 NS_EVENT_STATE_INVALID |
+                NS_EVENT_STATE_MOZ_UI_VALID |
                 NS_EVENT_STATE_MOZ_UI_INVALID |
                 NS_EVENT_STATE_INDETERMINATE |
                 NS_EVENT_STATE_MOZ_PLACEHOLDER |
                 NS_EVENT_STATE_MOZ_SUBMITINVALID;
     }
 
     if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled ||
         aName == nsGkAtoms::readonly) {
@@ -912,25 +913,25 @@ nsHTMLInputElement::AfterSetAttr(PRInt32
 
       // This *has* to be called *after* validity has changed.
       if (aName == nsGkAtoms::readonly || aName == nsGkAtoms::disabled) {
         UpdateBarredFromConstraintValidation();
       }
 
       states |= NS_EVENT_STATE_REQUIRED | NS_EVENT_STATE_OPTIONAL |
                 NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     } else if (MaxLengthApplies() && aName == nsGkAtoms::maxlength) {
       UpdateTooLongValidityState();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     } else if (aName == nsGkAtoms::pattern) {
       UpdatePatternMismatchValidityState();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     }
 
     if (aNotify) {
       nsIDocument* doc = GetCurrentDoc();
 
       if (aName == nsGkAtoms::type) {
         UpdateEditableState();
       } else if (IsSingleLineTextControl(PR_FALSE) && aName == nsGkAtoms::readonly) {
@@ -3312,17 +3313,17 @@ nsHTMLInputElement::IntrinsicState() con
   if (DoesRequiredApply() && HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
     state |= NS_EVENT_STATE_REQUIRED;
   } else {
     state |= NS_EVENT_STATE_OPTIONAL;
   }
 
   if (IsCandidateForConstraintValidation()) {
     if (IsValid()) {
-      state |= NS_EVENT_STATE_VALID;
+      state |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID;
     } else {
       state |= NS_EVENT_STATE_INVALID;
 
       if (GET_BOOLBIT(mBitField, BF_CAN_SHOW_INVALID_UI) &&
           ShouldShowInvalidUI()) {
         state |= NS_EVENT_STATE_MOZ_UI_INVALID;
       }
     }
@@ -3738,17 +3739,18 @@ nsHTMLInputElement::SetCustomValidity(co
 {
   nsIConstraintValidation::SetCustomValidity(aError);
 
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
     doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
                                             NS_EVENT_STATE_VALID |
-                                            NS_EVENT_STATE_MOZ_UI_INVALID);
+                                            NS_EVENT_STATE_MOZ_UI_INVALID |
+                                            NS_EVENT_STATE_MOZ_UI_VALID);
   }
 
   return NS_OK;
 }
 
 PRBool
 nsHTMLInputElement::IsTooLong()
 {
@@ -3910,17 +3912,17 @@ nsHTMLInputElement::UpdateAllValiditySta
   UpdatePatternMismatchValidityState();
 
   if (validBefore != IsValid() && aNotify) {
     nsIDocument* doc = GetCurrentDoc();
     if (doc) {
       MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
       doc->ContentStatesChanged(this, nsnull,
                                 NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                                NS_EVENT_STATE_MOZ_UI_INVALID);
+                                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID);
     }
   }
 }
 
 void
 nsHTMLInputElement::UpdateBarredFromConstraintValidation()
 {
   SetBarredFromConstraintValidation(mType == NS_FORM_INPUT_HIDDEN ||
@@ -4450,17 +4452,17 @@ nsHTMLInputElement::OnValueChanged(PRBoo
 
 void
 nsHTMLInputElement::FieldSetDisabledChanged(nsEventStates aStates, PRBool aNotify)
 {
   UpdateValueMissingValidityState();
   UpdateBarredFromConstraintValidation();
 
   aStates |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-             NS_EVENT_STATE_MOZ_UI_INVALID;
+             NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   nsGenericHTMLFormElement::FieldSetDisabledChanged(aStates, aNotify);
 }
 
 PRInt32
 nsHTMLInputElement::GetFilterFromAccept()
 {
   NS_ASSERTION(HasAttr(kNameSpaceID_None, nsGkAtoms::accept),
                "You should not call GetFileFiltersFromAccept if the element"
--- a/content/html/content/src/nsHTMLSelectElement.cpp
+++ b/content/html/content/src/nsHTMLSelectElement.cpp
@@ -206,17 +206,18 @@ nsHTMLSelectElement::SetCustomValidity(c
 {
   nsIConstraintValidation::SetCustomValidity(aError);
 
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
     doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
                                             NS_EVENT_STATE_VALID |
-                                            NS_EVENT_STATE_MOZ_UI_INVALID);
+                                            NS_EVENT_STATE_MOZ_UI_INVALID |
+                                            NS_EVENT_STATE_MOZ_UI_VALID);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsHTMLSelectElement::GetForm(nsIDOMHTMLFormElement** aForm)
 {
@@ -357,17 +358,18 @@ nsHTMLSelectElement::RemoveOptionsFromLi
       UpdateValueMissingValidityState();
 
       if (aNotify) {
         nsIDocument* doc = GetCurrentDoc();
         if (doc) {
           MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
           doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
                                                   NS_EVENT_STATE_INVALID |
-                                                  NS_EVENT_STATE_MOZ_UI_INVALID);
+                                                  NS_EVENT_STATE_MOZ_UI_INVALID |
+                                                  NS_EVENT_STATE_MOZ_UI_VALID);
         }
       }
     }
   }
 
   return NS_OK;
 }
 
@@ -880,17 +882,18 @@ nsHTMLSelectElement::OnOptionSelected(ns
 
   UpdateValueMissingValidityState();
   if (aNotify) {
     nsIDocument* doc = GetCurrentDoc();
     if (doc) {
       MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
       doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
                                               NS_EVENT_STATE_INVALID |
-                                              NS_EVENT_STATE_MOZ_UI_INVALID);
+                                              NS_EVENT_STATE_MOZ_UI_INVALID |
+                                              NS_EVENT_STATE_MOZ_UI_VALID);
     }
   }
 }
 
 void
 nsHTMLSelectElement::FindSelectedIndex(PRInt32 aStartIndex)
 {
   mSelectedIndex = -1;
@@ -1322,17 +1325,18 @@ nsHTMLSelectElement::SelectSomething(PRB
 
       UpdateValueMissingValidityState();
       if (aNotify) {
         nsIDocument* doc = GetCurrentDoc();
         if (doc) {
           MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
           doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_VALID |
                                                   NS_EVENT_STATE_INVALID |
-                                                  NS_EVENT_STATE_MOZ_UI_INVALID);
+                                                  NS_EVENT_STATE_MOZ_UI_INVALID |
+                                                  NS_EVENT_STATE_MOZ_UI_VALID);
         }
       }
 
       return PR_TRUE;
     }
   }
 
   return PR_FALSE;
@@ -1373,21 +1377,21 @@ nsHTMLSelectElement::AfterSetAttr(PRInt3
                                   const nsAString* aValue, PRBool aNotify)
 {
   nsEventStates states;
 
   if (aNameSpaceID == kNameSpaceID_None) {
     if (aName == nsGkAtoms::disabled) {
       UpdateBarredFromConstraintValidation();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     } else if (aName == nsGkAtoms::required) {
       UpdateValueMissingValidityState();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     }
   }
 
   if (aNotify && !states.IsEmpty()) {
     nsIDocument* doc = GetCurrentDoc();
     if (doc) {
       MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
       doc->ContentStatesChanged(this, nsnull, states);
@@ -1550,17 +1554,17 @@ nsHTMLSelectElement::PreHandleEvent(nsEv
 }
 
 nsEventStates
 nsHTMLSelectElement::IntrinsicState() const
 {
   nsEventStates state = nsGenericHTMLFormElement::IntrinsicState();
 
   if (IsCandidateForConstraintValidation()) {
-    state |= IsValid() ? NS_EVENT_STATE_VALID
+    state |= IsValid() ? NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID
                        : NS_EVENT_STATE_INVALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   }
 
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
     state |= NS_EVENT_STATE_REQUIRED;
   } else {
     state |= NS_EVENT_STATE_OPTIONAL;
   }
@@ -2233,12 +2237,12 @@ nsHTMLSelectElement::UpdateBarredFromCon
 }
 
 void
 nsHTMLSelectElement::FieldSetDisabledChanged(nsEventStates aStates, PRBool aNotify)
 {
   UpdateBarredFromConstraintValidation();
 
   aStates |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-             NS_EVENT_STATE_MOZ_UI_INVALID;
+             NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   nsGenericHTMLFormElement::FieldSetDisabledChanged(aStates, aNotify);
 }
 
--- a/content/html/content/src/nsHTMLTextAreaElement.cpp
+++ b/content/html/content/src/nsHTMLTextAreaElement.cpp
@@ -1052,17 +1052,17 @@ nsHTMLTextAreaElement::IntrinsicState() 
   if (HasAttr(kNameSpaceID_None, nsGkAtoms::required)) {
     state |= NS_EVENT_STATE_REQUIRED;
   } else {
     state |= NS_EVENT_STATE_OPTIONAL;
   }
 
   if (IsCandidateForConstraintValidation()) {
     if (IsValid()) {
-      state |= NS_EVENT_STATE_VALID;
+      state |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID;
     } else {
       state |= NS_EVENT_STATE_INVALID;
       // NS_EVENT_STATE_MOZ_UI_INVALID always apply if the element suffers from
       // VALIDITY_STATE_CUSTOM_ERROR.
       // Otherwise, it applies if the value has been modified.
       // NS_EVENT_STATE_MOZ_UI_INVALID always applies if the form submission has
       // been tried while invalid.
       if (mCanShowInvalidUI && ShouldShowInvalidUI()) {
@@ -1184,22 +1184,22 @@ nsHTMLTextAreaElement::AfterSetAttr(PRIn
       UpdateValueMissingValidityState();
 
       // This *has* to be called *after* validity has changed.
       if (aName == nsGkAtoms::readonly || aName == nsGkAtoms::disabled) {
         UpdateBarredFromConstraintValidation();
       }
 
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID |
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID |
                 NS_EVENT_STATE_MOZ_SUBMITINVALID;
     } else if (aName == nsGkAtoms::maxlength) {
       UpdateTooLongValidityState();
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     }
 
     if (aNotify) {
       nsIDocument* doc = GetCurrentDoc();
 
       if (aName == nsGkAtoms::readonly) {
         UpdateEditableState();
         states |= NS_EVENT_STATE_MOZ_READONLY | NS_EVENT_STATE_MOZ_READWRITE;
@@ -1243,17 +1243,18 @@ nsHTMLTextAreaElement::SetCustomValidity
 {
   nsIConstraintValidation::SetCustomValidity(aError);
 
   nsIDocument* doc = GetCurrentDoc();
   if (doc) {
     MOZ_AUTO_DOC_UPDATE(doc, UPDATE_CONTENT_STATE, PR_TRUE);
     doc->ContentStatesChanged(this, nsnull, NS_EVENT_STATE_INVALID |
                                             NS_EVENT_STATE_VALID |
-                                            NS_EVENT_STATE_MOZ_UI_INVALID);
+                                            NS_EVENT_STATE_MOZ_UI_INVALID |
+                                            NS_EVENT_STATE_MOZ_UI_VALID);
   }
 
   return NS_OK;
 }
 
 PRBool
 nsHTMLTextAreaElement::IsTooLong()
 {
@@ -1462,17 +1463,17 @@ nsHTMLTextAreaElement::OnValueChanged(PR
   PRBool validBefore = IsValid();
   UpdateTooLongValidityState();
   UpdateValueMissingValidityState();
 
   if (aNotify) {
     nsEventStates states;
     if (validBefore != IsValid()) {
       states |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-                NS_EVENT_STATE_MOZ_UI_INVALID;
+                NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
     }
 
     if (HasAttr(kNameSpaceID_None, nsGkAtoms::placeholder)
         && !nsContentUtils::IsFocusedContent((nsIContent*)(this))) {
       states |= NS_EVENT_STATE_MOZ_PLACEHOLDER;
     }
 
     if (!states.IsEmpty()) {
@@ -1487,12 +1488,12 @@ nsHTMLTextAreaElement::OnValueChanged(PR
 
 void
 nsHTMLTextAreaElement::FieldSetDisabledChanged(nsEventStates aStates, PRBool aNotify)
 {
   UpdateValueMissingValidityState();
   UpdateBarredFromConstraintValidation();
 
   aStates |= NS_EVENT_STATE_VALID | NS_EVENT_STATE_INVALID |
-             NS_EVENT_STATE_MOZ_UI_INVALID;
+             NS_EVENT_STATE_MOZ_UI_VALID | NS_EVENT_STATE_MOZ_UI_INVALID;
   nsGenericHTMLFormElement::FieldSetDisabledChanged(aStates, aNotify);
 }
 
copy from layout/reftests/css-valid/button/button-button.html
copy to layout/reftests/css-ui-valid/button/button-button.html
--- a/layout/reftests/css-valid/button/button-button.html
+++ b/layout/reftests/css-ui-valid/button/button-button.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button is of the button type, it is barred from constraint
-             validation and should not be affected by :valid pseudo-class. -->
+             validation and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <button class='notvalid' type='button'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-disabled-fieldset-1.html
copy to layout/reftests/css-ui-valid/button/button-disabled-fieldset-1.html
--- a/layout/reftests/css-valid/button/button-disabled-fieldset-1.html
+++ b/layout/reftests/css-ui-valid/button/button-disabled-fieldset-1.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <fieldset>
         <button class='notvalid'></button>
       </fieldset>
     </fieldset>
copy from layout/reftests/css-valid/button/button-disabled-fieldset-2.html
copy to layout/reftests/css-ui-valid/button/button-disabled-fieldset-2.html
--- a/layout/reftests/css-valid/button/button-disabled-fieldset-2.html
+++ b/layout/reftests/css-ui-valid/button/button-disabled-fieldset-2.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if button has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onloadHandler()
     {
       var fieldsets = document.getElementsByTagName("fieldset");
       fieldsets[1].disabled = true;
       fieldsets[0].disabled = false;
copy from layout/reftests/css-valid/button/button-disabled.html
copy to layout/reftests/css-ui-valid/button/button-disabled.html
--- a/layout/reftests/css-valid/button/button-disabled.html
+++ b/layout/reftests/css-ui-valid/button/button-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <button class='notvalid' disabled></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-dyn-disabled.html
copy to layout/reftests/css-ui-valid/button/button-dyn-disabled.html
--- a/layout/reftests/css-valid/button/button-dyn-disabled.html
+++ b/layout/reftests/css-ui-valid/button/button-dyn-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if button is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('b').disabled='true'; document.documentElement.className='';">
     <button class='notvalid' id='b'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-dyn-not-disabled.html
copy to layout/reftests/css-ui-valid/button/button-dyn-not-disabled.html
--- a/layout/reftests/css-valid/button/button-dyn-not-disabled.html
+++ b/layout/reftests/css-ui-valid/button/button-dyn-not-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if button is not disabled, it is candidate for constraint validation
-             and should be affected by :valid pseudo-class. -->
+             and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('b').removeAttribute('disabled'); document.documentElement.className='';">
     <button class='valid' id='b' disabled></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-fieldset-legend-ref.html
copy to layout/reftests/css-ui-valid/button/button-fieldset-legend-ref.html
copy from layout/reftests/css-valid/button/button-fieldset-legend.html
copy to layout/reftests/css-ui-valid/button/button-fieldset-legend.html
--- a/layout/reftests/css-valid/button/button-fieldset-legend.html
+++ b/layout/reftests/css-ui-valid/button/button-fieldset-legend.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button has a disabled fieldset ancestor, but is in the first
              legend, it is not barred from constraint validation and should be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <legend>
         <button class='valid'></button>
       </legend>
     </fieldset>
   </body>
copy from layout/reftests/css-valid/button/button-fieldset-ref.html
copy to layout/reftests/css-ui-valid/button/button-fieldset-ref.html
copy from layout/reftests/css-valid/button/button-invalid.html
copy to layout/reftests/css-ui-valid/button/button-invalid.html
--- a/layout/reftests/css-valid/button/button-invalid.html
+++ b/layout/reftests/css-ui-valid/button/button-invalid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
-  <!-- Test: if button has a custom error, it should not be affected by :valid
+  <!-- Test: if button has a custom error, it should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('b').setCustomValidity('foo'); document.documentElement.className='';">
     <button class='notvalid' id='b'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-ref.html
copy to layout/reftests/css-ui-valid/button/button-ref.html
copy from layout/reftests/css-valid/button/button-reset.html
copy to layout/reftests/css-ui-valid/button/button-reset.html
--- a/layout/reftests/css-valid/button/button-reset.html
+++ b/layout/reftests/css-ui-valid/button/button-reset.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button is of the reset type, it is barred from constraint
-             validation and should not be affected by :valid pseudo-class. -->
+             validation and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <button class='notvalid' type='reset'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-type-barred.html
copy to layout/reftests/css-ui-valid/button/button-type-barred.html
--- a/layout/reftests/css-valid/button/button-type-barred.html
+++ b/layout/reftests/css-ui-valid/button/button-type-barred.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if a button has is candidate for constraint validation then change
              its type to be barred from constraint validation, it should not be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('b').type='button'; document.documentElement.className='';">
     <button class='notvalid' type='submit' id='b'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/button-type-invalid.html
copy to layout/reftests/css-ui-valid/button/button-type-invalid.html
--- a/layout/reftests/css-valid/button/button-type-invalid.html
+++ b/layout/reftests/css-ui-valid/button/button-type-invalid.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if a button has a custom error when barred from constraint
              validation then move a type candidate for constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onLoadHandler()
     {
       var b = document.getElementById('b');
       b.setCustomValidity('foo');
       b.type = 'submit';
       document.documentElement.className='';
copy from layout/reftests/css-valid/button/button-valid.html
copy to layout/reftests/css-ui-valid/button/button-valid.html
--- a/layout/reftests/css-valid/button/button-valid.html
+++ b/layout/reftests/css-ui-valid/button/button-valid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if button has no custom error and is not barred from constraint
-             validation, it should be affected by :valid pseudo-class. -->
+             validation, it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <button class='valid'></button>
   </body>
 </html>
copy from layout/reftests/css-valid/button/reftest.list
copy to layout/reftests/css-ui-valid/button/reftest.list
copy from layout/reftests/css-valid/button/style.css
copy to layout/reftests/css-ui-valid/button/style.css
--- a/layout/reftests/css-valid/button/style.css
+++ b/layout/reftests/css-ui-valid/button/style.css
@@ -1,18 +1,18 @@
 /* Override default style */
 button:invalid {
   box-shadow: none;
 }
 
 button.notvalid {
   background-color: green;
 }
-button.notvalid:valid {
+button.notvalid:-moz-ui-valid {
   background-color: red;
 }
 
 button.valid {
   background-color: red;
 }
-button.valid:valid {
+button.valid:-moz-ui-valid {
   background-color: green;
 }
copy from layout/reftests/css-valid/input/input-button-ref.html
copy to layout/reftests/css-ui-valid/input/input-button-ref.html
copy from layout/reftests/css-valid/input/input-button.html
copy to layout/reftests/css-ui-valid/input/input-button.html
--- a/layout/reftests/css-valid/input/input-button.html
+++ b/layout/reftests/css-ui-valid/input/input-button.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is of button type, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' type='button'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-customerror.html
copy to layout/reftests/css-ui-valid/input/input-customerror.html
--- a/layout/reftests/css-valid/input/input-customerror.html
+++ b/layout/reftests/css-ui-valid/input/input-customerror.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
-  <!-- Test: if input has a custom error, it should not be affected by :valid
+  <!-- Test: if input has a custom error, it should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').setCustomValidity('foo'); document.documentElement.className='';">
     <input class='notvalid' id='t'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-disabled-fieldset-1.html
copy to layout/reftests/css-ui-valid/input/input-disabled-fieldset-1.html
--- a/layout/reftests/css-valid/input/input-disabled-fieldset-1.html
+++ b/layout/reftests/css-ui-valid/input/input-disabled-fieldset-1.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <fieldset>
         <input class='notvalid'>
       </fieldset>
     </fieldset>
copy from layout/reftests/css-valid/input/input-disabled-fieldset-2.html
copy to layout/reftests/css-ui-valid/input/input-disabled-fieldset-2.html
--- a/layout/reftests/css-valid/input/input-disabled-fieldset-2.html
+++ b/layout/reftests/css-ui-valid/input/input-disabled-fieldset-2.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onloadHandler()
     {
       var fieldsets = document.getElementsByTagName("fieldset");
       fieldsets[1].disabled = true;
       fieldsets[0].disabled = false;
copy from layout/reftests/css-valid/input/input-disabled.html
copy to layout/reftests/css-ui-valid/input/input-disabled.html
--- a/layout/reftests/css-valid/input/input-disabled.html
+++ b/layout/reftests/css-ui-valid/input/input-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' disabled>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-dyn-disabled.html
copy to layout/reftests/css-ui-valid/input/input-dyn-disabled.html
--- a/layout/reftests/css-valid/input/input-dyn-disabled.html
+++ b/layout/reftests/css-ui-valid/input/input-dyn-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').disabled='true'; document.documentElement.className='';">
     <input class='notvalid' id='i'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-dyn-not-disabled.html
copy to layout/reftests/css-ui-valid/input/input-dyn-not-disabled.html
--- a/layout/reftests/css-valid/input/input-dyn-not-disabled.html
+++ b/layout/reftests/css-ui-valid/input/input-dyn-not-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input is not disabled, it is candidate for constraint validation
-             and should be affected by :valid pseudo-class. -->
+             and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').removeAttribute('disabled'); document.documentElement.className='';">
     <input class='valid' id='i' disabled>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-dyn-not-readonly.html
copy to layout/reftests/css-ui-valid/input/input-dyn-not-readonly.html
--- a/layout/reftests/css-valid/input/input-dyn-not-readonly.html
+++ b/layout/reftests/css-ui-valid/input/input-dyn-not-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input is no longer readonly, it is candidate for constraint
-             validation and should be affected by :valid pseudo-class. -->
+             validation and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').removeAttribute('readonly'); document.documentElement.className='';">
     <input class='valid' id='i' readonly>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-dyn-readonly.html
copy to layout/reftests/css-ui-valid/input/input-dyn-readonly.html
--- a/layout/reftests/css-valid/input/input-dyn-readonly.html
+++ b/layout/reftests/css-ui-valid/input/input-dyn-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input is readonly, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').readOnly='ro'; document.documentElement.className='';">
     <input class='notvalid' id='i'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-email-invalid.html
copy to layout/reftests/css-ui-valid/input/input-email-invalid.html
--- a/layout/reftests/css-valid/input/input-email-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-email-invalid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' type='email' value='foo'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-email-ref.html
copy to layout/reftests/css-ui-valid/input/input-email-ref.html
copy from layout/reftests/css-valid/input/input-email-valid.html
copy to layout/reftests/css-ui-valid/input/input-email-valid.html
--- a/layout/reftests/css-valid/input/input-email-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-email-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid' type='email' value='foo@bar.com'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-fieldset-legend-ref.html
copy to layout/reftests/css-ui-valid/input/input-fieldset-legend-ref.html
copy from layout/reftests/css-valid/input/input-fieldset-legend.html
copy to layout/reftests/css-ui-valid/input/input-fieldset-legend.html
--- a/layout/reftests/css-valid/input/input-fieldset-legend.html
+++ b/layout/reftests/css-ui-valid/input/input-fieldset-legend.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input has a disabled fieldset ancestor, but is in the first
              legend, it is not barred from constraint validation and should be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <legend>
         <input class='valid'></input>
       </legend>
     </fieldset>
   </body>
copy from layout/reftests/css-valid/input/input-fieldset-ref.html
copy to layout/reftests/css-ui-valid/input/input-fieldset-ref.html
copy from layout/reftests/css-valid/input/input-maxlength-invalid.html
copy to layout/reftests/css-ui-valid/input/input-maxlength-invalid.html
--- a/layout/reftests/css-valid/input/input-maxlength-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-maxlength-invalid.html
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if input isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <!-- TODO: this is valid until bug bug 613016 and bug 613019 are fixed. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').value='foo'; document.documentElement.className='';">
     <input class='valid' maxlength="2" id='i'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-maxlength-valid.html
copy to layout/reftests/css-ui-valid/input/input-maxlength-valid.html
--- a/layout/reftests/css-valid/input/input-maxlength-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-maxlength-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and is not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid' maxlength="2">
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-pattern-invalid.html
copy to layout/reftests/css-ui-valid/input/input-pattern-invalid.html
--- a/layout/reftests/css-valid/input/input-pattern-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-pattern-invalid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' pattern='bar' value='foo'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-pattern-valid.html
copy to layout/reftests/css-ui-valid/input/input-pattern-valid.html
--- a/layout/reftests/css-valid/input/input-pattern-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-pattern-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid' pattern='foo' value='foo'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-readonly.html
copy to layout/reftests/css-ui-valid/input/input-readonly.html
--- a/layout/reftests/css-valid/input/input-readonly.html
+++ b/layout/reftests/css-ui-valid/input/input-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is readonly, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' readonly>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-ref.html
copy to layout/reftests/css-ui-valid/input/input-ref.html
copy from layout/reftests/css-valid/input/input-required-invalid.html
copy to layout/reftests/css-ui-valid/input/input-required-invalid.html
--- a/layout/reftests/css-valid/input/input-required-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-required-invalid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' required>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-required-valid.html
copy to layout/reftests/css-ui-valid/input/input-required-valid.html
--- a/layout/reftests/css-valid/input/input-required-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-required-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid' value='foo' required>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-reset.html
copy to layout/reftests/css-ui-valid/input/input-reset.html
--- a/layout/reftests/css-valid/input/input-reset.html
+++ b/layout/reftests/css-ui-valid/input/input-reset.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is of reset type, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <!-- Setting value to the empty string let us check against input-button-ref.html -->
     <input class='notvalid' type='reset' value=''>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-type-barred.html
copy to layout/reftests/css-ui-valid/input/input-type-barred.html
--- a/layout/reftests/css-valid/input/input-type-barred.html
+++ b/layout/reftests/css-ui-valid/input/input-type-barred.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if an input has is candidate for constraint validation then change
              its type to be barred from constraint validation, it should not be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('i').type='button'; document.documentElement.className='';">
     <input class='notvalid' id='i'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-type-invalid.html
copy to layout/reftests/css-ui-valid/input/input-type-invalid.html
--- a/layout/reftests/css-valid/input/input-type-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-type-invalid.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if an input has a custom error when barred from constraint
              validation then move a type candidate for constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onLoadHandler()
     {
       var i = document.getElementById('i');
       i.setCustomValidity('foo');
       i.type = 'text';
       document.documentElement.className='';
copy from layout/reftests/css-valid/input/input-url-invalid.html
copy to layout/reftests/css-ui-valid/input/input-url-invalid.html
--- a/layout/reftests/css-valid/input/input-url-invalid.html
+++ b/layout/reftests/css-ui-valid/input/input-url-invalid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='notvalid' type='url' value='foo'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-url-ref.html
copy to layout/reftests/css-ui-valid/input/input-url-ref.html
copy from layout/reftests/css-valid/input/input-url-valid.html
copy to layout/reftests/css-ui-valid/input/input-url-valid.html
--- a/layout/reftests/css-valid/input/input-url-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-url-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid' type='url' value='http://mozilla.org/'>
   </body>
 </html>
 
copy from layout/reftests/css-valid/input/input-valid.html
copy to layout/reftests/css-ui-valid/input/input-valid.html
--- a/layout/reftests/css-valid/input/input-valid.html
+++ b/layout/reftests/css-ui-valid/input/input-valid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if input is valid and is not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <input class='valid'>
   </body>
 </html>
copy from layout/reftests/css-valid/input/input-withtext-ref.html
copy to layout/reftests/css-ui-valid/input/input-withtext-ref.html
copy from layout/reftests/css-valid/input/reftest.list
copy to layout/reftests/css-ui-valid/input/reftest.list
copy from layout/reftests/css-valid/input/style.css
copy to layout/reftests/css-ui-valid/input/style.css
--- a/layout/reftests/css-valid/input/style.css
+++ b/layout/reftests/css-ui-valid/input/style.css
@@ -1,18 +1,18 @@
 /* Override default style */
 input:invalid {
   box-shadow: none;
 }
 
 input.notvalid {
   background-color: green;
 }
-input.notvalid:valid {
+input.notvalid:-moz-ui-valid {
   background-color: red;
 }
 
 input.valid {
   background-color: red;
 }
-input.valid:valid {
+input.valid:-moz-ui-valid {
   background-color: green;
 }
copy from layout/reftests/css-valid/reftest.list
copy to layout/reftests/css-ui-valid/reftest.list
--- a/layout/reftests/css-valid/reftest.list
+++ b/layout/reftests/css-ui-valid/reftest.list
@@ -1,11 +1,5 @@
-# :valid should not apply on fieldset (always barred from constraint validation)
-include fieldset/reftest.list
-
-# :valid should apply on the following elements
+# :-moz-ui-valid should apply on the following elements
 include button/reftest.list
 include input/reftest.list
 include select/reftest.list
 include textarea/reftest.list
-include output/reftest.list
-include output/reftest.list
-include output/reftest.list
copy from layout/reftests/css-valid/select/reftest.list
copy to layout/reftests/css-ui-valid/select/reftest.list
copy from layout/reftests/css-valid/select/select-disabled-fieldset-1.html
copy to layout/reftests/css-ui-valid/select/select-disabled-fieldset-1.html
--- a/layout/reftests/css-valid/select/select-disabled-fieldset-1.html
+++ b/layout/reftests/css-ui-valid/select/select-disabled-fieldset-1.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <fieldset>
         <select class='notvalid'></select>
       </fieldset>
     </fieldset>
copy from layout/reftests/css-valid/select/select-disabled-fieldset-2.html
copy to layout/reftests/css-ui-valid/select/select-disabled-fieldset-2.html
--- a/layout/reftests/css-valid/select/select-disabled-fieldset-2.html
+++ b/layout/reftests/css-ui-valid/select/select-disabled-fieldset-2.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if select has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onloadHandler()
     {
       var fieldsets = document.getElementsByTagName("fieldset");
       fieldsets[1].disabled = true;
       fieldsets[0].disabled = false;
copy from layout/reftests/css-valid/select/select-disabled-ref.html
copy to layout/reftests/css-ui-valid/select/select-disabled-ref.html
copy from layout/reftests/css-valid/select/select-disabled.html
copy to layout/reftests/css-ui-valid/select/select-disabled.html
--- a/layout/reftests/css-valid/select/select-disabled.html
+++ b/layout/reftests/css-ui-valid/select/select-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='notvalid' disabled></select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-dyn-disabled.html
copy to layout/reftests/css-ui-valid/select/select-dyn-disabled.html
--- a/layout/reftests/css-valid/select/select-dyn-disabled.html
+++ b/layout/reftests/css-ui-valid/select/select-dyn-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if select is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('s').disabled='true'; document.documentElement.className='';">
     <select class='notvalid' id='s'></select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-dyn-not-disabled.html
copy to layout/reftests/css-ui-valid/select/select-dyn-not-disabled.html
--- a/layout/reftests/css-valid/select/select-dyn-not-disabled.html
+++ b/layout/reftests/css-ui-valid/select/select-dyn-not-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if select is not disabled, it is candidate for constraint validation
-             and should be affected by :valid pseudo-class. -->
+             and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('s').removeAttribute('disabled'); document.documentElement.className='';">
     <select class='valid' id='s' disabled></select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-fieldset-legend-ref.html
copy to layout/reftests/css-ui-valid/select/select-fieldset-legend-ref.html
copy from layout/reftests/css-valid/select/select-fieldset-legend.html
copy to layout/reftests/css-ui-valid/select/select-fieldset-legend.html
--- a/layout/reftests/css-valid/select/select-fieldset-legend.html
+++ b/layout/reftests/css-ui-valid/select/select-fieldset-legend.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select has a disabled fieldset ancestor, but is in the first
              legend, it is not barred from constraint validation and should be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <legend>
         <select class='valid'></select>
       </legend>
     </fieldset>
   </body>
copy from layout/reftests/css-valid/select/select-fieldset-ref.html
copy to layout/reftests/css-ui-valid/select/select-fieldset-ref.html
copy from layout/reftests/css-valid/select/select-invalid.html
copy to layout/reftests/css-ui-valid/select/select-invalid.html
--- a/layout/reftests/css-valid/select/select-invalid.html
+++ b/layout/reftests/css-ui-valid/select/select-invalid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
-  <!-- Test: if select has a custom error, it should not be affected by :valid
+  <!-- Test: if select has a custom error, it should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('s').setCustomValidity('foo'); document.documentElement.className='';">
     <select class='notvalid' id='s'></select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-ref.html
copy to layout/reftests/css-ui-valid/select/select-ref.html
copy from layout/reftests/css-valid/select/select-required-invalid.html
copy to layout/reftests/css-ui-valid/select/select-required-invalid.html
--- a/layout/reftests/css-valid/select/select-required-invalid.html
+++ b/layout/reftests/css-ui-valid/select/select-required-invalid.html
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select is required and has a select option which has an empty
-             string value, :valid should not apply. -->
+             string value, :-moz-ui-valid should not apply. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='notvalid' required>
       <option selected value="">foo</option>
     </select>
   </body>
 </html></html>
copy from layout/reftests/css-valid/select/select-required-multiple-invalid.html
copy to layout/reftests/css-ui-valid/select/select-required-multiple-invalid.html
--- a/layout/reftests/css-valid/select/select-required-multiple-invalid.html
+++ b/layout/reftests/css-ui-valid/select/select-required-multiple-invalid.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select is required and has all selected option value set to the
-             string string, :valid should not apply. -->
+             string string, :-moz-ui-valid should not apply. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='notvalid' required multiple>
       <option selected></option>
       <option selected value="">foo</option>
     </select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-required-multiple-ref.html
copy to layout/reftests/css-ui-valid/select/select-required-multiple-ref.html
copy from layout/reftests/css-valid/select/select-required-multiple-valid.html
copy to layout/reftests/css-ui-valid/select/select-required-multiple-valid.html
--- a/layout/reftests/css-valid/select/select-required-multiple-valid.html
+++ b/layout/reftests/css-ui-valid/select/select-required-multiple-valid.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select is required and has a selected option which has value
-             different from the empty string, :valid should apply. -->
+             different from the empty string, :-moz-ui-valid should apply. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='valid' required multiple>
       <option selected></option>
       <option selected>foo</option>
     </select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-required-ref.html
copy to layout/reftests/css-ui-valid/select/select-required-ref.html
copy from layout/reftests/css-valid/select/select-required-valid.html
copy to layout/reftests/css-ui-valid/select/select-required-valid.html
--- a/layout/reftests/css-valid/select/select-required-valid.html
+++ b/layout/reftests/css-ui-valid/select/select-required-valid.html
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select is required and has a select option which has value
-             different from the empty string, :valid should apply. -->
+             different from the empty string, :-moz-ui-valid should apply. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='valid' required>
       <option selected>foo</option>
     </select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/select-valid.html
copy to layout/reftests/css-ui-valid/select/select-valid.html
--- a/layout/reftests/css-valid/select/select-valid.html
+++ b/layout/reftests/css-ui-valid/select/select-valid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if select has no custom error and is not barred from constraint
-             validation, it should be affected by :valid pseudo-class. -->
+             validation, it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <select class='valid'></select>
   </body>
 </html>
copy from layout/reftests/css-valid/select/style.css
copy to layout/reftests/css-ui-valid/select/style.css
--- a/layout/reftests/css-valid/select/style.css
+++ b/layout/reftests/css-ui-valid/select/style.css
@@ -1,18 +1,18 @@
 /* Override default style */
 select:invalid {
   box-shadow: none;
 }
 
 select.notvalid {
   background-color: green;
 }
-select.notvalid:valid {
+select.notvalid:-moz-ui-valid {
   background-color: red;
 }
 
 select.valid {
   background-color: red;
 }
-select.valid:valid {
+select.valid:-moz-ui-valid {
   background-color: green;
 }
copy from layout/reftests/css-valid/textarea/reftest.list
copy to layout/reftests/css-ui-valid/textarea/reftest.list
copy from layout/reftests/css-valid/textarea/style.css
copy to layout/reftests/css-ui-valid/textarea/style.css
--- a/layout/reftests/css-valid/textarea/style.css
+++ b/layout/reftests/css-ui-valid/textarea/style.css
@@ -1,18 +1,18 @@
 /* Override default style */
 textarea:invalid {
   box-shadow: none;
 }
 
 textarea.notvalid {
   background-color: green;
 }
-textarea.notvalid:valid {
+textarea.notvalid:-moz-ui-valid {
   background-color: red;
 }
 
 textarea.valid {
   background-color: red;
 }
-textarea.valid:valid {
+textarea.valid:-moz-ui-valid {
   background-color: green;
 }
copy from layout/reftests/css-valid/textarea/textarea-customerror.html
copy to layout/reftests/css-ui-valid/textarea/textarea-customerror.html
--- a/layout/reftests/css-valid/textarea/textarea-customerror.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-customerror.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
-  <!-- Test: if textarea has a custom error, it should not be affected by :valid
+  <!-- Test: if textarea has a custom error, it should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').setCustomValidity('foo'); document.documentElement.className='';">
     <textarea class='notvalid' id='t'></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-disabled-fieldset-1.html
copy to layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-1.html
--- a/layout/reftests/css-valid/textarea/textarea-disabled-fieldset-1.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-1.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <fieldset>
         <textarea class='notvalid'></textarea>
       </fieldset>
     </fieldset>
copy from layout/reftests/css-valid/textarea/textarea-disabled-fieldset-2.html
copy to layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-2.html
--- a/layout/reftests/css-valid/textarea/textarea-disabled-fieldset-2.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-disabled-fieldset-2.html
@@ -1,12 +1,12 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea has a disabled fieldset ancestor, it is barred from
-             constraint validation and should not be affected by :valid
+             constraint validation and should not be affected by :-moz-ui-valid
              pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <script>
     function onloadHandler()
     {
       var fieldsets = document.getElementsByTagName("fieldset");
       fieldsets[1].disabled = true;
       fieldsets[0].disabled = false;
copy from layout/reftests/css-valid/textarea/textarea-disabled.html
copy to layout/reftests/css-ui-valid/textarea/textarea-disabled.html
--- a/layout/reftests/css-valid/textarea/textarea-disabled.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='notvalid' disabled></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-dyn-disabled.html
copy to layout/reftests/css-ui-valid/textarea/textarea-dyn-disabled.html
--- a/layout/reftests/css-valid/textarea/textarea-dyn-disabled.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-dyn-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea is disabled, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').disabled='true'; document.documentElement.className='';">
     <textarea class='notvalid' id='t'></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-dyn-not-disabled.html
copy to layout/reftests/css-ui-valid/textarea/textarea-dyn-not-disabled.html
--- a/layout/reftests/css-valid/textarea/textarea-dyn-not-disabled.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-dyn-not-disabled.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea is not disabled, it is candidate for constraint validation
-             and should be affected by :valid pseudo-class. -->
+             and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').removeAttribute('disabled'); document.documentElement.className='';">
     <textarea class='valid' id='t' disabled></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-dyn-not-readonly.html
copy to layout/reftests/css-ui-valid/textarea/textarea-dyn-not-readonly.html
--- a/layout/reftests/css-valid/textarea/textarea-dyn-not-readonly.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-dyn-not-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea is no longer readonly, it is candidate for constraint
-             validation and should be affected by :valid pseudo-class. -->
+             validation and should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').removeAttribute('readonly'); document.documentElement.className='';">
     <textarea class='valid' id='t' readonly></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-dyn-readonly.html
copy to layout/reftests/css-ui-valid/textarea/textarea-dyn-readonly.html
--- a/layout/reftests/css-valid/textarea/textarea-dyn-readonly.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-dyn-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea is readonly, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').readOnly='ro'; document.documentElement.className='';">
     <textarea class='notvalid' id='t'></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-fieldset-legend-ref.html
copy to layout/reftests/css-ui-valid/textarea/textarea-fieldset-legend-ref.html
copy from layout/reftests/css-valid/textarea/textarea-fieldset-legend.html
copy to layout/reftests/css-ui-valid/textarea/textarea-fieldset-legend.html
--- a/layout/reftests/css-valid/textarea/textarea-fieldset-legend.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-fieldset-legend.html
@@ -1,13 +1,13 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea has a disabled fieldset ancestor, but is in the first
              legend, it is not barred from constraint validation and should be
-             affected by :valid pseudo-class. -->
+             affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <fieldset disabled>
       <legend>
         <textarea class='valid'></textarea>
       </legend>
     </fieldset>
   </body>
copy from layout/reftests/css-valid/textarea/textarea-fieldset-ref.html
copy to layout/reftests/css-ui-valid/textarea/textarea-fieldset-ref.html
copy from layout/reftests/css-valid/textarea/textarea-maxlength-invalid.html
copy to layout/reftests/css-ui-valid/textarea/textarea-maxlength-invalid.html
--- a/layout/reftests/css-valid/textarea/textarea-maxlength-invalid.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-maxlength-invalid.html
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html class="reftest-wait">
   <!-- Test: if textarea isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <!-- TODO: this is valid until bug bug 613016 and bug 613019 are fixed. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body onload="document.getElementById('t').value='foo'; document.documentElement.className='';">
     <textarea class='valid' maxlength="2" id='t'></textarea>
   </body>
 </html>
 
copy from layout/reftests/css-valid/textarea/textarea-maxlength-valid.html
copy to layout/reftests/css-ui-valid/textarea/textarea-maxlength-valid.html
--- a/layout/reftests/css-valid/textarea/textarea-maxlength-valid.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-maxlength-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea is valid and is not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='valid' maxlength="2"></textarea>
   </body>
 </html>
 
copy from layout/reftests/css-valid/textarea/textarea-readonly.html
copy to layout/reftests/css-ui-valid/textarea/textarea-readonly.html
--- a/layout/reftests/css-valid/textarea/textarea-readonly.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-readonly.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea is readonly, it is barred from constraint validation
-             and should not be affected by :valid pseudo-class. -->
+             and should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='notvalid' readonly></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-ref.html
copy to layout/reftests/css-ui-valid/textarea/textarea-ref.html
copy from layout/reftests/css-valid/textarea/textarea-required-invalid.html
copy to layout/reftests/css-ui-valid/textarea/textarea-required-invalid.html
--- a/layout/reftests/css-valid/textarea/textarea-required-invalid.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-required-invalid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea isn't valid nor barred from constraint validation,
-             it should not be affected by :valid pseudo-class. -->
+             it should not be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='notvalid' required></textarea>
   </body>
 </html>
 
copy from layout/reftests/css-valid/textarea/textarea-required-valid.html
copy to layout/reftests/css-ui-valid/textarea/textarea-required-valid.html
--- a/layout/reftests/css-valid/textarea/textarea-required-valid.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-required-valid.html
@@ -1,10 +1,10 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea is valid and not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='valid' required>foo</textarea>
   </body>
 </html>
 
copy from layout/reftests/css-valid/textarea/textarea-valid.html
copy to layout/reftests/css-ui-valid/textarea/textarea-valid.html
--- a/layout/reftests/css-valid/textarea/textarea-valid.html
+++ b/layout/reftests/css-ui-valid/textarea/textarea-valid.html
@@ -1,9 +1,9 @@
 <!DOCTYPE html>
 <html>
   <!-- Test: if textarea is valid and is not barred from constraint validation,
-             it should be affected by :valid pseudo-class. -->
+             it should be affected by :-moz-ui-valid pseudo-class. -->
   <link rel='stylesheet' type='text/css' href='style.css'>
   <body>
     <textarea class='valid'></textarea>
   </body>
 </html>
copy from layout/reftests/css-valid/textarea/textarea-withtext-ref.html
copy to layout/reftests/css-ui-valid/textarea/textarea-withtext-ref.html
--- a/layout/reftests/reftest.list
+++ b/layout/reftests/reftest.list
@@ -90,16 +90,19 @@ include css-invalid/reftest.list
 include css-submit-invalid/reftest.list
 
 # css transitions
 include css-transitions/reftest.list
 
 # css :-moz-ui-invalid
 include css-ui-invalid/reftest.list
 
+# css :-moz-ui-valid
+include css-ui-valid/reftest.list
+
 # css values and units
 include css-valuesandunits/reftest.list
 
 # Reftests in css-visited are run using
 # layout/style/test/test_visited_reftests instead of using the reftest
 # harness.
 
 include cssom/reftest.list