diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 98588cd3bea2..81ec2c02e09d 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -1007,8 +1007,8 @@ nsHTMLInputElement::GetValue(nsAString& aValue) { nsresult rv = GetValueInternal(aValue); - // Don't return non-sanitized value for number inputs. - if (mType == NS_FORM_INPUT_NUMBER) { + // Don't return non-sanitized value for types that are experimental on mobile. + if (IsExperimentalMobileType(mType)) { SanitizeValue(aValue); } @@ -2482,8 +2482,10 @@ nsHTMLInputElement::PreHandleEvent(nsEventChainPreVisitor& aVisitor) // Fire onchange (if necessary), before we do the blur, bug 357684. if (aVisitor.mEvent->message == NS_BLUR_CONTENT) { - // In number inputs we can't allow the user to set an invalid value. - if (mType == NS_FORM_INPUT_NUMBER) { + // Experimental mobile types rely on the system UI to prevent users to not + // set invalid values but we have to be extra-careful. Especially if the + // option has been enabled on desktop. + if (IsExperimentalMobileType(mType)) { nsAutoString aValue; GetValueInternal(aValue); SetValueInternal(aValue, false, false); @@ -2773,7 +2775,7 @@ nsHTMLInputElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) keyEvent->keyCode == NS_VK_ENTER) && (IsSingleLineTextControl(false, mType) || IsExperimentalMobileType(mType))) { - FireChangeEventIfNeeded(); + FireChangeEventIfNeeded(); rv = MaybeSubmitForm(aVisitor.mPresContext); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/content/html/content/test/forms/Makefile.in b/content/html/content/test/forms/Makefile.in index 8503dc8f2948..28b7b6ab9cf9 100644 --- a/content/html/content/test/forms/Makefile.in +++ b/content/html/content/test/forms/Makefile.in @@ -48,7 +48,7 @@ MOCHITEST_FILES = \ test_stepup_stepdown.html \ test_valueasnumber_attribute.html \ test_experimental_forms_pref.html \ - test_input_number_value.html \ + test_input_typing_sanitization.html \ test_input_sanitization.html \ test_valueasdate_attribute.html \ test_input_file_b2g_disabled.html \ diff --git a/content/html/content/test/forms/test_input_number_value.html b/content/html/content/test/forms/test_input_number_value.html deleted file mode 100644 index 13d7cf5d39f5..000000000000 --- a/content/html/content/test/forms/test_input_number_value.html +++ /dev/null @@ -1,135 +0,0 @@ - - - -
-- -- - diff --git a/content/html/content/test/forms/test_input_typing_sanitization.html b/content/html/content/test/forms/test_input_typing_sanitization.html new file mode 100644 index 000000000000..56bd11cb20f8 --- /dev/null +++ b/content/html/content/test/forms/test_input_typing_sanitization.html @@ -0,0 +1,226 @@ + + + + +
+ ++ +