Title: [207509] trunk
Revision
207509
Author
cdu...@apple.com
Date
2016-10-18 17:27:59 -0700 (Tue, 18 Oct 2016)

Log Message

Provide better form validation messages
https://bugs.webkit.org/show_bug.cgi?id=163584

Reviewed by Darin Adler.

Source/WebCore:

Provide better form validation messages that match more closely the ones
from Chrome and Firefox.

No new tests, updated existing tests.

* English.lproj/Localizable.strings:
* platform/LocalizedStrings.cpp:
(WebCore::validationMessageValueMissingText):
(WebCore::validationMessageValueMissingForCheckboxText):
(WebCore::validationMessageValueMissingForFileText):
(WebCore::validationMessageValueMissingForMultipleFileText):
(WebCore::validationMessageValueMissingForRadioText):
(WebCore::validationMessageValueMissingForSelectText):
(WebCore::validationMessageTypeMismatchText):
(WebCore::validationMessageTypeMismatchForEmailText):
(WebCore::validationMessageTypeMismatchForMultipleEmailText):
(WebCore::validationMessageTypeMismatchForURLText):
(WebCore::validationMessagePatternMismatchText):
(WebCore::validationMessageTooShortText):
(WebCore::validationMessageTooLongText):
(WebCore::validationMessageRangeUnderflowText):
(WebCore::validationMessageRangeOverflowText):
(WebCore::validationMessageStepMismatchText):
(WebCore::validationMessageBadInputForNumberText):

LayoutTests:

Update existing tests now that form validation messages differ.

* fast/forms/number/number-validation-message-expected.txt:
* fast/forms/number/number-validation-message.html:
* fast/forms/validationMessage-expected.txt:
* platform/mac/fast/forms/validation-message-appearance-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207508 => 207509)


--- trunk/LayoutTests/ChangeLog	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/ChangeLog	2016-10-19 00:27:59 UTC (rev 207509)
@@ -1,3 +1,17 @@
+2016-10-18  Chris Dumez  <cdu...@apple.com>
+
+        Provide better form validation messages
+        https://bugs.webkit.org/show_bug.cgi?id=163584
+
+        Reviewed by Darin Adler.
+
+        Update existing tests now that form validation messages differ.
+
+        * fast/forms/number/number-validation-message-expected.txt:
+        * fast/forms/number/number-validation-message.html:
+        * fast/forms/validationMessage-expected.txt:
+        * platform/mac/fast/forms/validation-message-appearance-expected.txt:
+
 2016-10-18  Ryan Haddad  <ryanhad...@apple.com>
 
         Marking http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/basic-upgrade-cors.https.html as flaky on Sierra.

Modified: trunk/LayoutTests/fast/forms/date/input-date-validation-message-expected.txt (207508 => 207509)


--- trunk/LayoutTests/fast/forms/date/input-date-validation-message-expected.txt	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/fast/forms/date/input-date-validation-message-expected.txt	2016-10-19 00:27:59 UTC (rev 207509)
@@ -6,15 +6,15 @@
 No message
 PASS testIt("", "", "") is ""
 Value missing
-PASS testIt("", "", "") is "value missing"
+FAIL testIt("", "", "") should be value missing. Was Please fill out this field..
 Type mismatch
 PASS testIt("foo", "", "") is ""
 Range overflow
-PASS testIt("1982-11-02", "", "1970-12-31") is "range overflow"
+FAIL testIt("1982-11-02", "", "1970-12-31") should be range overflow. Was Value must be less than or equal to 1970-12-31..
 Range underflow
-PASS testIt("1982-11-02", "1990-05-25", "1990-12-24") is "range underflow"
+FAIL testIt("1982-11-02", "1990-05-25", "1990-12-24") should be range underflow. Was Value must be greater than or equal to 1990-05-25..
 Step mismatch
-PASS testIt("1982-11-02", "", "", "123") is "step mismatch"
+FAIL testIt("1982-11-02", "", "", "123") should be step mismatch. Was Please enter a valid value..
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/forms/number/number-validation-message-expected.txt (207508 => 207509)


--- trunk/LayoutTests/fast/forms/number/number-validation-message-expected.txt	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/fast/forms/number/number-validation-message-expected.txt	2016-10-19 00:27:59 UTC (rev 207509)
@@ -6,15 +6,15 @@
 No message
 PASS testIt("", "", "") is ""
 Value missing
-PASS testIt("", "", "") is "value missing"
+PASS testIt("", "", "") is "Please fill out this field."
 Type mismatch
 PASS testIt("foo", "", "") is ""
 Range overflow
