mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 18:20:43 +09:00

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.
60 lines
1.9 KiB
HTML
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>
|