Changeset 207509 in webkit


Ignore:
Timestamp:
Oct 18, 2016 5:27:59 PM (8 years ago)
Author:
Chris Dumez
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:
Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207506 r207509  
     12016-10-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Provide better form validation messages
     4        https://bugs.webkit.org/show_bug.cgi?id=163584
     5
     6        Reviewed by Darin Adler.
     7
     8        Update existing tests now that form validation messages differ.
     9
     10        * fast/forms/number/number-validation-message-expected.txt:
     11        * fast/forms/number/number-validation-message.html:
     12        * fast/forms/validationMessage-expected.txt:
     13        * platform/mac/fast/forms/validation-message-appearance-expected.txt:
     14
    1152016-10-18  Ryan Haddad  <ryanhaddad@apple.com>
    216
  • trunk/LayoutTests/fast/forms/date/input-date-validation-message-expected.txt

    r121019 r207509  
    77PASS testIt("", "", "") is ""
    88Value missing
    9 PASS testIt("", "", "") is "value missing"
     9FAIL testIt("", "", "") should be value missing. Was Please fill out this field..
    1010Type mismatch
    1111PASS testIt("foo", "", "") is ""
    1212Range overflow
    13 PASS testIt("1982-11-02", "", "1970-12-31") is "range overflow"
     13FAIL testIt("1982-11-02", "", "1970-12-31") should be range overflow. Was Value must be less than or equal to 1970-12-31..
    1414Range underflow
    15 PASS testIt("1982-11-02", "1990-05-25", "1990-12-24") is "range underflow"
     15FAIL 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..
    1616Step mismatch
    17 PASS testIt("1982-11-02", "", "", "123") is "step mismatch"
     17FAIL testIt("1982-11-02", "", "", "123") should be step mismatch. Was Please enter a valid value..
    1818PASS successfullyParsed is true
    1919
  • trunk/LayoutTests/fast/forms/number/number-validation-message-expected.txt

    r123302 r207509  
    77PASS testIt("", "", "") is ""
    88Value missing
    9 PASS testIt("", "", "") is "value missing"
     9PASS testIt("", "", "") is "Please fill out this field."
    1010Type mismatch
    1111PASS testIt("foo", "", "") is ""
    1212Range overflow
    13 PASS testIt("200", "", "100") is "range overflow"
     13PASS testIt("200", "", "100") is "Value must be less than or equal to 100."
    1414Range underflow
    15 PASS testIt("10", "50", "100") is "range underflow"
     15PASS testIt("10", "50", "100") is "Value must be greater than or equal to 50."
    1616Step mismatch
    17 PASS testIt("55", "0", "100", "10") is "step mismatch"
     17PASS testIt("55", "0", "100", "10") is "Please enter a valid value."
    1818PASS successfullyParsed is true
    1919
  • trunk/LayoutTests/fast/forms/number/number-validation-message.html

    r155268 r207509  
    2626debug('Value missing')
    2727input.setAttribute("required", "");
    28 shouldBeEqualToString('testIt("", "", "")', 'value missing');
     28shouldBeEqualToString('testIt("", "", "")', 'Please fill out this field.');
    2929input.removeAttribute("required");
    3030
     
    3333
    3434debug('Range overflow')
    35 shouldBeEqualToString('testIt("200", "", "100")', 'range overflow');
     35shouldBeEqualToString('testIt("200", "", "100")', 'Value must be less than or equal to 100.');
    3636
    3737debug('Range underflow')
    38 shouldBeEqualToString('testIt("10", "50", "100")', 'range underflow');
     38shouldBeEqualToString('testIt("10", "50", "100")', 'Value must be greater than or equal to 50.');
    3939
    4040debug('Step mismatch')
    41 shouldBeEqualToString('testIt("55", "0", "100", "10")', 'step mismatch');
     41shouldBeEqualToString('testIt("55", "0", "100", "10")', 'Please enter a valid value.');
    4242
    4343</script>
  • trunk/LayoutTests/fast/forms/validationMessage-expected.txt

    r147119 r207509  
    44
    55
    6 input patternMismatch: pattern mismatch
    7 input valueMissing: value missing
    8 textarea valueMissing: value missing
    9 select valueMissing: value missing
    10 input typeMismatch: type mismatch
    11 input badInput: type mismatch
     6input patternMismatch: Please match the requested format.
     7input valueMissing: Please fill out this field.
     8textarea valueMissing: Please fill out this field.
     9select valueMissing: Please select an item in the list.
     10input typeMismatch: Please enter an email address.
     11input badInput: Please enter a number.
    1212badInput and valueMissing:
    1313PASS numberInput.validationMessage is nonRequiredBadInputMessage
  • trunk/LayoutTests/platform/mac-elcapitan/fast/forms/validation-message-appearance-expected.txt

    r202826 r207509  
    2626    RenderBlock {DIV} at (10,10) size 200x64
    2727      RenderBlock {DIV} at (0,0) size 200x16
    28         RenderText {#text} at (0,0) size 90x16
    29           text run at (0,0) width 90: "value missing"
     28        RenderText {#text} at (0,0) size 153x16
     29          text run at (0,0) width 153: "Please fill out this field."
    3030      RenderBlock {DIV} at (0,16) size 200x48
    3131        RenderText {#text} at (0,0) size 147x16
  • trunk/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt

    r202826 r207509  
    2626    RenderBlock {DIV} at (10,10) size 200x64
    2727      RenderBlock {DIV} at (0,0) size 200x16
    28         RenderText {#text} at (0,0) size 88x16
    29           text run at (0,0) width 88: "value missing"
     28        RenderText {#text} at (0,0) size 152x16
     29          text run at (0,0) width 152: "Please fill out this field."
    3030      RenderBlock {DIV} at (0,16) size 200x48
    3131        RenderText {#text} at (0,0) size 145x16
  • trunk/Source/WebCore/ChangeLog

    r207507 r207509  
     12016-10-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Provide better form validation messages
     4        https://bugs.webkit.org/show_bug.cgi?id=163584
     5
     6        Reviewed by Darin Adler.
     7
     8        Provide better form validation messages that match more closely the ones
     9        from Chrome and Firefox.
     10
     11        No new tests, updated existing tests.
     12
     13        * English.lproj/Localizable.strings:
     14        * platform/LocalizedStrings.cpp:
     15        (WebCore::validationMessageValueMissingText):
     16        (WebCore::validationMessageValueMissingForCheckboxText):
     17        (WebCore::validationMessageValueMissingForFileText):
     18        (WebCore::validationMessageValueMissingForMultipleFileText):
     19        (WebCore::validationMessageValueMissingForRadioText):
     20        (WebCore::validationMessageValueMissingForSelectText):
     21        (WebCore::validationMessageTypeMismatchText):
     22        (WebCore::validationMessageTypeMismatchForEmailText):
     23        (WebCore::validationMessageTypeMismatchForMultipleEmailText):
     24        (WebCore::validationMessageTypeMismatchForURLText):
     25        (WebCore::validationMessagePatternMismatchText):
     26        (WebCore::validationMessageTooShortText):
     27        (WebCore::validationMessageTooLongText):
     28        (WebCore::validationMessageRangeUnderflowText):
     29        (WebCore::validationMessageRangeOverflowText):
     30        (WebCore::validationMessageStepMismatchText):
     31        (WebCore::validationMessageBadInputForNumberText):
     32
    1332016-10-18  Dave Hyatt  <hyatt@apple.com>
    234
  • trunk/Source/WebCore/English.lproj/Localizable.strings

    r207429 r207509  
    218218"Cut (Undo action name)" = "Cut";
    219219
    220 /* accessibility role description for a date field */
    221 "date field" = "date field";
    222 
    223220/* Default writing direction context menu item */
    224221"Default" = "Default";
     
    248245"Drag (Undo action name)" = "Drag";
    249246
    250 /* accessibility role description for an email field */
    251 "email field" = "email field";
    252 
    253247/* Video Enter Fullscreen context menu item */
    254248"Enter Full Screen" = "Enter Full Screen";
     
    311305"Inspect Element" = "Inspect Element";
    312306
     307/* Validation message for input form controls with a value not matching type */
     308"Invalid value." = "Invalid value.";
     309
    313310/* Italic context menu item */
    314311"Italic" = "Italic";
     
    467464"Play movie in fullscreen mode" = "Play movie in fullscreen mode";
    468465
     466/* Validation message for required checkboxes that have not be checked */
     467"Please check this box if you want to proceed." = "Please check this box if you want to proceed.";
     468
     469/* Validation message for input form controls of type 'url' that have an invalid value */
     470"Please enter a URL." = "Please enter a URL.";
     471
     472/* Validation message for number fields where the user entered a non-number string */
     473"Please enter a number." = "Please enter a number.";
     474
     475/* Validation message for input form controls with value not respecting the step attribute */
     476"Please enter a valid value." = "Please enter a valid value.";
     477
     478/* Validation message for input form controls of type 'email' that have an invalid value */
     479"Please enter an email address." = "Please enter an email address.";
     480
     481/* Validation message for required form control elements that have no value */
     482"Please fill out this field." = "Please fill out this field.";
     483
     484/* Validation message for input form controls requiring a constrained value according to pattern */
     485"Please match the requested format." = "Please match the requested format.";
     486
     487/* Validation message for required file inputs that have no value */
     488"Please select a file." = "Please select a file.";
     489
     490/* Validation message for required menu list controls that have no selection */
     491"Please select an item in the list." = "Please select an item in the list.";
     492
     493/* Validation message for required radio boxes that have no selection */
     494"Please select one of these options." = "Please select one of these options.";
     495
     496/* Validation message for form control elements with a value shorter than minimum allowed length */
     497"Please use at least %d characters." = "Please use at least %d characters.";
     498
     499/* Validation message for form control elements with a value shorter than maximum allowed length */
     500"Please use no more than %d characters." = "Please use no more than %d characters.";
     501
    469502/* Label text to be used if plugin host process has crashed */
    470503"Plug-in Failure" = "Plug-in Failure";
     
    620653"Take Video (file upload action sheet)" = "Take Video";
    621654
    622 /* accessibility role description for a telephone number field */
    623 "telephone number field" = "telephone number field";
    624 
    625655/* Text Replacement context menu item */
    626656"Text Replacement" = "Text Replacement";
     
    689719"Typing (Undo action name)" = "Typing";
    690720
     721/* accessibility role description for a URL field. */
     722"URL field" = "URL field";
     723
    691724/* Underline context menu item */
    692725"Underline" = "Underline";
     
    722755"Used to encrypt WebCrypto keys in persistent storage, such as IndexedDB" = "Used to encrypt WebCrypto keys in persistent storage, such as IndexedDB";
    723756
     757/* Validation message for input form controls with value lower than allowed minimum */
     758"Value must be greater than or equal to %@." = "Value must be greater than or equal to %@.";
     759
     760/* Validation message for input form controls with value higher than allowed maximum */
     761"Value must be less than or equal to %@." = "Value must be less than or equal to %@.";
     762
    724763/* Web Inspector window title when inspecting Web Inspector */
    725764"Web Inspector [%d] — %@" = "Web Inspector [%d] — %@";
     
    812851"current movie time in seconds" = "current movie time in seconds";
    813852
     853/* accessibility role description for a date field. */
     854"date field" = "date field";
     855
    814856/* role description of ARIA definition role */
    815857"definition" = "definition";
     
    830872"elapsed time" = "elapsed time";
    831873
     874/* accessibility role description for an email field. */
     875"email field" = "email field";
     876
    832877/* accessibility label for enter fullscreen button */
    833878"enter fullscreen" = "enter fullscreen";
     
    9801025"password auto fill" = "password auto fill";
    9811026
    982 /* Validation message for input form controls requiring a constrained value according to pattern */
    983 "pattern mismatch" = "pattern mismatch";
    984 
    9851027/* accessibility label for pause button */
    9861028"pause" = "pause";
     
    10761118"status" = "status";
    10771119
    1078 /* Validation message for input form controls with value not respecting the step attribute */
    1079 "step mismatch" = "step mismatch";
    1080 
    10811120/* accessibility help text for hide closed captions button */
    10821121"stop displaying closed captions" = "stop displaying closed captions";
     
    10941133"tab panel" = "tab panel";
    10951134
     1135/* accessibility role description for a telephone number field. */
     1136"telephone number field" = "telephone number field";
     1137
    10961138/* HTTP result code string */
    10971139"temporarily redirected" = "temporarily redirected";
     
    11001142"term" = "term";
    11011143
    1102 /* accessibility role description for a time field */
     1144/* accessibility role description for a time field. */
    11031145"time field" = "time field";
    11041146
     
    11091151"timer" = "timer";
    11101152
    1111 /* Validation message for form control elements with a value longer than maximum allowed length */
    1112 "too long" = "too long";
    1113 
    1114 /* Validation message for form control elements with a value shorter than minimum allowed length */
    1115 "too short" = "too short";
    1116 
    11171153/* An ARIA accessibility group that acts as a tooltip. */
    11181154"tooltip" = "tooltip";
    11191155
    1120 /* Validation message for input form controls with a value not matching type */
    1121 "type mismatch" = "type mismatch";
    1122 
    11231156/* HTTP result code string */
    11241157"unacceptable" = "unacceptable";
     
    11481181"unsupported version" = "unsupported version";
    11491182
    1150 /* accessibility role description for a URL field */
    1151 "URL field" = "URL field";
    1152 
    1153 /* Validation message for required form control elements that have no value */
    1154 "value missing" = "value missing";
    1155 
    11561183/* accessibility help text for video element controller */
    11571184"video element playback controls and status display" = "video element playback controls and status display";
  • trunk/Source/WebCore/platform/LocalizedStrings.cpp

    r207429 r207509  
    10511051String validationMessageValueMissingText()
    10521052{
    1053     return WEB_UI_STRING("value missing", "Validation message for required form control elements that have no value");
     1053    return WEB_UI_STRING("Please fill out this field.", "Validation message for required form control elements that have no value");
    10541054}
    10551055
    10561056String validationMessageValueMissingForCheckboxText()
    10571057{
    1058     return validationMessageValueMissingText();
     1058    return WEB_UI_STRING("Please check this box if you want to proceed.", "Validation message for required checkboxes that have not be checked");
    10591059}
    10601060
    10611061String validationMessageValueMissingForFileText()
    10621062{
    1063     return validationMessageValueMissingText();
     1063    return WEB_UI_STRING("Please select a file.", "Validation message for required file inputs that have no value");
    10641064}
    10651065
    10661066String validationMessageValueMissingForMultipleFileText()
    10671067{
    1068     return validationMessageValueMissingText();
     1068    return validationMessageValueMissingForFileText();
    10691069}
    10701070
    10711071String validationMessageValueMissingForRadioText()
    10721072{
    1073     return validationMessageValueMissingText();
     1073    return WEB_UI_STRING("Please select one of these options.", "Validation message for required radio boxes that have no selection");
    10741074}
    10751075
    10761076String validationMessageValueMissingForSelectText()
    10771077{
    1078     return validationMessageValueMissingText();
     1078    return WEB_UI_STRING("Please select an item in the list.", "Validation message for required menu list controls that have no selection");
    10791079}
    10801080
    10811081String validationMessageTypeMismatchText()
    10821082{
    1083     return WEB_UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type");
     1083    return WEB_UI_STRING("Invalid value.", "Validation message for input form controls with a value not matching type");
    10841084}
    10851085
    10861086String validationMessageTypeMismatchForEmailText()
    10871087{
    1088     return validationMessageTypeMismatchText();
     1088    return WEB_UI_STRING("Please enter an email address.", "Validation message for input form controls of type 'email' that have an invalid value");
    10891089}
    10901090
    10911091String validationMessageTypeMismatchForMultipleEmailText()
    10921092{
    1093     return validationMessageTypeMismatchText();
     1093    return validationMessageTypeMismatchForEmailText();
    10941094}
    10951095
    10961096String validationMessageTypeMismatchForURLText()
    10971097{
    1098     return validationMessageTypeMismatchText();
     1098    return WEB_UI_STRING("Please enter a URL.", "Validation message for input form controls of type 'url' that have an invalid value");
    10991099}
    11001100
    11011101String validationMessagePatternMismatchText()
    11021102{
    1103     return WEB_UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern");
    1104 }
    1105 
    1106 String validationMessageTooShortText(int, int)
    1107 {
    1108     return WEB_UI_STRING("too short", "Validation message for form control elements with a value shorter than minimum allowed length");
    1109 }
    1110 
    1111 String validationMessageTooLongText(int, int)
    1112 {
    1113     return WEB_UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length");
    1114 }
    1115 
    1116 String validationMessageRangeUnderflowText(const String&)
    1117 {
     1103    return WEB_UI_STRING("Please match the requested format.", "Validation message for input form controls requiring a constrained value according to pattern");
     1104}
     1105
     1106String validationMessageTooShortText(int, int minLength)
     1107{
     1108    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);
     1109}
     1110
     1111String validationMessageTooLongText(int, int maxLength)
     1112{
     1113    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);
     1114}
     1115
     1116String validationMessageRangeUnderflowText(const String& minimum)
     1117{
     1118#if PLATFORM(COCOA)
     1119    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());
     1120#else
     1121    UNUSED_PARAM(minimum);
    11181122    return WEB_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
    1119 }
    1120 
    1121 String validationMessageRangeOverflowText(const String&)
    1122 {
     1123#endif
     1124}
     1125
     1126String validationMessageRangeOverflowText(const String& maximum)
     1127{
     1128#if PLATFORM(COCOA)
     1129    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());
     1130#else
     1131    UNUSED_PARAM(maximum);
    11231132    return WEB_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
     1133#endif
    11241134}
    11251135
    11261136String validationMessageStepMismatchText(const String&, const String&)
    11271137{
    1128     return WEB_UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute");
     1138    return WEB_UI_STRING("Please enter a valid value.", "Validation message for input form controls with value not respecting the step attribute");
    11291139}
    11301140
    11311141String validationMessageBadInputForNumberText()
    11321142{
    1133     notImplemented();
    1134     return validationMessageTypeMismatchText();
     1143    return WEB_UI_STRING("Please enter a number.", "Validation message for number fields where the user entered a non-number string");
    11351144}
    11361145
Note: See TracChangeset for help on using the changeset viewer.