-PASS testIt("200", "", "100") is "range overflow"
+PASS testIt("200", "", "100") is "Value must be less than or equal to 100."
 Range underflow
-PASS testIt("10", "50", "100") is "range underflow"
+PASS testIt("10", "50", "100") is "Value must be greater than or equal to 50."
 Step mismatch
-PASS testIt("55", "0", "100", "10") is "step mismatch"
+PASS testIt("55", "0", "100", "10") is "Please enter a valid value."
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/forms/number/number-validation-message.html (207508 => 207509)


--- trunk/LayoutTests/fast/forms/number/number-validation-message.html	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/fast/forms/number/number-validation-message.html	2016-10-19 00:27:59 UTC (rev 207509)
@@ -25,7 +25,7 @@
 
 debug('Value missing')
 input.setAttribute("required", "");
-shouldBeEqualToString('testIt("", "", "")', 'value missing');
+shouldBeEqualToString('testIt("", "", "")', 'Please fill out this field.');
 input.removeAttribute("required");
 
 debug('Type mismatch');
@@ -32,13 +32,13 @@
 shouldBeEqualToString('testIt("foo", "", "")', '');
 
 debug('Range overflow')
-shouldBeEqualToString('testIt("200", "", "100")', 'range overflow');
+shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to 100.');
 
 debug('Range underflow')
-shouldBeEqualToString('testIt("10", "50", "100")', 'range underflow');
+shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to 50.');
 
 debug('Step mismatch')
-shouldBeEqualToString('testIt("55", "0", "100", "10")', 'step mismatch');
+shouldBeEqualToString('testIt("55", "0", "100", "10")', 'Please enter a valid value.');
 
 </script>
 <script src=""

Modified: trunk/LayoutTests/fast/forms/validationMessage-expected.txt (207508 => 207509)


--- trunk/LayoutTests/fast/forms/validationMessage-expected.txt	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/fast/forms/validationMessage-expected.txt	2016-10-19 00:27:59 UTC (rev 207509)
@@ -3,12 +3,12 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-input patternMismatch: pattern mismatch
-input valueMissing: value missing
-textarea valueMissing: value missing
-select valueMissing: value missing
-input typeMismatch: type mismatch
-input badInput: type mismatch
+input patternMismatch: Please match the requested format.
+input valueMissing: Please fill out this field.
+textarea valueMissing: Please fill out this field.
+select valueMissing: Please select an item in the list.
+input typeMismatch: Please enter an email address.
+input badInput: Please enter a number.
 badInput and valueMissing:
 PASS numberInput.validationMessage is nonRequiredBadInputMessage
 PASS but.validationMessage is ''

Modified: trunk/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt (207508 => 207509)


--- trunk/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt	2016-10-19 00:27:59 UTC (rev 207509)
@@ -25,8 +25,8 @@
     RenderBlock {DIV} at (10,10) size 0x64
     RenderBlock {DIV} at (10,10) size 200x64
       RenderBlock {DIV} at (0,0) size 200x16
