1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-11 18:20:43 +09:00
ladybird/Tests/LibWeb/Text/input/textarea-value.html
Timothy Flynn 2b6c00e8b9 LibWeb: Use the <textarea>'s API value, not its raw value, where needed
The API value of a <textarea> element is its raw value with normalized
newlines. This should be used in a couple of places where we currently
use the raw value.
2024-03-16 13:11:57 +01:00

60 lines
1.9 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;
});
// 6. Textarea set value with carriage return
testPart(() => {
const textarea = document.createElement('textarea');
textarea.value = '\ntext\rwith\r\ncarriage\n\rreturn\r\r';
return textarea.value.replaceAll('\n', '[0x0a]');
});
});
</script>