mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Auto merge of #20050 - paavininanda:NewTests, r=jdm
Adding left over tests using DRY coding <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes add the tests using DRY technique to reduce redundant code for https://github.com/servo/servo/pull/19963 <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20050) <!-- Reviewable:end -->
This commit is contained in:
commit
2b9acb12dd
2 changed files with 19 additions and 26 deletions
|
@ -559039,7 +559039,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