mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Adding tests with DRY coding technique
This commit is contained in:
parent
b1d3d6f632
commit
06f0ad1be7
2 changed files with 19 additions and 26 deletions
|
@ -558282,7 +558282,7 @@
|
|||
"support"
|
||||
],
|
||||
"html/semantics/forms/textfieldselection/defaultSelection.html": [
|
||||
"c9568da864127d49974b970809312c953fb347b1",
|
||||
"f49a2316f73094a7a0b27d810453f40ef029636b",
|
||||
"testharness"
|
||||
],
|
||||
"html/semantics/forms/textfieldselection/original-id.json": [
|
||||
|
|
|
@ -3,33 +3,26 @@
|
|||
<title></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<textarea>g</textarea>
|
||||
<input type="text" value="foo">
|
||||
</input>
|
||||
<textarea>foo</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");
|
||||
for (let el of [document.querySelector("textarea"), document.querySelector("input")]) {
|
||||
test(function() {
|
||||
assert_equals(el.selectionStart, 0);
|
||||
assert_equals(el.selectionEnd, 0);
|
||||
}, `Default selectionStart and selectionEnd for ${el}`);
|
||||
|
||||
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() {
|
||||
el.value="foo";
|
||||
assert_equals(el.selectionStart, 0);
|
||||
assert_equals(el.selectionEnd, 0);
|
||||
}, `selectionStart and selectionEnd do not change when same value set again for ${el}`);
|
||||
|
||||
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");
|
||||
test(function() {
|
||||
el.value="Foo";
|
||||
assert_equals(el.selectionStart, 3);
|
||||
assert_equals(el.selectionEnd, 3);
|
||||
}, `selectionStart and selectionEnd change when value changed to upper case for ${el}`);
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue