Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / textarea-appearance-wrap.html
blobf45d4fe713fe2db0679f18438402a23c3de175c5
1 <html>
2 <body>
3 This tests that textarea wrap attributes work correctly when submitting a form.
4 <form action="?" name=f>
5 <textarea name=ta_WrapHard cols=5 style="-webkit-appearance:textarea" wrap=hard>123456789</textarea><br>
6 <textarea name=ta_WrapSoft cols=5 style="-webkit-appearance:textarea" wrap=soft>123456789</textarea><br>
7 <textarea name=ta_WrapOff cols=5 style="-webkit-appearance:textarea" wrap=off>123456789</textarea><br>
8 <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>
9 <textarea name=ta_WrapHardBidi cols=5 style="-webkit-appearance:textarea; direction:ltr" wrap=hard>abc&#1488;&#1489;&#1490;&#1488;&#1489;&#1490;abc</textarea><br>
10 <textarea name=ta_WrapHardHidden cols=5 style="-webkit-appearance:textarea; visibility:hidden" wrap=hard>123456789</textarea><br>
11 </form>
13 <div id="res"></div>
15 <script>
16 function log(msg) {
17 document.getElementById('res').innerHTML = document.getElementById('res').innerHTML + msg + "<br>";
20 if (window.testRunner) {
21 testRunner.dumpAsText();
22 testRunner.waitUntilDone();
25 var unescapedLineWrap = unescape("%0D%0A");
27 function assertLineWrap(properties, escapedResult, shouldHaveLineBreakInResult) {
28 var unescapedResult = unescape(escapedResult);
29 var passed = shouldHaveLineBreakInResult ?
30 unescapedResult.indexOf(unescapedLineWrap) != -1 :
31 unescapedResult.indexOf(unescapedLineWrap) == -1
32 if (passed)
33 log("<p>" + properties + ": Success</p>");
34 else
35 log("<p>" + properties + ": Failure. Expected " + (shouldHaveLineBreakInResult ? "" : "no ") +
36 "%0D%A in the result at the line-wrap. <br>Actual form data: " + unescapedResult + "</p>");
39 if (document.URL.substring(0, 4) == "file") {
41 if (document.URL.indexOf('?') == -1) {
42 document.f.submit();
43 } else {
44 var urlString = document.URL.substring(document.URL.indexOf('?')+1, document.URL.length);
45 var index1 = 0;
46 var index2 = urlString.indexOf('ta_WrapSoft');
47 var index3 = urlString.indexOf('ta_WrapOff');
48 var index4 = urlString.indexOf('ta_WrapHardRTL');
49 var index5 = urlString.indexOf('ta_WrapHardBidi');
50 var index6 = urlString.indexOf('ta_WrapHardHidden');
51 var index7 = document.URL.length;
52 var expectedResult;
53 var result;
55 assertLineWrap("wrap=hard", urlString.substring(index1, index2 - 1), true);
56 assertLineWrap("wrap=soft", urlString.substring(index2, index3 - 1), false);
57 assertLineWrap("wrap=off", urlString.substring(index3, index4 - 1), false);
58 assertLineWrap("wrap=hard rtl text", urlString.substring(index4, index5 - 1), true);
59 assertLineWrap("wrap=hard mixed rtl and ltr text", urlString.substring(index5, index6 - 1), true);
60 assertLineWrap("wrap=hard visibility:hidden", urlString.substring(index6, index7 - 1), true);
62 if (window.testRunner)
63 testRunner.notifyDone();
66 } else {
67 document.write("<p>This test doesn't work directly from bugzilla, please save it to a local file first.</p>");
69 </script>
70 </body>
71 </html>