1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Bug 1310079 - Implement the min and max attribute for <input type=datetime-local>

This commit is contained in:
janekptacijarabaci
2018-03-30 19:56:09 +02:00
committed by Roy Tam
parent 344ea39e20
commit c140ca5b67
9 changed files with 88 additions and 112 deletions
+3 -6
View File
@@ -7848,8 +7848,7 @@ HTMLInputElement::HasPatternMismatch() const
bool
HTMLInputElement::IsRangeOverflow() const
{
// TODO: this is temporary until bug 888331 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_DATETIME_LOCAL) {
if (!DoesMinMaxApply()) {
return false;
}
@@ -7869,8 +7868,7 @@ HTMLInputElement::IsRangeOverflow() const
bool
HTMLInputElement::IsRangeUnderflow() const
{
// TODO: this is temporary until bug 888331 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_DATETIME_LOCAL) {
if (!DoesMinMaxApply()) {
return false;
}
@@ -8878,8 +8876,7 @@ HTMLInputElement::UpdateHasRange()
mHasRange = false;
// TODO: this is temporary until bug 888331 is fixed.
if (!DoesMinMaxApply() || mType == NS_FORM_INPUT_DATETIME_LOCAL) {
if (!DoesMinMaxApply()) {
return;
}
+42 -5
View File
@@ -31,8 +31,7 @@ var data = [
{ type: 'month', apply: true },
{ type: 'week', apply: true },
{ type: 'time', apply: true },
// TODO: temporary set to false until bug 888331 is fixed.
{ type: 'datetime-local', apply: false },
{ type: 'datetime-local', apply: true },
{ type: 'number', apply: true },
{ type: 'range', apply: true },
{ type: 'color', apply: false },
@@ -71,7 +70,8 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
"element overflow status should be " + !aValidity);
var overflowMsg =
(aElement.type == "date" || aElement.type == "time" ||
aElement.type == "month" || aElement.type == "week") ?
aElement.type == "month" || aElement.type == "week" ||
aElement.type == "datetime-local") ?
("Please select a value that is no later than " + aElement.max + ".") :
("Please select a value that is no more than " + aElement.max + ".");
is(aElement.validationMessage,
@@ -148,7 +148,7 @@ for (var test of data) {
input.max = '2016-W39';
break;
case 'datetime-local':
// TODO: this is temporary until bug 888331 is fixed.
input.max = '2016-12-31T23:59:59';
break;
default:
ok(false, 'please, add a case for this new type (' + input.type + ')');
@@ -421,7 +421,44 @@ for (var test of data) {
break;
case 'datetime-local':
// TODO: this is temporary until bug 888331 is fixed.
input.value = '2016-01-01T12:00';
checkValidity(input, true, apply, apply);
input.value = '2016-12-31T23:59:59';
checkValidity(input, true, apply, apply);
input.value = 'foo';
checkValidity(input, true, apply, apply);
input.value = '2016-12-31T23:59:59.123';
checkValidity(input, false, apply, apply);
input.value = '2017-01-01T10:00';
checkValidity(input, false, apply, apply);
input.max = '2017-01-01T10:00';
checkValidity(input, true, apply, apply);
input.value = '2017-01-01T10:00:30';
checkValidity(input, false, apply, apply);
input.value = '1000-01-01T12:00';
checkValidity(input, true, apply, apply);
input.value = '2100-01-01T12:00';
checkValidity(input, false, apply, apply);
input.max = '0050-12-31T23:59:59.999';
checkValidity(input, false, apply, apply);
input.value = '0050-12-31T23:59:59';
checkValidity(input, true, apply, apply);
input.max = '';
checkValidity(input, true, apply, false);
input.max = 'foo';
checkValidity(input, true, apply, false);
break;
}
+43 -6
View File
@@ -31,8 +31,7 @@ var data = [
{ type: 'month', apply: true },
{ type: 'week', apply: true },
{ type: 'time', apply: true },
// TODO: temporary set to false until bug 888331 is fixed.
{ type: 'datetime-local', apply: false },
{ type: 'datetime-local', apply: true },
{ type: 'number', apply: true },
{ type: 'range', apply: true },
{ type: 'color', apply: false },
@@ -71,7 +70,8 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
"element underflow status should be " + !aValidity);
var underflowMsg =
(aElement.type == "date" || aElement.type == "time" ||
aElement.type == "month" || aElement.type == "week") ?
aElement.type == "month" || aElement.type == "week" ||
aElement.type == "datetime-local") ?
("Please select a value that is no earlier than " + aElement.min + ".") :
("Please select a value that is no less than " + aElement.min + ".");
is(aElement.validationMessage,
@@ -146,10 +146,10 @@ for (var test of data) {
input.min = '2016-06';
break;
case 'week':
input.min = "2016-W39";
input.min = '2016-W39';
break;
case 'datetime-local':
// TODO: this is temporary until bug 888331 is fixed.
input.min = '2017-01-01T00:00';
break;
default:
ok(false, 'please, add a case for this new type (' + input.type + ')');
@@ -420,7 +420,44 @@ for (var test of data) {
checkValidity(input, true, apply, false);
break;
case 'datetime-local':
// TODO: this is temporary until bug 888331 is fixed.
input.value = '2017-12-31T23:59';
checkValidity(input, true, apply, apply);
input.value = '2017-01-01T00:00';
checkValidity(input, true, apply, apply);
input.value = '2017-01-01T00:00:00.123';
checkValidity(input, true, apply, apply);
input.value = 'foo';
checkValidity(input, true, apply, apply);
input.value = '2016-12-31T23:59';
checkValidity(input, false, apply, apply);
input.min = '2016-01-01T00:00';
checkValidity(input, true, apply, apply);
input.value = '2015-12-31T23:59';
checkValidity(input, false, apply, apply);
input.value = '1000-01-01T00:00';
checkValidity(input, false, apply, apply);
input.value = '10000-01-01T00:00';
checkValidity(input, true, apply, apply);
input.min = '0010-01-01T12:00';
checkValidity(input, true, apply, apply);
input.value = '0010-01-01T10:00';
checkValidity(input, false, apply, apply);
input.min = '';
checkValidity(input, true, apply, false);
input.min = 'foo';
checkValidity(input, true, apply, false);
break;
default:
ok(false, 'write tests for ' + input.type);
@@ -33,21 +33,6 @@
[[INPUT in DATETIME status\] The datetime type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The datetime-local type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an overflow]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an overflow (in a form)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an underflow]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an underflow (in a form)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from a step mismatch]
expected: FAIL
@@ -39,21 +39,6 @@
[[INPUT in DATETIME status\] The datetime type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The datetime-local type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an overflow]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an overflow (in a form)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an underflow]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from an underflow (in a form)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] suffering from a step mismatch]
expected: FAIL
@@ -3,21 +3,3 @@
[[INPUT in DATETIME status\] The datetime type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The datetime-local type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is greater than max]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is greater than max(with millisecond in 1 digit)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is greater than max(with millisecond in 2 digits)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is greater than max(with millisecond in 3 digits)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is greater than max(Year is 10000 should be valid)]
expected: FAIL
@@ -3,21 +3,3 @@
[[INPUT in DATETIME status\] The datetime type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The datetime-local type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is less than min]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is less than min(with millisecond in 1 digit)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is less than min(with millisecond in 2 digits)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is less than min(with millisecond in 3 digits)]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The value is less than min(Year is 10000 should be valid)]
expected: FAIL
@@ -24,15 +24,6 @@
[[INPUT in MONTH status\] validity.valid must be false if validity.stepMismatch is true]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] The datetime-local type must be supported.]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] validity.valid must be false if validity.rangeOverflow is true]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] validity.valid must be false if validity.rangeUnderflow is true]
expected: FAIL
[[INPUT in DATETIME-LOCAL status\] validity.valid must be false if validity.stepMismatch is true]
expected: FAIL
@@ -1,20 +0,0 @@
[inrange-outofrange.html]
type: testharness
[':in-range' matches all elements that are candidates for constraint validation, have range limitations, and that are neither suffering from an underflow nor suffering from an overflow]
expected: FAIL
[':in-range' update number1's value < min]
expected: FAIL
[':in-range' update number3's min < value]
expected: FAIL
[':out-of-range' matches all elements that are candidates for constraint validation, have range limitations, and that are either suffering from an underflow or suffering from an overflow]
expected: FAIL
[':out-of-range' update number1's value < min]
expected: FAIL
[':out-of-range' update number3's min < value]
expected: FAIL