Commit d55b46e0 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Convert textarea-appearance-wrap.html for testharness.js

This CL has no behavior changes.

Change-Id: I6d9ed9d0efd67e16d922034afb4e19717e60a98e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2454590
Auto-Submit: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814510}
parent 90896397
This tests that textarea wrap attributes work correctly when submitting a form.
wrap=hard: Success
wrap=soft: Success
wrap=off: Success
wrap=hard rtl text: Success
wrap=hard mixed rtl and ltr text: Success
wrap=hard visibility:hidden: Success
<!DOCTYPE html>
<!-- TODO(tkent): Rename this file. This doesn't test appearance. -->
<html> <html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<body> <body>
This tests that textarea wrap attributes work correctly when submitting a form.
<form action="?" name=f> <form action="?" name=f>
<textarea name=ta_WrapHard cols=5 style="-webkit-appearance:textarea" wrap=hard>123456789</textarea><br> <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_WrapSoft cols=5 style="-webkit-appearance:textarea" wrap=soft>123456789</textarea><br>
...@@ -10,62 +13,31 @@ This tests that textarea wrap attributes work correctly when submitting a form. ...@@ -10,62 +13,31 @@ This tests that textarea wrap attributes work correctly when submitting a form.
<textarea name=ta_WrapHardHidden cols=5 style="-webkit-appearance:textarea; visibility:hidden" wrap=hard>123456789</textarea><br> <textarea name=ta_WrapHardHidden cols=5 style="-webkit-appearance:textarea; visibility:hidden" wrap=hard>123456789</textarea><br>
</form> </form>
<div id="res"></div>
<script> <script>
function log(msg) { function assertLineWrap(description, formData, name, shouldHaveLineBreakInResult) {
document.getElementById('res').innerHTML = document.getElementById('res').innerHTML + msg + "<br>"; const LINE_WRAP = "\r\n";
} const wireValue = formData.get(name);
if (shouldHaveLineBreakInResult) {
if (window.testRunner) { assert_not_equals(wireValue.indexOf(LINE_WRAP), -1,
testRunner.dumpAsText(); `"${wireValue}" should contain \\r\\n`);
testRunner.waitUntilDone(); } else {
} assert_equals(wireValue.indexOf(LINE_WRAP), -1,
`"${wireValue}" should not contain \\r\\n`);
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") { test(() => {
const formData = new FormData(document.f);
if (document.URL.indexOf('?') == -1) {
document.f.submit(); assertLineWrap("wrap=hard", formData, 'ta_WrapHard', true);
} else { assertLineWrap("wrap=soft", formData, 'ta_WrapSoft', false);
var urlString = document.URL.substring(document.URL.indexOf('?')+1, document.URL.length); assertLineWrap("wrap=off", formData, 'ta_WrapOff', false);
var index1 = 0; assertLineWrap("wrap=hard rtl text", formData, 'ta_WrapHardRTL', true);
var index2 = urlString.indexOf('ta_WrapSoft'); assertLineWrap("wrap=hard mixed rtl and ltr text", formData,
var index3 = urlString.indexOf('ta_WrapOff'); 'ta_WrapHardBidi', true);
var index4 = urlString.indexOf('ta_WrapHardRTL'); assertLineWrap("wrap=hard visibility:hidden", formData, 'ta_WrapHardHidden',
var index5 = urlString.indexOf('ta_WrapHardBidi'); true);
var index6 = urlString.indexOf('ta_WrapHardHidden'); }, 'This tests that textarea wrap attributes work correctly when submitting a form.');
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> </script>
</body> </body>
</html> </html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment