blob: f45d4fe713fe2db0679f18438402a23c3de175c5 [file] [log] [blame]
<html>
<body>
This tests that textarea wrap attributes work correctly when submitting a form.
<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>
<div id="res"></div>
<script>
function log(msg) {
document.getElementById('res').innerHTML = document.getElementById('res').innerHTML + msg + "<br>";
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var unescapedLineWrap = unescape("%0D%0A");
function assertLineWrap(properties, escapedResult, shouldHaveLineBreakInResult) {
var unescapedResult = unescape(escapedResult);
var passed = shouldHaveLineBreakInResult ?
unescapedResult.indexOf(unescapedLineWrap) != -1 :
unescapedResult.indexOf(unescapedLineWrap) == -1
if (passed)
log("<p>" + properties + ": Success</p>");
else
log("<p>" + properties + ": Failure. Expected " + (shouldHaveLineBreakInResult ? "" : "no ") +
"%0D%A in the result at the line-wrap. <br>Actual form data: " + unescapedResult + "</p>");
}
if (document.URL.substring(0, 4) == "file") {
if (document.URL.indexOf('?') == -1) {
document.f.submit();
} else {
var urlString = document.URL.substring(document.URL.indexOf('?')+1, document.URL.length);
var index1 = 0;
var index2 = urlString.indexOf('ta_WrapSoft');
var index3 = urlString.indexOf('ta_WrapOff');
var index4 = urlString.indexOf('ta_WrapHardRTL');
var index5 = urlString.indexOf('ta_WrapHardBidi');
var index6 = urlString.indexOf('ta_WrapHardHidden');
var index7 = document.URL.length;
var expectedResult;
var result;
assertLineWrap("wrap=hard", urlString.substring(index1, index2 - 1), true);
assertLineWrap("wrap=soft", urlString.substring(index2, index3 - 1), false);
assertLineWrap("wrap=off", urlString.substring(index3, index4 - 1), false);
assertLineWrap("wrap=hard rtl text", urlString.substring(index4, index5 - 1), true);
assertLineWrap("wrap=hard mixed rtl and ltr text", urlString.substring(index5, index6 - 1), true);
assertLineWrap("wrap=hard visibility:hidden", urlString.substring(index6, index7 - 1), true);
if (window.testRunner)
testRunner.notifyDone();
}
} else {
document.write("<p>This test doesn't work directly from bugzilla, please save it to a local file first.</p>");
}
</script>
</body>
</html>