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

@ -328172,6 +328172,12 @@
{}
]
],
"html/semantics/forms/textfieldselection/defaultSelection.html": [
[
"/html/semantics/forms/textfieldselection/defaultSelection.html",
{}
]
],
"html/semantics/forms/textfieldselection/select-event.html": [
[
"/html/semantics/forms/textfieldselection/select-event.html",
@ -558275,6 +558281,10 @@
"da39a3ee5e6b4b0d3255bfef95601890afd80709",
"support"
],
"html/semantics/forms/textfieldselection/defaultSelection.html": [
"c9568da864127d49974b970809312c953fb347b1",
"testharness"
],
"html/semantics/forms/textfieldselection/original-id.json": [
"14a6f0077d512837c24931a2a9723e11d1d7a1c7",
"support"

View file

@ -1,4 +0,0 @@
[setSelectionRange.html]
[setSelectionRange on line boundaries]
expected: FAIL

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>