Bug 1385926 - Add a test to ensure that the selection is always collapsed to the end after setting the value of input and textarea elements using the DOM API; r=masayuki

This commit is contained in:
Ehsan Akhgari 2017-07-31 17:55:30 -04:00
Родитель 27fb550d1e
Коммит 8a7e6af123
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -92,4 +92,27 @@ for (var data of elemData) {
}, `value dirty flag behavior after setRangeText on ${data.desc}`);
}
for (var tag of ['input', 'textarea']) {
test(function() {
var el = document.createElement(tag);
document.body.appendChild(el);
this.add_cleanup(() => el.remove());
el.value = "";
assert_equals(el.selectionStart, el.value.length,
"element.selectionStart should be value.length");
assert_equals(el.selectionEnd, el.value.length,
"element.selectionEnd should be value.length");
el.value = "foo";
assert_equals(el.selectionStart, el.value.length,
"element.selectionStart should be value.length");
assert_equals(el.selectionEnd, el.value.length,
"element.selectionEnd should be value.length");
el.value = "foobar";
assert_equals(el.selectionStart, el.value.length,
"element.selectionStart should be value.length");
assert_equals(el.selectionEnd, el.value.length,
"element.selectionEnd should be value.length");
}, `selection is always collapsed to the end after setting values on ${tag}`);
}
</script>