OLD | NEW |
| 1 <!DOCTYPE html> |
| 2 <script src="../../../resources/testharness.js"></script> |
| 3 <script src="../../../resources/testharnessreport.js"></script> |
| 4 <div id="log"></div> |
| 5 <textarea id="ta"></textarea> |
1 <script> | 6 <script> |
2 function test() | 7 test(function() { |
3 { | |
4 if (window.testRunner) | |
5 testRunner.dumpAsText(); | |
6 var ta = document.getElementById("ta"); | 8 var ta = document.getElementById("ta"); |
7 ta.value = "abc\n"; | 9 ta.value = "abc\n"; |
8 ta.focus(); | 10 ta.focus(); |
9 ta.setSelectionRange(0, 4); | 11 ta.setSelectionRange(0, 4); |
10 document.execCommand("cut"); | 12 document.execCommand("cut"); |
11 document.execCommand("paste"); | 13 document.execCommand("paste"); |
12 var result1 = ta.value; | 14 assert_equals(ta.value, "abc\n"); |
| 15 |
13 ta.setSelectionRange(0, 0); | 16 ta.setSelectionRange(0, 0); |
14 document.execCommand("paste"); | 17 document.execCommand("paste"); |
15 var result2 = ta.value; | 18 assert_equals(ta.value, "abc\nabc\n"); |
16 | 19 }, "Pasting text ending with newline should work correctly."); |
17 if (result1 == "abc\n" && result2 == "abc\nabc\n") | |
18 document.write("<p>Hooray, the test was successful!</p>"); | |
19 else if (result1 == "") | |
20 document.write("<p>The test failed; doesn't work in release builds of Sa
fari because paste is not allowed.</p>"); | |
21 else | |
22 document.write("<p>The test failed, result 1 was '" + result1.replace("\
n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'.</p>"); | |
23 } | |
24 </script> | 20 </script> |
25 <body onload="test()"> | |
26 <p><textarea id="ta"></textarea></p> | |
OLD | NEW |