Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack of normalisation in date formats #1470

Open
andrewnicols opened this issue Dec 11, 2019 · 7 comments
Open

Lack of normalisation in date formats #1470

andrewnicols opened this issue Dec 11, 2019 · 7 comments

Comments

@andrewnicols
Copy link

@andrewnicols andrewnicols commented Dec 11, 2019

This is a bit of a weird one, so apologies in advance.

In chapter E. Index:

Date state
Local Date and Time state

The display format for the date, and local date and time, input types is left to be implementation specific, meanwhile the value attribute is always normalised to dd-mm-yyyy.
The lack of standardisation makes it difficult to set the value using the element-send-keys endpoint (https://www.w3.org/TR/webdriver/#dfn-element-send-keys) as the keys sent mimic the display format.

As an example, if I set the value of a date element to 2012-12-25 I can do so successfully on Firefox, but Chrome uses a different date format of dd/mm/yyyy for display. As a result my attempt to set the value leads to a garbage result of 1225-12-20.

I feel that there should be some part of the spec which dictates that the accepted values must be normalised in some way.

In the current state it is not possible to write a cross-browser way of setting the date using the sendKeys endpoint.

@andreastt
Copy link
Member

@andreastt andreastt commented Dec 11, 2019

Mutable form control elements Elements rendered as something other than a text input control are special cased in the remote end steps for Element Send Keys, step 8, match clause two, substep 3:

The user agent renders element as something other than a text input control (for example an input element in the color state being presented as a colorwheel):

3. Set a property value to text on element.

(It is a bug in the above quote from the spec that the match clause doesn’t use the mutable form control elements definition directly, but the effect is the same.)

This means for <input type=date>, drivers will modify the value own property directly and simulate the necessary DOM events. The following test case shows that this produces the correct result in both Firefox and Chrome:

<!doctype html>
<meta charset=utf-8>
<title>date</title>

<input type=date />

<script>
const date = document.querySelector("input");
date.value = "2019-12-11";
console.log(date.value);  // prints "2019-12-11"
</script>

To my big surprise we don’t seem to have any interoperability tests for this, which means the behaviour you are observing with chromedriver is likely a bug.

@andrewnicols
Copy link
Author

@andrewnicols andrewnicols commented Dec 11, 2019

Thanks @andreastt - I'll have a re-read of that part of the spec tomorrow (10pm here in Aus).

Should I report this as a bug against chromedriver then?

@andrewnicols
Copy link
Author

@andrewnicols andrewnicols commented Dec 11, 2019

Unrelated to this issue, but I've noticed another missing case: sendKeys should accept NULL to clear modifiers, as discussed in php-webdriver/php-webdriver#693.

@andreastt
Copy link
Member

@andreastt andreastt commented Dec 11, 2019

I fixed the definition of which form controls we should bypass using actions for in #1471. That should help explain the intention of the spec.

The NULL character breaking to clear modifiers will consequently not be applicable to those elements we don’t use actions for.

@andrewnicols
Copy link
Author

@andrewnicols andrewnicols commented Dec 12, 2019

I have raised:

  1. bug against chromedriver https://bugs.chromium.org/p/chromedriver/issues/detail?id=3274
  2. bug against wpt: web-platform-tests/wpt#20734
@andrewnicols
Copy link
Author

@andrewnicols andrewnicols commented Feb 13, 2020

@andreastt, it would be really helpful if we could finalise this issue and 1471, however I think that the language in the patch on 1471 could be improved further.

This issue was specifically raised to discuss the date input type, but it has not been specifically mentioned in 1471, and the discussion in https://bugs.chromium.org/p/chromedriver/issues/detail?id=3274 suggests that the language is still unclear - so much so that the folks at chromedriver do not think that there is consensus that the date element should be treated as non-typeable.

@andreastt
Copy link
Member

@andreastt andreastt commented Feb 14, 2020

(I am currently between jobs and will not have the capacity to work on this until further notice.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.