mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +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
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