Commit 053d52a2 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

html: Fix an issue of type-change-state.html about selectionDirection="none"

type-change-state.html contains assertions for the following operation in [1]:
> ..., and set its selection direction to "none".

However it had an issue that the assertions checked if
input.selectionDirection was "none". According to [2],
input.selectionDirection can be "forward" on specific platforms.

> update the element's selection direction to the given direction, unless
> the direction is "none" and the platform does not support that direction;
> in that case, update the element's selection direction to "forward".

[1] https://html.spec.whatwg.org/multipage/input.html#the-input-element:set-the-selection-direction
[2] https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#set-the-selection-direction

Change-Id: Idc1a97fbb2036e351a788a1f758b3239308d8c71
Reviewed-on: https://chromium-review.googlesource.com/c/1322264Reviewed-by: default avatarRakina Zata Amni <rakina@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606310}
parent c162a12d
......@@ -36,6 +36,17 @@
const selectionEnd = 5;
const selectionDirection = "backward";
// Obtain selectionDirection after setting it to "none".
// Some platforms don't support "none" direction, and "forward" is returned
// in such platforms.
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#set-the-selection-direction
function testNoneDirection() {
const input = document.createElement("input");
input.selectionDirection = "none";
return input.selectionDirection;
}
const noneDirectionResult = testNoneDirection();
for (var i = 0; i < types.length; i++) {
for (var j = 0; j < types.length; j++) {
if (types[i] != types[j]) {
......@@ -92,7 +103,8 @@
} 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'");
assert_equals(input.selectionDirection, noneDirectionResult,
`selectionDirection should be '{noneDirectionResult}'`);
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment