summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/date-multiple-fields/date-multiple-fields-fallback-format.html
blob: 7f0dbbf46e84edb09938e6bcb08fba41e8caa37a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.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>
</body>
</html>