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 @@ ...@@ -36,6 +36,17 @@
const selectionEnd = 5; const selectionEnd = 5;
const selectionDirection = "backward"; 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 i = 0; i < types.length; i++) {
for (var j = 0; j < types.length; j++) { for (var j = 0; j < types.length; j++) {
if (types[i] != types[j]) { if (types[i] != types[j]) {
...@@ -92,7 +103,8 @@ ...@@ -92,7 +103,8 @@
} else { } else {
assert_equals(input.selectionStart, 0, "selectionStart should be 0"); assert_equals(input.selectionStart, 0, "selectionStart should be 0");
assert_equals(input.selectionEnd, 0, "selectionEnd 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}'`);
} }
} }
} }
......
This is a testharness.js-based test.
Found 462 tests; 361 PASS, 101 FAIL, 0 TIMEOUT, 0 NOTRUN.
FAIL change state from hidden to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from hidden to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from hidden to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from hidden to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from hidden to email
FAIL change state from hidden to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from hidden to datetime-local
PASS change state from hidden to date
PASS change state from hidden to month
PASS change state from hidden to week
PASS change state from hidden to time
PASS change state from hidden to number
PASS change state from hidden to range
PASS change state from hidden to color
PASS change state from hidden to checkbox
PASS change state from hidden to radio
PASS change state from hidden to file
PASS change state from hidden to submit
PASS change state from hidden to image
PASS change state from hidden to reset
PASS change state from hidden to button
PASS change state from text to hidden
PASS change state from text to search
PASS change state from text to tel
FAIL change state from text to url assert_equals: selectionStart should be unchanged expected 2 but got 6
PASS change state from text to email
PASS change state from text to password
PASS change state from text to datetime-local
PASS change state from text to date
PASS change state from text to month
PASS change state from text to week
PASS change state from text to time
PASS change state from text to number
PASS change state from text to range
PASS change state from text to color
PASS change state from text to checkbox
PASS change state from text to radio
PASS change state from text to file
PASS change state from text to submit
PASS change state from text to image
PASS change state from text to reset
PASS change state from text to button
PASS change state from search to hidden
PASS change state from search to text
PASS change state from search to tel
FAIL change state from search to url assert_equals: selectionStart should be unchanged expected 2 but got 6
PASS change state from search to email
PASS change state from search to password
PASS change state from search to datetime-local
PASS change state from search to date
PASS change state from search to month
PASS change state from search to week
PASS change state from search to time
PASS change state from search to number
PASS change state from search to range
PASS change state from search to color
PASS change state from search to checkbox
PASS change state from search to radio
PASS change state from search to file
PASS change state from search to submit
PASS change state from search to image
PASS change state from search to reset
PASS change state from search to button
PASS change state from tel to hidden
PASS change state from tel to text
PASS change state from tel to search
FAIL change state from tel to url assert_equals: selectionStart should be unchanged expected 2 but got 6
PASS change state from tel to email
PASS change state from tel to password
PASS change state from tel to datetime-local
PASS change state from tel to date
PASS change state from tel to month
PASS change state from tel to week
PASS change state from tel to time
PASS change state from tel to number
PASS change state from tel to range
PASS change state from tel to color
PASS change state from tel to checkbox
PASS change state from tel to radio
PASS change state from tel to file
PASS change state from tel to submit
PASS change state from tel to image
PASS change state from tel to reset
PASS change state from tel to button
PASS change state from url to hidden
FAIL change state from url to text assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
FAIL change state from url to search assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
FAIL change state from url to tel assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
PASS change state from url to email
FAIL change state from url to password assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
PASS change state from url to datetime-local
PASS change state from url to date
PASS change state from url to month
PASS change state from url to week
PASS change state from url to time
PASS change state from url to number
PASS change state from url to range
PASS change state from url to color
PASS change state from url to checkbox
PASS change state from url to radio
PASS change state from url to file
PASS change state from url to submit
PASS change state from url to image
PASS change state from url to reset
PASS change state from url to button
PASS change state from email to hidden
FAIL change state from email to text assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
FAIL change state from email to search assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
FAIL change state from email to tel assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
FAIL change state from email to url assert_equals: selectionStart should be 0 expected 0 but got 6
FAIL change state from email to password assert_equals: input.value should be ' foobar ' after change of state expected " foobar " but got "foobar"
PASS change state from email to datetime-local
PASS change state from email to date
PASS change state from email to month
PASS change state from email to week
PASS change state from email to time
PASS change state from email to number
PASS change state from email to range
PASS change state from email to color
PASS change state from email to checkbox
PASS change state from email to radio
PASS change state from email to file
PASS change state from email to submit
PASS change state from email to image
PASS change state from email to reset
PASS change state from email to button
PASS change state from password to hidden
PASS change state from password to text
PASS change state from password to search
PASS change state from password to tel
FAIL change state from password to url assert_equals: selectionStart should be unchanged expected 2 but got 6
PASS change state from password to email
PASS change state from password to datetime-local
PASS change state from password to date
PASS change state from password to month
PASS change state from password to week
PASS change state from password to time
PASS change state from password to number
PASS change state from password to range
PASS change state from password to color
PASS change state from password to checkbox
PASS change state from password to radio
PASS change state from password to file
PASS change state from password to submit
PASS change state from password to image
PASS change state from password to reset
PASS change state from password to button
PASS change state from datetime-local to hidden
FAIL change state from datetime-local to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from datetime-local to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from datetime-local to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from datetime-local to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from datetime-local to email
FAIL change state from datetime-local to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from datetime-local to date
PASS change state from datetime-local to month
PASS change state from datetime-local to week
PASS change state from datetime-local to time
PASS change state from datetime-local to number
PASS change state from datetime-local to range
PASS change state from datetime-local to color
FAIL change state from datetime-local to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from datetime-local to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from datetime-local to file
PASS change state from datetime-local to submit
PASS change state from datetime-local to image
PASS change state from datetime-local to reset
PASS change state from datetime-local to button
PASS change state from date to hidden
FAIL change state from date to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from date to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from date to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from date to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from date to email
FAIL change state from date to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from date to datetime-local
PASS change state from date to month
PASS change state from date to week
PASS change state from date to time
PASS change state from date to number
PASS change state from date to range
PASS change state from date to color
FAIL change state from date to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from date to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from date to file
PASS change state from date to submit
PASS change state from date to image
PASS change state from date to reset
PASS change state from date to button
PASS change state from month to hidden
FAIL change state from month to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from month to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from month to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from month to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from month to email
FAIL change state from month to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from month to datetime-local
PASS change state from month to date
PASS change state from month to week
PASS change state from month to time
PASS change state from month to number
PASS change state from month to range
PASS change state from month to color
FAIL change state from month to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from month to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from month to file
PASS change state from month to submit
PASS change state from month to image
PASS change state from month to reset
PASS change state from month to button
PASS change state from week to hidden
FAIL change state from week to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from week to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from week to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from week to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from week to email
FAIL change state from week to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from week to datetime-local
PASS change state from week to date
PASS change state from week to month
PASS change state from week to time
PASS change state from week to number
PASS change state from week to range
PASS change state from week to color
FAIL change state from week to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from week to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from week to file
PASS change state from week to submit
PASS change state from week to image
PASS change state from week to reset
PASS change state from week to button
PASS change state from time to hidden
FAIL change state from time to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from time to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from time to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from time to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from time to email
FAIL change state from time to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from time to datetime-local
PASS change state from time to date
PASS change state from time to month
PASS change state from time to week
PASS change state from time to number
PASS change state from time to range
PASS change state from time to color
FAIL change state from time to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from time to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from time to file
PASS change state from time to submit
PASS change state from time to image
PASS change state from time to reset
PASS change state from time to button
PASS change state from number to hidden
FAIL change state from number to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from number to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from number to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from number to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from number to email
FAIL change state from number to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from number to datetime-local
PASS change state from number to date
PASS change state from number to month
PASS change state from number to week
PASS change state from number to time
PASS change state from number to range
PASS change state from number to color
FAIL change state from number to checkbox assert_equals: input.value should be 'on' after change of state expected "on" but got ""
FAIL change state from number to radio assert_equals: input.value should be 'on' after change of state expected "on" but got ""
PASS change state from number to file
PASS change state from number to submit
PASS change state from number to image
PASS change state from number to reset
PASS change state from number to button
PASS change state from range to hidden
FAIL change state from range to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from range to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from range to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from range to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from range to email
FAIL change state from range to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from range to datetime-local
PASS change state from range to date
PASS change state from range to month
PASS change state from range to week
PASS change state from range to time
FAIL change state from range to number assert_equals: input.value should be '' after change of state expected "" but got "50"
PASS change state from range to color
PASS change state from range to checkbox
PASS change state from range to radio
PASS change state from range to file
PASS change state from range to submit
PASS change state from range to image
PASS change state from range to reset
PASS change state from range to button
PASS change state from color to hidden
FAIL change state from color to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from color to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from color to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from color to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from color to email
FAIL change state from color to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from color to datetime-local
PASS change state from color to date
PASS change state from color to month
PASS change state from color to week
PASS change state from color to time
PASS change state from color to number
PASS change state from color to range
PASS change state from color to checkbox
PASS change state from color to radio
PASS change state from color to file
PASS change state from color to submit
PASS change state from color to image
PASS change state from color to reset
PASS change state from color to button
PASS change state from checkbox to hidden
FAIL change state from checkbox to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from checkbox to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from checkbox to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from checkbox to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from checkbox to email
FAIL change state from checkbox to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from checkbox to datetime-local
PASS change state from checkbox to date
PASS change state from checkbox to month
PASS change state from checkbox to week
PASS change state from checkbox to time
PASS change state from checkbox to number
PASS change state from checkbox to range
PASS change state from checkbox to color
PASS change state from checkbox to radio
PASS change state from checkbox to file
PASS change state from checkbox to submit
PASS change state from checkbox to image
PASS change state from checkbox to reset
PASS change state from checkbox to button
PASS change state from radio to hidden
FAIL change state from radio to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from radio to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from radio to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from radio to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from radio to email
FAIL change state from radio to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from radio to datetime-local
PASS change state from radio to date
PASS change state from radio to month
PASS change state from radio to week
PASS change state from radio to time
PASS change state from radio to number
PASS change state from radio to range
PASS change state from radio to color
PASS change state from radio to checkbox
PASS change state from radio to file
PASS change state from radio to submit
PASS change state from radio to image
PASS change state from radio to reset
PASS change state from radio to button
PASS change state from file to hidden
PASS change state from file to text
PASS change state from file to search
PASS change state from file to tel
PASS change state from file to url
PASS change state from file to email
PASS change state from file to password
PASS change state from file to datetime-local
PASS change state from file to date
PASS change state from file to month
PASS change state from file to week
PASS change state from file to time
PASS change state from file to number
PASS change state from file to range
PASS change state from file to color
PASS change state from file to checkbox
PASS change state from file to radio
PASS change state from file to submit
PASS change state from file to image
PASS change state from file to reset
PASS change state from file to button
PASS change state from submit to hidden
FAIL change state from submit to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from submit to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from submit to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from submit to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from submit to email
FAIL change state from submit to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from submit to datetime-local
PASS change state from submit to date
PASS change state from submit to month
PASS change state from submit to week
PASS change state from submit to time
PASS change state from submit to number
PASS change state from submit to range
PASS change state from submit to color
PASS change state from submit to checkbox
PASS change state from submit to radio
PASS change state from submit to file
PASS change state from submit to image
PASS change state from submit to reset
PASS change state from submit to button
PASS change state from image to hidden
FAIL change state from image to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from image to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from image to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from image to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from image to email
FAIL change state from image to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from image to datetime-local
PASS change state from image to date
PASS change state from image to month
PASS change state from image to week
PASS change state from image to time
PASS change state from image to number
PASS change state from image to range
PASS change state from image to color
PASS change state from image to checkbox
PASS change state from image to radio
PASS change state from image to file
PASS change state from image to submit
PASS change state from image to reset
PASS change state from image to button
PASS change state from reset to hidden
FAIL change state from reset to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from reset to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from reset to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from reset to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from reset to email
FAIL change state from reset to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from reset to datetime-local
PASS change state from reset to date
PASS change state from reset to month
PASS change state from reset to week
PASS change state from reset to time
PASS change state from reset to number
PASS change state from reset to range
PASS change state from reset to color
PASS change state from reset to checkbox
PASS change state from reset to radio
PASS change state from reset to file
PASS change state from reset to submit
PASS change state from reset to image
PASS change state from reset to button
PASS change state from button to hidden
FAIL change state from button to text assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from button to search assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from button to tel assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
FAIL change state from button to url assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from button to email
FAIL change state from button to password assert_equals: selectionDirection should be 'none' expected "none" but got "forward"
PASS change state from button to datetime-local
PASS change state from button to date
PASS change state from button to month
PASS change state from button to week
PASS change state from button to time
PASS change state from button to number
PASS change state from button to range
PASS change state from button to color
PASS change state from button to checkbox
PASS change state from button to radio
PASS change state from button to file
PASS change state from button to submit
PASS change state from button to image
PASS change state from button to reset
Harness: the test ran to completion.
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