Correct default Selectionstart and SelectionEnd

This commit is contained in:
paavininanda 2018-02-06 22:33:12 +05:30
parent e19bab84cf
commit b2c1f89b93
8 changed files with 144 additions and 87 deletions

View file

@ -0,0 +1,35 @@
<!doctype html>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<textarea>g</textarea>
<input type="text" value="foo">
</input>
<script>
test(function() {
let textarea = document.querySelector('textarea');
assert_equals(textarea.selectionStart, 0);
assert_equals(textarea.selectionEnd, 0);
}, "Default selectionStart and selectionEnd for textarea");
test(function() {
let textarea = document.querySelector('input');
assert_equals(textarea.selectionStart, 0);
assert_equals(textarea.selectionEnd, 0);
}, "Default selectionStart and selectionEnd for input");
test(function() {
let textarea = document.querySelector('textarea');
textarea.value="g";
assert_equals(textarea.selectionStart, 0);
assert_equals(textarea.selectionEnd, 0);
}, "selectionStart and selectionEnd do not change when same value set again");
test(function() {
let textarea = document.querySelector('textarea');
textarea.value="G";
assert_equals(textarea.selectionStart, 1);
assert_equals(textarea.selectionEnd, 1);
}, "selectionStart and selectionEnd change when value changed to upper case");
</script>