Navigation Menu

Skip to content

Commit

Permalink
Refactor selection-start-end test
Browse files Browse the repository at this point in the history
Move assertions about the initial value of selection{Start,End} to their
own tests. This ensures that when one of these assertions fails, it
doesn't prevent other tests from being defined. Thus we have a clearer
view of which tests are passing or failing, since all tests get defined
regardless of which assertions fail.
  • Loading branch information
jonleighton committed Nov 18, 2017
1 parent e61a4d0 commit f290cac
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 16 deletions.
2 changes: 1 addition & 1 deletion tests/wpt/metadata/MANIFEST.json
Expand Up @@ -542575,7 +542575,7 @@
"testharness"
],
"html/semantics/forms/textfieldselection/selection-start-end.html": [
"e38a79075e27780327f49e7ae9cadd2558165eac",
"3fd1c942f7ac3ed3097bbd1ec89db15fb0805476",
"testharness"
],
"html/semantics/forms/textfieldselection/selection-value-interactions.html": [
Expand Down
@@ -1,17 +1,60 @@
[selection-start-end.html]
type: testharness
[onselect should fire when selectionStart is changed]
expected: TIMEOUT
[Setting selectionStart to a value larger than selectionEnd should increase selectionEnd]
expected: FAIL

[onselect should fire when selectionEnd is changed]
[Setting selectionEnd to a value smaller than selectionStart should decrease selectionStart]
expected: FAIL

[Setting selectionStart to a value larger than selectionEnd should increase selectionEnd]
[selectionStart edge-case values]
expected: FAIL

[Setting selectionEnd to a value smaller than selectionStart should decrease selectionStart]
[Initial .value set on textarea-appended should set selectionStart to end of value]
expected: FAIL

[selectionStart edge-case values]
[Initial .value set on textarea-not-appended should set selectionStart to end of value]
expected: FAIL

[Initial .value set on textarea-appended-prefocused should set selectionStart to end of value]
expected: FAIL

[Initial .value set on textarea-not-appended-prefocused should set selectionStart to end of value]
expected: FAIL

[onselect should fire when selectionStart is changed on textarea-appended]
expected: NOTRUN

[onselect should fire when selectionStart is changed on textarea-not-appended]
expected: NOTRUN

[onselect should fire when selectionStart is changed on textarea-appended-prefocused]
expected: NOTRUN

[onselect should fire when selectionStart is changed on textarea-not-appended-prefocused]
expected: NOTRUN

[onselect should fire when selectionEnd is changed on textarea-appended]
expected: NOTRUN

[onselect should fire when selectionEnd is changed on textarea-not-appended]
expected: NOTRUN

[onselect should fire when selectionEnd is changed on textarea-appended-prefocused]
expected: NOTRUN

[onselect should fire when selectionEnd is changed on textarea-not-appended-prefocused]
expected: NOTRUN

[Initial .value set on textarea-appended should set selectionEnd to end of value]
expected: FAIL

[Initial .value set on textarea-not-appended should set selectionEnd to end of value]
expected: FAIL

[Initial .value set on textarea-appended-prefocused should set selectionEnd to end of value]
expected: FAIL

[Initial .value set on textarea-not-appended-prefocused should set selectionEnd to end of value]
expected: FAIL

Expand Up @@ -59,10 +59,16 @@
assert_equals(testValue.length, 10);
}, "Sanity check for testValue length; if this fails, variou absolute offsets in the test below need to be adjusted to be less than testValue.length");

for (let prop of ["selectionStart", "selectionEnd"]) {
for (let el of createTestElements(testValue)) {
test(function() {
assert_equals(el.selectionStart, testValue.length);
}, `Initial .value set on ${el.id} should set ${prop} to end of value`);
}
}

test(function() {
for (let el of createTestElements(testValue)) {
assert_equals(el.selectionStart, testValue.length,
`Initial .value set on ${el.id} should set selectionStart to end of value`);
var t = async_test(`onselect should fire when selectionStart is changed on ${el.id}`);
el.onselect = t.step_func_done(function(e) {
assert_equals(e.type, "select");
Expand All @@ -74,8 +80,6 @@

test(function() {
for (let el of createTestElements(testValue)) {
assert_equals(el.selectionEnd, testValue.length,
`Initial .value set on ${el.id} should set selectionEnd to end of value`);
var t = async_test(`onselect should fire when selectionEnd is changed on ${el.id}`);
el.onselect = t.step_func_done(function(e) {
assert_equals(e.type, "select");
Expand All @@ -87,8 +91,6 @@

test(function() {
for (let el of createTestElements(testValue)) {
assert_equals(el.selectionStart, testValue.length,
`Initial .value set on ${el.id} should set selectionStart to end of value`);
el.selectionStart = 0;
el.selectionEnd = 5;
el.selectionStart = 8;
Expand All @@ -100,10 +102,6 @@

test(function() {
for (let el of createTestElements(testValue)) {
assert_equals(el.selectionStart, testValue.length,
`Initial .value set on ${el.id} should set selectionStart to end of value`);
assert_equals(el.selectionEnd, testValue.length,
`Initial .value set on ${el.id} should set selectionEnd to end of value`);
el.selectionStart = 8;
el.selectionEnd = 5;
assert_equals(el.selectionStart, 5, `selectionStart on ${el.id}`);
Expand Down

0 comments on commit f290cac

Please sign in to comment.