summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/textarea-paste-newline.html
blob: cc8204e360f184734128e81a6ae40767b271c3cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<script>
function test()
{
    if (window.layoutTestController)
        layoutTestController.dumpAsText();
    var ta = document.getElementById("ta");
    ta.value = "abc\n";
    ta.focus();
    ta.setSelectionRange(0, 4);
    document.execCommand("cut");
    document.execCommand("paste");
    var result1 = ta.value;
    ta.setSelectionRange(0, 0);
    document.execCommand("paste");
    var result2 = ta.value;

    if (result1 == "abc\n" && result2 == "abc\nabc\n")
        document.write("<p>Hooray, the test was successful!</p>");
    else if (result1 == "")
        document.write("<p>The test failed; doesn't work in release builds of Safari because paste is not allowed.</p>");
    else
        document.write("<p>The test failed, result 1 was '" + result1.replace("\n", "\\n") + "' and result 2 was '" + result2.replace("\n", "\\n") + "'.</p>");
}
</script>
<body onload="test()">
<p><textarea id="ta"></textarea></p>