blob: c1a7622b621bccfdb5d15dd6e63297256472c7a1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Tests for value sanitization algorithm.');
var input = document.createElement('input');
input.type = 'datetime';
debug('Valid values:');
shouldBeEqualToString('input.value = "2009-09-07T16:49Z"; input.value', '2009-09-07T16:49Z');
shouldBeEqualToString('input.value = "2009-09-07T16:49:31.123Z"; input.value', '2009-09-07T16:49:31.123Z');
debug('Valid values, normalized:');
shouldBeEqualToString('input.value = "2009-09-07T16:49:00Z"; input.value', '2009-09-07T16:49Z');
shouldBeEqualToString('input.value = "2009-09-07T16:49:00.000Z"; input.value', '2009-09-07T16:49Z');
shouldBeEqualToString('input.value = "2012-01-01T00:00+00:00"; input.value', '2012-01-01T00:00Z');
shouldBeEqualToString('input.value = "2012-01-01T00:00-00:00"; input.value', '2012-01-01T00:00Z');
shouldBeEqualToString('input.value = "2012-01-01T00:00+01:00"; input.value', '2011-12-31T23:00Z');
shouldBeEqualToString('input.value = "2012-01-01T00:00-01:00"; input.value', '2012-01-01T01:00Z');
shouldBeEqualToString('input.value = "2011-12-31T23:59:59.999-23:59"; input.value', '2012-01-01T23:58:59.999Z');
debug('Invalid values:');
shouldBeEqualToString('input.value = "a"; input.value', '');
shouldBeEqualToString('input.value = "2009-09-07T16:49Z "; input.value', '');
shouldBeEqualToString('input.value = " 2009-09-07T16:49Z"; input.value', '');
shouldBeEqualToString('input.value = "2009-09-07T16:49"; input.value', '');
shouldBeEqualToString('input.value = "2009-09-07T16:49"; input.value', '');
shouldBeEqualToString('input.value = "2009-09-07T16:49-24:00"; input.value', '');
shouldBeEqualToString('input.value = "2009-09-07T16:49-01:00:00"; input.value', '');
shouldBeEqualToString('input.value = "0000-12-31T23:59"; input.value', '');
shouldBeEqualToString('input.value = "2012-01-00T00:00"; input.value', '');
shouldBeEqualToString('input.value = "2012-00-01T00:00"; input.value', '');
shouldBeEqualToString('input.value = "0001-01-01T00:00:60"; input.value', '');
shouldBeEqualToString('input.value = "0001-01-01T00:60:00"; input.value', '');
shouldBeEqualToString('input.value = "0001-01-01T24:00:00"; input.value', '');
shouldBeEqualToString('input.value = "0001-01-32T00:00:00"; input.value', '');
shouldBeEqualToString('input.value = "0001-02-29T00:00:00"; input.value', '');
shouldBeEqualToString('input.value = "0001-13-01T00:00:00"; input.value', '');
shouldBeEqualToString('input.value = "2147483648-01-01T00:00:00"; input.value', '');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>