justing | 2803233 | 2006-10-27 20:42:17 +0000 | [diff] [blame] | 1 | <p>This tests to see that a line break inserted in a textarea is serialized as a '\n'.</p> |
| 2 | <textarea rows="5" id="textarea"></textarea> |
| 3 | <ul id="console"></ul> |
| 4 | |
| 5 | <script> |
| 6 | function log(str) { |
| 7 | var li = document.createElement("li"); |
| 8 | li.appendChild(document.createTextNode(str)); |
| 9 | var console = document.getElementById("console"); |
| 10 | console.appendChild(li); |
| 11 | } |
| 12 | |
rniwa@webkit.org | ea3cf92 | 2012-06-22 06:52:33 +0000 | [diff] [blame] | 13 | if (window.testRunner) |
| 14 | window.testRunner.dumpAsText(); |
justing | 2803233 | 2006-10-27 20:42:17 +0000 | [diff] [blame] | 15 | |
| 16 | var textarea = document.getElementById("textarea"); |
| 17 | textarea.focus(); |
| 18 | document.execCommand("InsertText", false, "foo"); |
| 19 | document.execCommand("InsertLineBreak"); |
| 20 | document.execCommand("InsertText", false, "bar"); |
| 21 | |
| 22 | if (textarea.value != "foo\nbar") |
| 23 | log("Failure"); |
| 24 | else |
| 25 | log("Success"); |
| 26 | </script> |