-        RenderText {#text} at (0,0) size 88x16
-          text run at (0,0) width 88: "value missing"
+        RenderText {#text} at (0,0) size 152x16
+          text run at (0,0) width 152: "Please fill out this field."
       RenderBlock {DIV} at (0,16) size 200x48
         RenderText {#text} at (0,0) size 145x16
           text run at (0,0) width 145: "Needs at least 8 letters."

Modified: trunk/LayoutTests/platform/mac-elcapitan/fast/forms/validation-message-appearance-expected.txt (207508 => 207509)


--- trunk/LayoutTests/platform/mac-elcapitan/fast/forms/validation-message-appearance-expected.txt	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/LayoutTests/platform/mac-elcapitan/fast/forms/validation-message-appearance-expected.txt	2016-10-19 00:27:59 UTC (rev 207509)
@@ -25,8 +25,8 @@
     RenderBlock {DIV} at (10,10) size 0x64
     RenderBlock {DIV} at (10,10) size 200x64
       RenderBlock {DIV} at (0,0) size 200x16
-        RenderText {#text} at (0,0) size 90x16
-          text run at (0,0) width 90: "value missing"
+        RenderText {#text} at (0,0) size 153x16
+          text run at (0,0) width 153: "Please fill out this field."
       RenderBlock {DIV} at (0,16) size 200x48
         RenderText {#text} at (0,0) size 147x16
           text run at (0,0) width 147: "Needs at least 8 letters."

Modified: trunk/Source/WebCore/ChangeLog (207508 => 207509)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 00:27:59 UTC (rev 207509)
@@ -1,3 +1,35 @@
+2016-10-18  Chris Dumez  <cdu...@apple.com>
+
+        Provide better form validation messages
+        https://bugs.webkit.org/show_bug.cgi?id=163584
+
+        Reviewed by Darin Adler.
+
+        Provide better form validation messages that match more closely the ones
+        from Chrome and Firefox.
+
+        No new tests, updated existing tests.
+
+        * English.lproj/Localizable.strings:
+        * platform/LocalizedStrings.cpp:
+        (WebCore::validationMessageValueMissingText):
+        (WebCore::validationMessageValueMissingForCheckboxText):
+        (WebCore::validationMessageValueMissingForFileText):
+        (WebCore::validationMessageValueMissingForMultipleFileText):
+        (WebCore::validationMessageValueMissingForRadioText):
+        (WebCore::validationMessageValueMissingForSelectText):
+        (WebCore::validationMessageTypeMismatchText):
+        (WebCore::validationMessageTypeMismatchForEmailText):
+        (WebCore::validationMessageTypeMismatchForMultipleEmailText):
+        (WebCore::validationMessageTypeMismatchForURLText):
+        (WebCore::validationMessagePatternMismatchText):
+        (WebCore::validationMessageTooShortText):
+        (WebCore::validationMessageTooLongText):
+        (WebCore::validationMessageRangeUnderflowText):
+        (WebCore::validationMessageRangeOverflowText):
+        (WebCore::validationMessageStepMismatchText):
+        (WebCore::validationMessageBadInputForNumberText):
+
 2016-10-18  Dave Hyatt  <hy...@apple.com>
 
         Fix GTK build.

Modified: trunk/Source/WebCore/English.lproj/Localizable.strings (207508 => 207509)


--- trunk/Source/WebCore/English.lproj/Localizable.strings	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/Source/WebCore/English.lproj/Localizable.strings	2016-10-19 00:27:59 UTC (rev 207509)
@@ -217,9 +217,6 @@
 /* Undo action name */
 "Cut (Undo action name)" = "Cut";
 
-/* accessibility role description for a date field */
-"date field" = "date field";
-
 /* Default writing direction context menu item */
 "Default" = "Default";
 
@@ -247,9 +244,6 @@
 /* Undo action name */
 "Drag (Undo action name)" = "Drag";
 
-/* accessibility role description for an email field */
-"email field" = "email field";
-
 /* Video Enter Fullscreen context menu item */
 "Enter Full Screen" = "Enter Full Screen";
 
@@ -310,6 +304,9 @@
 /* Inspect Element context menu item */
 "Inspect Element" = "Inspect Element";
 
+/* Validation message for input form controls with a value not matching type */
+"Invalid value." = "Invalid value.";
+
 /* Italic context menu item */
 "Italic" = "Italic";
 
@@ -466,6 +463,42 @@
 /* accessibility help text for enter fullscreen button */
 "Play movie in fullscreen mode" = "Play movie in fullscreen mode";
 
+/* Validation message for required checkboxes that have not be checked */
+"Please check this box if you want to proceed." = "Please check this box if you want to proceed.";
+
+/* Validation message for input form controls of type 'url' that have an invalid value */
+"Please enter a URL." = "Please enter a URL.";
+
+/* Validation message for number fields where the user entered a non-number string */
+"Please enter a number." = "Please enter a number.";
+
+/* Validation message for input form controls with value not respecting the step attribute */
+"Please enter a valid value." = "Please enter a valid value.";
+
+/* Validation message for input form controls of type 'email' that have an invalid value */
+"Please enter an email address." = "Please enter an email address.";
+
+/* Validation message for required form control elements that have no value */
+"Please fill out this field." = "Please fill out this field.";
+
+/* Validation message for input form controls requiring a constrained value according to pattern */
+"Please match the requested format." = "Please match the requested format.";
+
+/* Validation message for required file inputs that have no value */
+"Please select a file." = "Please select a file.";
+
+/* Validation message for required menu list controls that have no selection */
+"Please select an item in the list." = "Please select an item in the list.";
+
+/* Validation message for required radio boxes that have no selection */
+"Please select one of these options." = "Please select one of these options.";
+
+/* Validation message for form control elements with a value shorter than minimum allowed length */
+"Please use at least %d characters." = "Please use at least %d characters.";
+
+/* Validation message for form control elements with a value shorter than maximum allowed length */
+"Please use no more than %d characters." = "Please use no more than %d characters.";
+
 /* Label text to be used if plugin host process has crashed */
 "Plug-in Failure" = "Plug-in Failure";
 
@@ -619,9 +652,6 @@
 /* File Upload alert sheet camera button string for taking only videos */
 "Take Video (file upload action sheet)" = "Take Video";
 
-/* accessibility role description for a telephone number field */
-"telephone number field" = "telephone number field";
-
 /* Text Replacement context menu item */
 "Text Replacement" = "Text Replacement";
 
@@ -688,6 +718,9 @@
 /* Undo action name */
 "Typing (Undo action name)" = "Typing";
 
+/* accessibility role description for a URL field. */
+"URL field" = "URL field";
+
 /* Underline context menu item */
 "Underline" = "Underline";
 
@@ -721,6 +754,12 @@
 /* Description of WebCrypto master keys in Keychain */
 "Used to encrypt WebCrypto keys in persistent storage, such as IndexedDB" = "Used to encrypt WebCrypto keys in persistent storage, such as IndexedDB";
 
+/* Validation message for input form controls with value lower than allowed minimum */
+"Value must be greater than or equal to %@." = "Value must be greater than or equal to %@.";
+
+/* Validation message for input form controls with value higher than allowed maximum */
+"Value must be less than or equal to %@." = "Value must be less than or equal to %@.";
+
 /* Web Inspector window title when inspecting Web Inspector */
 "Web Inspector [%d] — %@" = "Web Inspector [%d] — %@";
 
@@ -811,6 +850,9 @@
 /* accessibility help text for elapsed time display */
 "current movie time in seconds" = "current movie time in seconds";
 
+/* accessibility role description for a date field. */
+"date field" = "date field";
+
 /* role description of ARIA definition role */
 "definition" = "definition";
 
@@ -829,6 +871,9 @@
 /* accessibility label for elapsed time display */
 "elapsed time" = "elapsed time";
 
+/* accessibility role description for an email field. */
+"email field" = "email field";
+
 /* accessibility label for enter fullscreen button */
 "enter fullscreen" = "enter fullscreen";
 
@@ -979,9 +1024,6 @@
 /* Label for the auto fill credentials button inside a text field. */
 "password auto fill" = "password auto fill";
 
-/* Validation message for input form controls requiring a constrained value according to pattern */
-"pattern mismatch" = "pattern mismatch";
-
 /* accessibility label for pause button */
 "pause" = "pause";
 
@@ -1075,9 +1117,6 @@
 /* accessibility label for movie status */
 "status" = "status";
 
-/* Validation message for input form controls with value not respecting the step attribute */
-"step mismatch" = "step mismatch";
-
 /* accessibility help text for hide closed captions button */
 "stop displaying closed captions" = "stop displaying closed captions";
 
@@ -1093,6 +1132,9 @@
 /* An ARIA accessibility group that contains the content of a tab. */
 "tab panel" = "tab panel";
 
+/* accessibility role description for a telephone number field. */
+"telephone number field" = "telephone number field";
+
 /* HTTP result code string */
 "temporarily redirected" = "temporarily redirected";
 
@@ -1099,7 +1141,7 @@
 /* term word of a description list */
 "term" = "term";
 
-/* accessibility role description for a time field */
+/* accessibility role description for a time field. */
 "time field" = "time field";
 
 /* accessibility label for timeline thumb */
@@ -1108,18 +1150,9 @@
 /* An ARIA accessibility group that acts as an updating timer. */
 "timer" = "timer";
 
-/* Validation message for form control elements with a value longer than maximum allowed length */
-"too long" = "too long";
-
-/* Validation message for form control elements with a value shorter than minimum allowed length */
-"too short" = "too short";
-
 /* An ARIA accessibility group that acts as a tooltip. */
 "tooltip" = "tooltip";
 
-/* Validation message for input form controls with a value not matching type */
-"type mismatch" = "type mismatch";
-
 /* HTTP result code string */
 "unacceptable" = "unacceptable";
 
@@ -1147,12 +1180,6 @@
 /* HTTP result code string */
 "unsupported version" = "unsupported version";
 
-/* accessibility role description for a URL field */
-"URL field" = "URL field";
-
-/* Validation message for required form control elements that have no value */
-"value missing" = "value missing";
-
 /* accessibility help text for video element controller */
 "video element playback controls and status display" = "video element playback controls and status display";
 

Modified: trunk/Source/WebCore/platform/LocalizedStrings.cpp (207508 => 207509)


--- trunk/Source/WebCore/platform/LocalizedStrings.cpp	2016-10-19 00:21:50 UTC (rev 207508)
+++ trunk/Source/WebCore/platform/LocalizedStrings.cpp	2016-10-19 00:27:59 UTC (rev 207509)
@@ -1050,88 +1050,97 @@
 
 String validationMessageValueMissingText()
 {
-    return WEB_UI_STRING("value missing", "Validation message for required form control elements that have no value");
+    return WEB_UI_STRING("Please fill out this field.", "Validation message for required form control elements that have no value");
 }
 
 String validationMessageValueMissingForCheckboxText()
 {
-    return validationMessageValueMissingText();
+    return WEB_UI_STRING("Please check this box if you want to proceed.", "Validation message for required checkboxes that have not be checked");
 }
 
 String validationMessageValueMissingForFileText()
 {
-    return validationMessageValueMissingText();
+    return WEB_UI_STRING("Please select a file.", "Validation message for required file inputs that have no value");
 }
 
 String validationMessageValueMissingForMultipleFileText()
 {
-    return validationMessageValueMissingText();
+    return validationMessageValueMissingForFileText();
 }
 
 String validationMessageValueMissingForRadioText()
 {
-    return validationMessageValueMissingText();
+    return WEB_UI_STRING("Please select one of these options.", "Validation message for required radio boxes that have no selection");
 }
 
 String validationMessageValueMissingForSelectText()
 {
-    return validationMessageValueMissingText();
+    return WEB_UI_STRING("Please select an item in the list.", "Validation message for required menu list controls that have no selection");
 }
 
 String validationMessageTypeMismatchText()
 {
-    return WEB_UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type");
+    return WEB_UI_STRING("Invalid value.", "Validation message for input form controls with a value not matching type");
 }
 
 String validationMessageTypeMismatchForEmailText()
 {
-    return validationMessageTypeMismatchText();
+    return WEB_UI_STRING("Please enter an email address.", "Validation message for input form controls of type 'email' that have an invalid value");
 }
 
 String validationMessageTypeMismatchForMultipleEmailText()
 {
-    return validationMessageTypeMismatchText();
+    return validationMessageTypeMismatchForEmailText();
 }
 
 String validationMessageTypeMismatchForURLText()
 {
-    return validationMessageTypeMismatchText();
+    return WEB_UI_STRING("Please enter a URL.", "Validation message for input form controls of type 'url' that have an invalid value");
 }
 
 String validationMessagePatternMismatchText()
 {
-    return WEB_UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern");
+    return WEB_UI_STRING("Please match the requested format.", "Validation message for input form controls requiring a constrained value according to pattern");
 }
 
-String validationMessageTooShortText(int, int)
+String validationMessageTooShortText(int, int minLength)
 {
-    return WEB_UI_STRING("too short", "Validation message for form control elements with a value shorter than minimum allowed length");
+    return formatLocalizedString(WEB_UI_STRING("Please use at least %d characters.", "Validation message for form control elements with a value shorter than minimum allowed length"), minLength);
 }
 
-String validationMessageTooLongText(int, int)
+String validationMessageTooLongText(int, int maxLength)
 {
-    return WEB_UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length");
+    return formatLocalizedString(WEB_UI_STRING("Please use no more than %d characters.", "Validation message for form control elements with a value shorter than maximum allowed length"), maxLength);
 }
 
-String validationMessageRangeUnderflowText(const String&)
+String validationMessageRangeUnderflowText(const String& minimum)
 {
+#if PLATFORM(COCOA)
+    return formatLocalizedString(WEB_UI_STRING("Value must be greater than or equal to %@.", "Validation message for input form controls with value lower than allowed minimum"), minimum.createCFString().get());
+#else
+    UNUSED_PARAM(minimum);
     return WEB_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
+#endif
 }
 
-String validationMessageRangeOverflowText(const String&)
+String validationMessageRangeOverflowText(const String& maximum)
 {
+#if PLATFORM(COCOA)
+    return formatLocalizedString(WEB_UI_STRING("Value must be less than or equal to %@.", "Validation message for input form controls with value higher than allowed maximum"), maximum.createCFString().get());
+#else
+    UNUSED_PARAM(maximum);
     return WEB_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
+#endif
 }
 
 String validationMessageStepMismatchText(const String&, const String&)
 {
-    return WEB_UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute");
+    return WEB_UI_STRING("Please enter a valid value.", "Validation message for input form controls with value not respecting the step attribute");
 }
 
 String validationMessageBadInputForNumberText()
 {
-    notImplemented();
-    return validationMessageTypeMismatchText();
+    return WEB_UI_STRING("Please enter a number.", "Validation message for number fields where the user entered a non-number string");
 }
 
 String clickToExitFullScreenText()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to