diff options
author | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-03-22 10:04:16 +0000 |
---|---|---|
committer | commit-queue@webkit.org <commit-queue@webkit.org@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2013-03-22 10:04:16 +0000 |
commit | 1b5ee4337fe825d39095d42dbd596f153c48ac36 (patch) | |
tree | e2ceefb56b6cf2edc4e4a264ab8def5b8cc7530a /third_party/WebKit/LayoutTests/fast | |
parent | 7551108a40902e5e45d0679df2ce7e0bc8c090c1 (diff) | |
download | chromium_src-1b5ee4337fe825d39095d42dbd596f153c48ac36.zip chromium_src-1b5ee4337fe825d39095d42dbd596f153c48ac36.tar.gz chromium_src-1b5ee4337fe825d39095d42dbd596f153c48ac36.tar.bz2 |
INPUT_MULTIPLE_FIELDS_UI: Incomplete datetime format should fallback to default
https://bugs.webkit.org/show_bug.cgi?id=113005
Patch by Kunihiko Sakamoto <ksakamoto@chromium.org> on 2013-03-22
Reviewed by Kent Tamura.
Source/WebCore:
Use fallback format when datetime format from locale is not complete.
Tests: fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html
fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html
fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html
fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html
fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html
fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html
* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(DateTimeFormatValidator): A helper class that parses datetime format and tests existence of fields.
(WebCore::DateTimeFormatValidator::DateTimeFormatValidator):
(WebCore::DateTimeFormatValidator::visitField):
(WebCore::DateTimeFormatValidator::validateFormat): Parses datetime format and validates by calling BaseMultipleFieldsDateAndTimeInputType::isValidFormat.
(WebCore::BaseMultipleFieldsDateAndTimeInputType::updateInnerTextValue): Checks if dateTimeFormat is valid, and uses fallback format if not.
* html/BaseMultipleFieldsDateAndTimeInputType.h:
(BaseMultipleFieldsDateAndTimeInputType): Declare isValidFormat.
* html/DateInputType.cpp:
(WebCore::DateInputType::isValidFormat): Added.
* html/DateInputType.h:
(DateInputType):
* html/DateTimeInputType.cpp:
(WebCore::DateTimeInputType::isValidFormat): Added.
* html/DateTimeInputType.h:
(DateTimeInputType):
* html/DateTimeLocalInputType.cpp:
(WebCore::DateTimeLocalInputType::isValidFormat): Added.
* html/DateTimeLocalInputType.h:
(DateTimeLocalInputType):
* html/MonthInputType.cpp:
(WebCore::MonthInputType::isValidFormat): Added.
* html/MonthInputType.h:
(MonthInputType):
* html/TimeInputType.cpp:
(WebCore::TimeInputType::isValidFormat): Added.
* html/TimeInputType.h:
(TimeInputType):
* html/WeekInputType.cpp:
(WebCore::WeekInputType::isValidFormat): Added.
* html/WeekInputType.h:
(WeekInputType):
LayoutTests:
* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt: Added.
* fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html: Added.
git-svn-id: svn://svn.chromium.org/blink/trunk@146584 bbb929c8-8fbe-4397-9dbb-9b2b20218538
Diffstat (limited to 'third_party/WebKit/LayoutTests/fast')
12 files changed, 324 insertions, 0 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..56631f1 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,15 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "31-07-1999" +Invalid format, fallback to yyyy-MM-dd +PASS getUserAgentShadowTextContent(input) is "1999-07-31" +PASS getUserAgentShadowTextContent(input) is "1999-07-31" +PASS getUserAgentShadowTextContent(input) is "1999-07-31" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html new file mode 100644 index 0000000..cd9b260 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'date'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '1999-07-31'; + +debug('Valid format'); +setDateTimeFormat("dd-MM-yyyy"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '31-07-1999'); + +debug("Invalid format, fallback to yyyy-MM-dd"); +setDateTimeFormat('yyyy-MM'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31'); +setDateTimeFormat('MM/dd'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31'); +setDateTimeFormat('dd-yyyy'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..a72bb79 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,15 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "1999-07-31 11:59 PM" +Invalid format, fallback to yyyy-MM-dd'T'HH:mm +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html new file mode 100644 index 0000000..209f688 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/datetime-multiple-fields/datetime-multiple-fields-fallback-format.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'datetime-local'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '1999-07-31T23:59'; + +debug('Valid format'); +setDateTimeFormat("yyyy-MM-dd hh:mm a"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31 11:59 PM'); + +debug("Invalid format, fallback to yyyy-MM-dd'T'HH:mm"); +setDateTimeFormat('yyyy-MM-dd'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); +setDateTimeFormat('HH:mm'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); +setDateTimeFormat("yyyy-MM-dd'T'hh:mm"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..a72bb79 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,15 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "1999-07-31 11:59 PM" +Invalid format, fallback to yyyy-MM-dd'T'HH:mm +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS getUserAgentShadowTextContent(input) is "1999-07-31T23:59" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html new file mode 100644 index 0000000..209f688 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/datetimelocal-multiple-fields/datetimelocal-multiple-fields-fallback-format.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'datetime-local'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '1999-07-31T23:59'; + +debug('Valid format'); +setDateTimeFormat("yyyy-MM-dd hh:mm a"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31 11:59 PM'); + +debug("Invalid format, fallback to yyyy-MM-dd'T'HH:mm"); +setDateTimeFormat('yyyy-MM-dd'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); +setDateTimeFormat('HH:mm'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); +setDateTimeFormat("yyyy-MM-dd'T'hh:mm"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07-31T23:59'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..b38b96a --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,14 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "07-1999" +Invalid format, fallback to yyyy-MM +PASS getUserAgentShadowTextContent(input) is "1999-07" +PASS getUserAgentShadowTextContent(input) is "1999-07" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html new file mode 100644 index 0000000..29511ab --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/month-multiple-fields/month-multiple-fields-fallback-format.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'month'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '1999-07'; + +debug('Valid format'); +setDateTimeFormat('MM-yyyy'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '07-1999'); + +debug('Invalid format, fallback to yyyy-MM'); +setDateTimeFormat('mm-yyyy'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07'); +setDateTimeFormat('M'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-07'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..42174d4 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,17 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "01.234:59:11 PM" +PASS getUserAgentShadowTextContent(input) is "01.234:59:23" +PASS getUserAgentShadowTextContent(input) is "01.234:59:23 PM" +Invalid format, fallback to HH:mm:ss +PASS getUserAgentShadowTextContent(input) is "23:59:01.234" +PASS getUserAgentShadowTextContent(input) is "23:59:01.234" +PASS getUserAgentShadowTextContent(input) is "23:59:01.234" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html new file mode 100644 index 0000000..766e161 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/time-multiple-fields/time-multiple-fields-fallback-format.html @@ -0,0 +1,43 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'time'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '23:59:01.234'; + +debug('Valid format'); +setDateTimeFormat('ss:mm:hh a'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:11 PM'); +setDateTimeFormat('ss:mm:HH'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23'); +setDateTimeFormat('ss:mm:HH a'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '01.234:59:23 PM'); + +debug('Invalid format, fallback to HH:mm:ss'); +setDateTimeFormat('HH'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234'); +setDateTimeFormat('mm:ss'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234'); +setDateTimeFormat('hh:mm:ss'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '23:59:01.234'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt new file mode 100644 index 0000000..7b2cca8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format-expected.txt @@ -0,0 +1,14 @@ +Checks incomplete datetime formats are rejected. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Valid format +PASS getUserAgentShadowTextContent(input) is "Week09 1999" +Invalid format, fallback to yyyy-'W'ww +PASS getUserAgentShadowTextContent(input) is "1999-W09" +PASS getUserAgentShadowTextContent(input) is "1999-W09" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html new file mode 100644 index 0000000..25f492b --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/forms/week-multiple-fields/week-multiple-fields-fallback-format.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<html> +<head> +<script src="../../js/resources/js-test-pre.js"></script> +<script src="../resources/common.js"></script> +</head> +<body> +<script> +description('Checks incomplete datetime formats are rejected.'); + +var input = document.createElement('input'); +input.type = 'week'; +document.body.appendChild(input); + +function setDateTimeFormat(pattern) { + var value = input.value; + getElementByPseudoId(internals.youngestShadowRoot(input), '-webkit-datetime-edit').setAttribute('pattern', pattern); + input.value = ''; // Updates the element for new format + input.value = value; +} + +input.value = '1999-W09'; + +debug('Valid format'); +setDateTimeFormat("'Week'ww yyyy"); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', 'Week09 1999'); + +debug("Invalid format, fallback to yyyy-'W'ww"); +setDateTimeFormat('ww'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09'); +setDateTimeFormat('yyyy'); +shouldBeEqualToString('getUserAgentShadowTextContent(input)', '1999-W09'); + +</script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> |