mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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"
|
"support"
|
||||||
],
|
],
|
||||||
"html/semantics/forms/textfieldselection/defaultSelection.html": [
|
"html/semantics/forms/textfieldselection/defaultSelection.html": [
|
||||||
"c9568da864127d49974b970809312c953fb347b1",
|
"f49a2316f73094a7a0b27d810453f40ef029636b",
|
||||||
"testharness"
|
"testharness"
|
||||||
],
|
],
|
||||||
"html/semantics/forms/textfieldselection/original-id.json": [
|
"html/semantics/forms/textfieldselection/original-id.json": [
|
||||||
|
|
|
@ -3,33 +3,26 @@
|
||||||
<title></title>
|
<title></title>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<textarea>g</textarea>
|
<textarea>foo</textarea>
|
||||||
<input type="text" value="foo">
|
<input type="text" value="foo"></input>
|
||||||
</input>
|
|
||||||
<script>
|
<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() {
|
for (let el of [document.querySelector("textarea"), document.querySelector("input")]) {
|
||||||
let textarea = document.querySelector('input');
|
test(function() {
|
||||||
assert_equals(textarea.selectionStart, 0);
|
assert_equals(el.selectionStart, 0);
|
||||||
assert_equals(textarea.selectionEnd, 0);
|
assert_equals(el.selectionEnd, 0);
|
||||||
}, "Default selectionStart and selectionEnd for input");
|
}, `Default selectionStart and selectionEnd for ${el}`);
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
let textarea = document.querySelector('textarea');
|
el.value="foo";
|
||||||
textarea.value="g";
|
assert_equals(el.selectionStart, 0);
|
||||||
assert_equals(textarea.selectionStart, 0);
|
assert_equals(el.selectionEnd, 0);
|
||||||
assert_equals(textarea.selectionEnd, 0);
|
}, `selectionStart and selectionEnd do not change when same value set again for ${el}`);
|
||||||
}, "selectionStart and selectionEnd do not change when same value set again");
|
|
||||||
|
|
||||||
test(function() {
|
test(function() {
|
||||||
let textarea = document.querySelector('textarea');
|
el.value="Foo";
|
||||||
textarea.value="G";
|
assert_equals(el.selectionStart, 3);
|
||||||
assert_equals(textarea.selectionStart, 1);
|
assert_equals(el.selectionEnd, 3);
|
||||||
assert_equals(textarea.selectionEnd, 1);
|
}, `selectionStart and selectionEnd change when value changed to upper case for ${el}`);
|
||||||
}, "selectionStart and selectionEnd change when value changed to upper case");
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue