OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/testharness.js"></script> | 2 <script src="../../../resources/testharness.js"></script> |
3 <script src="../../../resources/testharnessreport.js"></script> | 3 <script src="../../../resources/testharnessreport.js"></script> |
4 <div id="log"></div> | 4 <div id="log"></div> |
5 <textarea id="ta"></textarea> | 5 <textarea id="ta"></textarea> |
6 <script> | 6 <script> |
7 test(function() { | 7 test(function() { |
8 var ta = document.getElementById("ta"); | 8 var ta = document.getElementById("ta"); |
9 ta.value = "abc\n"; | 9 ta.value = "abc\n"; |
10 ta.focus(); | 10 ta.focus(); |
11 ta.setSelectionRange(0, 4); | 11 ta.setSelectionRange(0, 4); |
12 document.execCommand("cut"); | 12 document.execCommand("cut"); |
13 document.execCommand("paste"); | 13 document.execCommand("paste"); |
14 assert_equals(ta.value, "abc\n"); | 14 assert_equals(ta.value, "abc\n"); |
15 | 15 |
16 ta.setSelectionRange(0, 0); | 16 ta.setSelectionRange(0, 0); |
17 document.execCommand("paste"); | 17 document.execCommand("paste"); |
18 assert_equals(ta.value, "abc\nabc\n"); | 18 assert_equals(ta.value, "abc\nabc\n"); |
19 }, "Pasting text ending with newline should work correctly."); | 19 }, "Pasting text ending with newline should work correctly."); |
| 20 |
| 21 test(function() { |
| 22 var source = document.createElement("textarea"); |
| 23 document.body.appendChild(source); |
| 24 source.value = "\n"; |
| 25 source.focus(); |
| 26 source.select(); |
| 27 document.execCommand("copy"); |
| 28 |
| 29 var dest = document.createElement("textarea"); |
| 30 document.body.appendChild(dest); |
| 31 dest.focus(); |
| 32 document.execCommand("paste"); |
| 33 assert_equals(dest.value, "\n"); |
| 34 assert_equals(dest.selectionStart, 1); |
| 35 assert_equals(dest.selectionEnd, 1); |
| 36 }, "Pasting \\n into an empty TEXTAREA should set the caret at the end."); |
20 </script> | 37 </script> |
OLD | NEW |