summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/textarea/textarea-textlength.html
blob: 0532dba50fa3c4cc7b995b83822aacec33ef10f7 (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
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description('Test for HTMLTextAreaElement.textLength');

var textArea = document.createElement('textarea');
document.body.appendChild(textArea);
shouldBe('textArea.textLength', '0');

textArea.value = 'abcd';
shouldBe('textArea.textLength', '4');

textArea.focus();
eventSender.keyDown('e', []);
shouldBe('textArea.textLength', '5');

// Test for a character larger than U+FFFF.
textArea = document.createElement('textarea');
textArea.innerHTML = '&#x1d538;';
// Firefox 3.5 and Opera 10 return 2 for 1 surrogate pair.
shouldBe('textArea.textLength', '2');

// Test for combined characters.
textArea = document.createElement('textarea');
// U+3055 Hiragana Letter Sa
// U+3099 Combining Katakana-HIragana Voiced Sound Mark
textArea.innerHTML = '&#x3055;&#x3099;';
// Firefox 3.5 seems to apply NFC for the value, and .textLength and .value.length is 1.
// Opera 10 returns 2, and IE's .value.length is 2.
shouldBe('textArea.textLength', '2');

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