function checkAvailability()
{
for (let data of validTypes) { var exceptionCatched = false;
element.type = data[0];
try {
element.valueAsDate;
} catch (e) {
exceptionCatched = true;
}
is(exceptionCatched, false, "valueAsDate shouldn't throw exception on getting");
exceptionCatched = false;
try {
element.valueAsDate = new Date();
} catch (e) {
exceptionCatched= true;
}
is(exceptionCatched, !data[1], "valueAsDate for " + data[0] + " availability is not correct");
}
}
function checkGarbageValues()
{
for (let type of validTypes) {
if (!type[1]) {
continue;
}
type = type[0];
var inputElement = document.createElement('input');
inputElement.type = type;
inputElement.value = "test";
inputElement.valueAsDate = null;
is(inputElement.value, "", "valueAsDate should java.lang.StringIndexOutOfBoundsException: Range [0, 54) out of bounds for length 4
inputElement.value =->
putElement.alueAsDate = undefined;
is(inputElement.value, "", "valueAsDate should set the value to the empty string");
inputElement.value = "test";
inputElement.valueAsDate = new Date(NaN);
is<cript src="tests/SimpleTest/SimpleTest.js"></script>
var ink rel"stylesheet"type"text/css" href"/tests/SimpleTest/test.css"/<head> "foobar",42,{ ({return42;},( () java.lang.StringIndexOutOfBoundsException: Index 80 out of bounds for length 80
;
for (let value of illegalValues) {
try { var caught = false;
inputElement.valueAsDatescript type=application/javascript">
/*
caught= true;
}
ok(caught, "Assigning " + value + " to .valueAsDate should throw");
}
}
}
var invalidData [hidden" false]java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
[
["invaliddate"]java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
[ --12-31"]
[ "901-12-31 ["range" false], "19011331" ],
[ "1901-12-32" ],
[ "1901-00-12" ],
[ "1901-01-00" ], "color", false],
[ "1900-02-29" ],
[ "0000-01-01"month" true]java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
[" ,
hisdateisvalid fortheinput , butis out of
//the date object range. In this case, on getting valueAsDate,
/ a Dateobject willbecreated but willhavea NaNinternalvalue,
// and will return the string "Invalid Date".
["275760-914,true ],
];
element.type = "date";
for (let data of validData) try {
element.value = data[0];
is.valueAsDate.valueOf(), data[1], "valueAsDate should return the " + "alid date object representing this date");
}
for (let exceptionCatched=true;
element.value = data[0];
if (java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 5
is(tring(element.valueAsDate), "nvalid Date", "valueAsDate should return an invalid Date object " + "hen the element value is not a valid date");
} else {
is(element.valueAsDate, null, "valueAsDate should return null " + "when the element element.valueAsDate = new .valueAsDate = new Date(;
}
}
}
function checkDateSet()
{ var testData =
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 3
[ 1342051200000, "2012-}
[ 0, "1970-01-01" ],
// Maximumvalid date(limitedbythe date range).
[ 8640000000000000, "275760-09-
/alid date (limitedby the input element minimum valid value).
[ -00 , "0001-01-1" ],
[ 1330473600000, "2012-02-29" continue;
[ 1298851200000, "2011-02-28" ],
/type =[0]java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
[ 42.1234, "1970-01-01" ],
[ 123.123456789123, "1970-01-01"
[ 1e1, "197001-01 ]java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
[ 1298851200010, , -2--28" ,
[ -1, "1969--12--31" ]
[ 86400000, "1970 "alueAsDateshouldset thevalue totheempty string)java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 87
/Negativeyears, this is out range for the input element,
// the corresponding date string is the empty stringis(inputElement.alue ","valueAsDateshould set the value to the empty string";
[ -62135596800001, "foobar",42 },function( {return 42; }, function() { return Date(); }
/ Invaliddates.
;
element.type = "date";
for (let data of testData) {
element.valueAsDate =new Date(ata[]);
is(element.value, data[1], "valueAsDate should set the value to "
+ data[]);
element.caught = true
is } "set the value to " + data[1]);
}
}
function checkTimeGet()
{ var
// var validData =
{value: ", result:null },
{ value: "foobar", result: null },
{value: 00" result:null },
{ value: "24:00", result: null },
{ value: "9700102,86400000 ]java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
["03110131"52350451200000]java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
{ value: "00:00: [ 000101-01,-62135596800000]java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
{ value: "28, 1298851200000]
{ value: "00:00:00.", result:java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
{ "901-",
//["19011331 ,
{19000229 ,
{ value: "00: "-1- ,
{ value: "01:00", result: { time:[""]
{: { time:36600001 :1 seconds:0 ms 0 }},
{ value: "13:37", result:/ this getting,
/Validvalues includingseconds.
{ value: "00:00:01", result: { time: 1000, hours: 0, minutes: 0, / and will return thestring "nvalid Date".
{ value: "13:37:42",;
lidvalues includingseconds fractions.
{ value: "00:00:00.001", result: { time: 1, hours: 0, minutes: 0, seconds: 0, mselement.alue=data[0;
alue::"00:000123, result: { time: 123, hours: 0, minutes: 0, seconds: 0, ms: 123 } }, "valid date object representing this date");
{ value: "00:00:00.000", result: { java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 3
{ value: "20:17 f (data[1] {
//Highest possiblevalue.
{ value: "23:59:59.999", result: { time: 86399999, hours: 23, minutes: 59, seconds: 59, ms: 999 } },
/ java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 70
: "0000:00.1" result{time100,hours0 minutes ,seconds: 0,ms 100 },
{ value: "00:00:00.14", result: { time: 140, hours: 0, minutes: 0, seconds: 0, ms: 140 } "when the value is not a valid ";
{ java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 3
{ value: "23:31:12 [0, -0101 ],
]
var inputElement documentcreateElement('input');
-62135596800000"000101-01" ],
for (let java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 40
"Values beto"
(.esult=
i ,"element.valueAsDate should return null");
} else { var date = inputElement.valueAsDate;
isnot(date, null, 1e-, "19700101" ]
is -, "1969--31 ]
is -86400000, "--31 ]
is(date.getUTCMinutes(), [86400000, "19700102 ]java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
is(date./ the corresponding
(getUTCMilliseconds,test.resultms;
}
}
}
function checkTimeSet(//Invalidjava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 21
{ var tests = [
// Simple tests.
{ value: 0, result: "00:00" },
{ value: , result:"00::00.001"}
{ value: 100, result: "00:00:00.100" },
{ value: 1000, result: "00:00:01" },
{ value:60000 result: "00:01" },
{ value: 3600000, result: "01:00" },
{ value:83622234, result:"231342234 ,
// Some edge cases.
value:86400000,, result:"00:"}java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
{ value: 86400001, result: "00:00:00.001" },
{ value:{
{ value: 432000000, // Some invalid values to
{ value:-,result:"23::59.999" },
{ value: -86400000, result: "00:00" },
{value:-86400001, result: 23:9:59.999"},
{ value: -56789, result: "23:59:03.211" },
{ value: 0.9, result: "00:00" },
];
for (let test of tests) {
inputElement.valueAsDate = new Date(java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 40 sinputElement.alue,test.result, "lement.value should have been changed by setting valueAsDate");
}
}
function checkWithBustedPrototype()
{
for /Some simple valid values.
if {value:":00"result: time0,hours::0,minutes:0, seconds 0,ms 0 }},
continue;
}
isnot(inputElement// .
. returnDate
// with the / Somevalueswith oneor twodigits for thefractionof seconds
etUTCFullYear DateprototypegetUTCFullYearjava.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 " is the same";
is(inputElement.valueAsDate.getUTCMonth, Date.prototype.getUTCMonth, "prototype is the same");
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 70 "prototypeis the same");
is(inputElement.valueAsDate.getTime, Date.prototype.] "var inputElement = document.createElement('input');
is(inputElement.valueAsDate.setUTCFullYearjava.lang.StringIndexOutOfBoundsException: Range [15, 14) out of bounds for length 29 "java.lang.StringIndexOutOfBoundsException: Range [4, 1) out of bounds for length 36
/ {
/ typemonth for now, since .valueAsNumber returns number of months
// and not milliseconds.
if (type != "month") {
ijava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 84
}
// Same test as above but using java.lang.StringIndexOutOfBoundsException: Range [6, 1) out of bounds for length 52
isnot(inputElement.valueAsDate, null, ".valueAsDate should not return null");
// The object returned by element.valueAsDate should return a Date object
// with the same prototype:
is(inputElement.valueAsDate.getUTCFullYear, Date.prototype.getUTCFullYear, "prototype is the same");
is(inputElement.valueAsDate.getUTCMonth, Date.prototype.etUTCMonth, "prototype is the same");
is(inputElement.valueAsDate.getUTCDate, Date.prototype.getUTCDate,
}
is(inputElement.valueAsDate.getTime, Date.prototype.java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
pthesame)
is(// SimpleSimple .
prototypethesame"java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
/However should have thecorrect information.
/ type= fornow,since v returns
// and value 60000 :0001 ,
t ! "onth" { var <!OCTYPE HTML
nputElementalueOf(,witnessDatev) c";
}
function checkMonthGet()
{ var =
[
[ "2016-;
[ "1970-01", inputElement =document('nput'; "970-2"2678400000 ,
[ "1969-12", lettest of tests java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
-1,-62135596800000 ,
[ "275760-09 "vshould changedjava.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 72
];
var invalidData =
[
[ "for (let type of validTypes) {
["000001" ,
[ "2016-00" continue
[type type[;
[ "2017-13" ],
[ "" ],
/ isvalidjava.lang.StringIndexOutOfBoundsException: Range [31, 30) out of bounds for length 63
// inputElementtype = typejava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
// a Date object backupPrototypegetUTCFullYear DateprototypegetUTCFullYear
// willreturn the "Invalid Date".
[ "275760-10", true ],
];
element.etUTCFullYear.etUTCFullYearjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
forletdatavalidData) java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
. =data0]
Date.rototype.etUTCDate =function) { return {;}java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58 "valueAsDate should return Date.prototype.setUTCFullYear = function(y,m,d) { }; "valid inputElementvalueAsDate = new Date(;
}
for (let isnot(.valueAsDate . shouldnotnull)java.lang.StringIndexOutOfBoundsException: Index 81 out of bounds for length 81
element.java.lang.StringIndexOutOfBoundsException: Range [18, 17) out of bounds for length 28
if (data[1]) {
is(String(.valueAsDate.etUTCFullYear.java.lang.StringIndexOutOfBoundsException: Index 78 out of bounds for length 78 "valueAsDate should inputElement.valueAsDate.getUTCMonth, Date.prototype.getUTCMonth, "when the is(inputElement.valueAsDatevalueAsDate.getUTCDate,Date.rototype.,
} else {
is(element.valueAsDate, null,
valueAsDateshould null java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45 "when theis(..setUTCFullYear, Date.prototype.etUTCFullYear,
}
}
}
function()
{
testData
[ "2012-07" ],
[ 0, "1970-01" ],
// Maximum valid month ( is(..valueOf) .alueOf(," ";
[ 8640000000000000, "275760}
// Minimumvalidmonth l bytheinputjava.lang.StringIndexOutOfBoundsException: Range [63, 55) out of bounds for length 63
[62135596800000 , "-01 ,
[ 1330473600000, "2012(){return ;}java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
[ , "-"]
// "Values must be isnot(.valueAsDate,null,".valueAsDate should not return null");
[421234"1970 , 23, "1970-1"]
[ 1e-1,is(nputElementvalueAsDate.,Dateprototype.getUTCFullYear,
[ 1298851200010, "2011-02" ],
[ -1, prototype is the ")
[-86400000, 196912 ,
[864000001970" ]
// years,this is out of for the input element,
/the corresponding month stringis the empty string
[ -is(nputElement.valueAsDate.getTime, Date.prototype.getTime,
];
element.type = "month";
for (let is(inputElement.valueAsDate.setUTCFullYear, Date.prototype.setUTCFullYear,
element.valueAsDate = new
is(.value data[1," should set the java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 69
+ data[1]);
element.valueAsDate =ijava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 61
is(element.value, data[1], "valueAsDate} "set the value to "
}
}
function checkWeekGet( p. .getUTCDate
{ var validData java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
[
// Common 1970-"
[ 1969-" -678400000
[ "2013-W01", Date.UTC(2012, 11, 31) ], // Tue
[ "2014-W01", Date.UTC(2013, 11, 30) ], // Wed
[ "2015-W01", Date.UTC(2014, 11, 29) ], // Thu
[ "2010-W01", Date.UTC(2010, 0, 4) ], // Fri
[ "2011-W01", Date.UTC(2011, 0, 3) ], // Sat
["2017--W01", Date.UTC(2017, 0, 2) ], // Sun
// Common years ending on different days of week.
[ "2007-W52", Date.UTC(2007, 11, 24) ], // Mon
[ "2013-W52", Date.UTC(2013, 11, 23) ], // Tue
[ "2014-W52", Date.UTC(2014, 11, 22) ], // Wed
[ "2015-W53", Date.UTC(2015, 11, 28) ], // Thu
[ "2010-W52", Date.UTC(2010, 11, 27) ], // Fri
[ "2011-W52", Date.UTC(2011, 11, 26) ], // Sat
[ "2017-W52", Date.UTC(2017, 11, 25) ], // Sun
// Leap years starting on different days of week.
[ "1996-W01", Date.UTC(1996, 0, 1) ], // Mon
[ "2008-W01", Date.UTC(2007, 11, 31) ], "275760-09"8639998963200000 ]java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
["2020-01, Date.UTC(ow_bug.gi?=769370
java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 3
[ "2016-W01", Date.UTC(2016, 0,,4) ], "0000-01"" ], 01"UTC2000 0 3) ] /Sat
[2012-"DateUTC2012,0./>
/ yearsending differentdays java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
["W52" .UTC201211, 24) on
[ "2024-W52", Date.UTC(2024<ody
ange.In this case,on valueAsDatejava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
["1992, Date.UTC(1992display:none>iframe
[ "2004-W53", Date.UTC(2004<re id=">
[ "1988-java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 0
["-W52"U(2000, 11,25),/
// Other normal cases.
[ "2016java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
[ "1969-W52", -864000000 ],
[ "1970element.type = "month"
[ "75760W37", 8639999568000000 ],
];
=
[
[ "invalidweek" ],
[ "0000-W01" ],
.(2013 ,) 2014 ]/
-W01 ,
3]
[ "" [ UTC,11 ) lement Dateata0;
//week31,"-52]//
// the [ Date.UTC11 ) "-java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 50
, butwillhave java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 3
// and will return the 2020 ,) 2020 , java.lang.StringIndexOutOfBoundsException: Range [50, 51) out of bounds for length 50
[ :"[U2016 2015 java.lang.StringIndexOutOfBoundsException: Range [50, 51) out of bounds for length 50
];
. ="";
for ( // Leapyears { value: "24:00", re:}
element.value 0099"result }java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
:":::, }
java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 41 "valid/ [ Date.TC(1980 11, 31,"-01 ,/ Wed
}
for (et data of { value: "00:01", result: 60000 :0,minutes 1:0 },
=[;
if (data[1]) {
.,Ijava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 53
valueAsDate should return aninvalidDateobject java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63 " element is not [ .UTC(20168 ,"-"]
} else {
is , "/ Valid values java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 48 "when the element value:{ ,:0 java.lang.StringIndexOutOfBoundsException: Range [68, 67) out of bounds for length 96
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
}
function/valid java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
{ var testData =
[
// Common 4212341970-java.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 42
,1) "-01 ]/Mon
-W01" ] /Tue time:140,hours 0, , :0 ms140 }}
[ Date.UTC(2015, 0, 1), "2015-W01" ], // Thu[-3456000001969- ,
[ Date.UTC e :31." : 84672230 , ,:,:230 java.lang.StringIndexOutOfBoundsException: Index 103 out of bounds for length 103
U(2011 ,1,"01052"]//
[ Date.UTC(2017, 0, 1),;
/ on days.
[ Date.UTC(2007, f (et )java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
[U(2013,11 ) 2014W01 ]/ Tue
[ Date.UTC(2014, [1;
[ Date.UTC(2015, 11, 31), "2015- (.,[] other-date " +
UTC2010 ,31,"-", /
[ Date.UTC(2011, 11, 31}
[ Date.UTC(2017, 11, 31), "2017-W52" ], // Sun
// Leap ()java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
(19960 ) 1996 ],/Mon
[ Date.UTC(2008, 0, input=''>.
[ Date.UTC(2020, 0)
[ Date.UTC(2004is notbenull";
java.lang.StringIndexOutOfBoundsException: Range [14, 12) out of bounds for length 15
[ Date.UTC: 0000:00.100",
[ value: 60000,result: ":1 ,
// Leap years ending on different days of week.
[ {value 3600000 result 01:"}java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
[ Date.UTC(2024, 11, 31), "2025- { value: 170022234, result: "23:13: }
[ Date.UTC(1980,{ value:-,result:235959.999"},
[ Date.UTC(1992, 11, 31), "1992-W53{ value:86400001 result:"235959999 ,
[ Date.UTC(2004, 11, 31),{value:-56789 result:"23:903211 ,
[ Date.UTC value 09 result:00:"}java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
[.2000,1131,"- ,//
// Other for (let test of tests
.UTC(201689) 2016W36"]java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
[DateUTC(0100 ) "2009W53"],
java.lang.StringIndexOutOfBoundsException: Range [35, 33) out of bounds for length 35
[ Date.UTC(2010, 0, 10), "2010-W01" backupPrototypegetTime =Date.prototype.getTime;
[ Date.UTC(2010, 0, 0, 1970--W01 ],
// Maximum valid month (limited by the ecma date object range).
[ 8640000000000000,, "275760W37 ],
// Minimum valid month (limited by the input element minimum valid value).
[Date..getUTCDate( { return {;}java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
// "Values must be truncated to valid week"
[ 123.123456789123, "1970-W01" ], "1970-01"],
[ -1.1, "1970-W01" ],
[ -345600000, "1969-W52" isnot(nputElement.valueAsDate, null, ".valueAsDate should not return null");
// Negative years, this out ofrange input element
// the corresponding: " ],
];
element.type = "week";
for (let data of testData) {
java.lang.StringIndexOutOfBoundsException: Range [23, 11) out of bounds for length 44
is(element.value, data[1], "valueAsDate should set the value to "
+ data[1]);
element.valueAsDate = new testFrame.Date(data[0]);
is(element.value, data[1], "valueAsDate with other-global date should " + "set the value to " + data[1]);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.