blob: 408415f057a141f6ffce43e00f2461656d1208e1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body>
<form action="?" name=f>
<textarea name=ta_WrapHard cols=5 style="-webkit-appearance:textarea" wrap=hard>123456789</textarea><br>
<textarea name=ta_WrapSoft cols=5 style="-webkit-appearance:textarea" wrap=soft>123456789</textarea><br>
<textarea name=ta_WrapOff cols=5 style="-webkit-appearance:textarea" wrap=off>123456789</textarea><br>
<textarea name=ta_WrapHardRTL cols=5 style="-webkit-appearance:textarea; direction:rtl" wrap=hard>&#1488;&#1489;&#1490;&#1488;&#1489;&#1490;&#1488;&#1489;&#1490;&#1488;&#1489;&#1490;</textarea><br>
<textarea name=ta_WrapHardBidi cols=5 style="-webkit-appearance:textarea; direction:ltr" wrap=hard>abc&#1488;&#1489;&#1490;&#1488;&#1489;&#1490;abc</textarea><br>
<textarea name=ta_WrapHardHidden cols=5 style="-webkit-appearance:textarea; visibility:hidden" wrap=hard>123456789</textarea><br>
</form>
<script>
function assertLineWrap(description, formData, name, shouldHaveLineBreakInResult) {
const LINE_WRAP = "\r\n";
const wireValue = formData.get(name);
if (shouldHaveLineBreakInResult) {
assert_not_equals(wireValue.indexOf(LINE_WRAP), -1,
`"${wireValue}" should contain \\r\\n`);
} else {
assert_equals(wireValue.indexOf(LINE_WRAP), -1,
`"${wireValue}" should not contain \\r\\n`);
}
}
test(() => {
const formData = new FormData(document.f);
assertLineWrap("wrap=hard", formData, 'ta_WrapHard', true);
assertLineWrap("wrap=soft", formData, 'ta_WrapSoft', false);
assertLineWrap("wrap=off", formData, 'ta_WrapOff', false);
assertLineWrap("wrap=hard rtl text", formData, 'ta_WrapHardRTL', true);
assertLineWrap("wrap=hard mixed rtl and ltr text", formData,
'ta_WrapHardBidi', true);
assertLineWrap("wrap=hard visibility:hidden", formData, 'ta_WrapHardHidden',
true);
}, 'This tests that textarea wrap attributes work correctly when submitting a form.');
</script>
</body>
</html>