mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +00:00
LibWeb: Add input element valueAsDate property
This commit is contained in:
parent
be511fdcf7
commit
cf69fd0a09
10 changed files with 314 additions and 9 deletions
14
Tests/LibWeb/Text/expected/input-date.txt
Normal file
14
Tests/LibWeb/Text/expected/input-date.txt
Normal file
|
@ -0,0 +1,14 @@
|
|||
1. "2023-12-11T00:00:00.000Z"
|
||||
2. null
|
||||
3. "1970-01-01T19:46:00.000Z"
|
||||
4. "1970-01-01T19:46:19.000Z"
|
||||
5. null
|
||||
6. "1970-01-01"
|
||||
7. "2023-12-11"
|
||||
8. Exception: TypeError
|
||||
9. ""
|
||||
10. "18:47:37"
|
||||
11. "18:47:37.100"
|
||||
12. "18:47:37.864"
|
||||
13. Exception: TypeError
|
||||
14. ""
|
126
Tests/LibWeb/Text/input/input-date.html
Normal file
126
Tests/LibWeb/Text/input/input-date.html
Normal file
|
@ -0,0 +1,126 @@
|
|||
<script src="./include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let testCounter = 1;
|
||||
function testPart(part) {
|
||||
try {
|
||||
println(`${testCounter}. ${JSON.stringify(part())}`);
|
||||
} catch (e) {
|
||||
println(`${testCounter}. Exception: ${e.name}`);
|
||||
}
|
||||
testCounter++;
|
||||
}
|
||||
|
||||
// 1. Input date get value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.value = '2023-12-11';
|
||||
return input.valueAsDate;
|
||||
});
|
||||
|
||||
// 2. Input date invalid get value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.value = 'invalid';
|
||||
return input.valueAsDate;
|
||||
});
|
||||
|
||||
// 3. Input time get value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.value = '19:46';
|
||||
return input.valueAsDate;
|
||||
});
|
||||
|
||||
// 4. Input time get value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.value = '19:46:19';
|
||||
return input.valueAsDate;
|
||||
});
|
||||
|
||||
// 5. Input time invalid get value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.value = 'invalid';
|
||||
return input.valueAsDate;
|
||||
});
|
||||
|
||||
// 6. Input date set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.valueAsDate = new Date(0);
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 7. Input date set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.valueAsDate = new Date(1702320457860);
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 8. Input date invalid set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.valueAsDate = {};
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 9. Input date null set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'date';
|
||||
input.valueAsDate = null;
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 10. Input time set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.valueAsDate = new Date(1702320457000);
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 11. Input time set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.valueAsDate = new Date(1702320457100);
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 12. Input time set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.valueAsDate = new Date(1702320457864.5);
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 13. Input time invalid set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.valueAsDate = {};
|
||||
return input.value;
|
||||
});
|
||||
|
||||
// 14. Input time null set value as date
|
||||
testPart(() => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'time';
|
||||
input.valueAsDate = null;
|
||||
return input.value;
|
||||
});
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue