summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/text/pre-wrap-trailing-tab.html
blob: 5f5e1a75e873977393c1bfe41f49f244cb26008f (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
42
<!DOCTYPE html>
<html>
<body><div id="tests"><div style="width: 1ex; font-size: 1em; white-space: pre-wrap;"
></div><div style="width: 1ex; font-size: 1em; white-space: pre-wrap; word-wrap: break-word;"
></div><textarea style="width: 1ex; font-size: 1em;"
></textarea></div><pre id="log"></pre><script>

function assertEqual(name, length, endOffset)
{
    log.textContent += '\n' + name + ': ';
    if (length != endOffset)
        log.textContent += 'FAIL - length was ' + length + ' but selection end was ' + endOffset + ' after selecting all text';
    else
        log.textContent += 'PASS';
}

var tests = document.getElementById('tests').childNodes;
var log = document.getElementById('log');
log.textContent = 'This test ensures WebKit renders the trailing whitespace properly. You should see PASS thrice below.\n';

var letter = 'a';
for (var i = 0; i < tests.length; i++, letter = String.fromCharCode(letter.charCodeAt(0) + 1)) {
    if (tests[i].select) {
        tests[i].value = letter + '\t';
        tests[i].focus();
        tests[i].select();
        var endOffset = tests[i].selectionEnd;
    } else {
        tests[i].textContent = letter + '\t';
        window.getSelection().selectAllChildren(tests[i]);
        var endOffset = window.getSelection().getRangeAt(0).endOffset;
    }
    assertEqual('test ' + i, 2, endOffset);
}

if (window.testRunner) {
    testRunner.dumpAsText();
    document.getElementById('tests').style.display = 'none';
}

</script></pre></body>
</html>