Index: LayoutTests/fast/forms/textarea-selection-preservation.html |
diff --git a/LayoutTests/fast/forms/textarea-selection-preservation.html b/LayoutTests/fast/forms/textarea-selection-preservation.html |
index d526b50b760ef755d551414904d6b7168f5e49f0..e477fcf15fd8739ee8418e2c6a69d74a735a82d0 100644 |
--- a/LayoutTests/fast/forms/textarea-selection-preservation.html |
+++ b/LayoutTests/fast/forms/textarea-selection-preservation.html |
@@ -5,10 +5,14 @@ |
<body> |
<p>This tests for problems where we'd lose the selection in a textarea when making style and value changes.</p> |
<div id="console"></div> |
-<p><textarea id="ta">abc123 |
-</textarea></p> |
+<form id="form"><textarea id="ta">abc123 |
+</textarea></form> |
<script type="text/javascript"> |
var ta = document.getElementById('ta'); |
+ debug("- default value"); |
+ shouldBe('ta.selectionStart', '0'); |
+ shouldBe('ta.selectionEnd', '0'); |
+ debug("- set selectionStart/End"); |
ta.selectionStart = 3; |
ta.selectionEnd = 4; |
shouldBe('ta.selectionStart', '3'); |
@@ -39,6 +43,33 @@ |
ta.value = "abc123"; |
shouldBe('ta.selectionStart', '3'); |
shouldBe('ta.selectionEnd', '4'); |
+ |
+ debug("- reset form"); |
+ form.reset(); |
+ shouldBe('ta.selectionStart', '7'); |
+ shouldBe('ta.selectionEnd', '7'); |
+ |
+ debug("- set new defaultValue"); |
+ ta.defaultValue = 'abc123456'; |
+ shouldBe('ta.selectionStart', '9'); |
+ shouldBe('ta.selectionEnd', '9'); |
+ |
+ debug("- set same defaultValue"); |
+ ta.setSelectionRange(2, 3); |
+ ta.defaultValue = 'abc123456'; |
+ shouldBe('ta.selectionStart', '9'); |
+ shouldBe('ta.selectionEnd', '9'); |
+ |
+ debug("- append a text node"); |
+ ta.appendChild(document.createTextNode('foo')); |
+ shouldBe('ta.selectionStart', '12'); |
+ shouldBe('ta.selectionEnd', '12'); |
+ |
+ debug("- append a empty text node"); |
+ ta.setSelectionRange(2, 3); |
+ ta.appendChild(document.createTextNode('')); |
+ shouldBe('ta.selectionStart', '12'); |
+ shouldBe('ta.selectionEnd', '12'); |
</script> |
</body> |
</html> |