summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/input-implicit-length-limit.html
blob: 056bb4feb80574a688c73d0009a79ef9bc3ba162 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<p>This page tests that the length of an <tt>&lt;input&gt;</tt> element's string is implicitly limited to 524288 characters. <a href="http://bugs.webkit.org/show_bug.cgi?id=14388">http://bugs.webkit.org/show_bug.cgi?id=14388</a></p>
<input id="input">
<pre id="log"></pre>
<script>
    function log(msg)
    {
        document.getElementById("log").appendChild(document.createTextNode(msg + "\n"));
    }

    if (window.testRunner)
        testRunner.dumpAsText();

    var testString = "";

    function attempt(length, expected)
    {
        log("Attempting to insert " + length + " characters.");

        if (testString.length > length)
            testString = "";

        for (var i = testString.length; i < length; ++i)
            testString += i % 10;

        var input = document.getElementById("input");
        input.value = testString;

        if (input.value.length == expected)
            log("PASS");
        else
            log("FAIL: Expected " + expected + " characters to be inserted, but " + input.value.length + " characters were actually inserted.");
    }

    attempt(0, 0);
    attempt(5, 5);
    attempt(1025, 1025);
    attempt(524287, 524287);
    attempt(524288, 524288);
    attempt(524289, 524288);
    attempt(530000, 524288);
</script>