1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00
serenity/Tests/LibWeb/Text/input/textarea-value.html
Timothy Flynn ed13793110 LibWeb: Update the stored textarea value upon change
And fire the "input" event upon change. This is needed to submit a
comment on GitHub; otherwise, GitHub thinks the textarea value is empty.
2024-03-07 00:38:33 +01:00

53 lines
1.6 KiB
HTML

<script src="include.js"></script>
<script>
test(() => {
let testCounter = 1;
function testPart(part) {
println(`${testCounter++}. ${JSON.stringify(part())}`);
}
// 1. Textarea get value
testPart(() => {
const textarea = document.createElement('textarea');
textarea.textContent = 'PASS';
return textarea.value;
});
// 2. Textarea set value
testPart(() => {
const textarea = document.createElement('textarea');
textarea.textContent = 'PASS';
textarea.value = 'FAIL';
return textarea.textContent;
});
// 3. Textarea set default value
testPart(() => {
const textarea = document.createElement('textarea');
textarea.textContent = 'FAIL';
textarea.defaultValue = 'PASS';
return textarea.textContent;
});
// 4. Textarea text length
testPart(() => {
const textarea = document.createElement('textarea');
textarea.innerHTML = 'PASS';
return textarea.textLength;
});
// 5. Textarea input via keyboard events.
testPart(() => {
const textarea = document.createElement('textarea');
// The element currently has to be part of a document to be able to receive keyboard events.
document.body.appendChild(textarea);
internals.sendText(textarea, 'PASS');
const value = textarea.value;
document.body.removeChild(textarea);
return value;
});
});
</script>