Skip to content

Commit

Permalink
Merge pull request #9311 from w3c/sync_ed63c8c97b001265daf5e2fa8af9cd…
Browse files Browse the repository at this point in the history
…fe69c7b771

Merge pull request #9311 from sync_ed63c8c97b001265daf5e2fa8af9cdfe69c7b771
  • Loading branch information
servo-wpt-sync committed Jan 31, 2018
2 parents 60202b0 + ed63c8c commit 99bc980
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions html/semantics/forms/the-input-element/type-change-state.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
{ type: "reset" },
{ type: "button" }
];

const selectionStart = 2;
const selectionEnd = 5;
const selectionDirection = "backward";

for (var i = 0; i < types.length; i++) {
for (var j = 0; j < types.length; j++) {
if (types[i] != types[j]) {
Expand All @@ -49,6 +54,13 @@
assert_equals(input.value, "");
} else {
input.value = expected;

const previouslySelectable = (input.selectionStart !== null);

if (previouslySelectable) {
input.setSelectionRange(selectionStart, selectionEnd, selectionDirection);
}

input.type = types[j].type; // change state

// type[i] sanitization
Expand All @@ -69,6 +81,20 @@
}

assert_equals(input.value, expected, "input.value should be '" + expected + "' after change of state");

const nowSelectable = (input.selectionStart !== null);

if (nowSelectable) {
if (previouslySelectable) {
assert_equals(input.selectionStart, selectionStart, "selectionStart should be unchanged");
assert_equals(input.selectionEnd, selectionEnd, "selectionEnd should be unchanged");
assert_equals(input.selectionDirection, selectionDirection, "selectionDirection should be unchanged");
} else {
assert_equals(input.selectionStart, 0, "selectionStart should be 0");
assert_equals(input.selectionEnd, 0, "selectionEnd should be 0");
assert_equals(input.selectionDirection, "none", "selectionDirection should be 'none'");
}
}
}
}, "change state from " + types[i].type + " to " + types[j].type);
}
Expand Down

0 comments on commit 99bc980

Please sign in to comment.