mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00

And fire the "input" event upon change. This is needed to submit a comment on GitHub; otherwise, GitHub thinks the textarea value is empty.
53 lines
1.6 KiB
HTML
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>
|