Closed Bug 1417224 Opened 7 years ago Closed 6 years ago

Element clear should work for date-input elements

Categories

(Remote Protocol :: Marionette, defect)

57 Branch
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1354211

People

(Reporter: fisherii, Unassigned)

References

Details

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36

Steps to reproduce:

Called WebElement.clear() on an element that was defined as:

<input type="date">


Actual results:

Got an exception:
InvalidElementStateException: Message: Element must be user-editable in order to clear it.



Expected results:

Any date selected in the input element should have been cleared.
Thank you for reporting this failure. I had a look at it and can reproduce it very easily. Here an example test which demonstrates that behavior:

    def test_date_input(self):
        self.marionette.navigate(self.inline("""<input type="date">"""))
        input = self.marionette.find_element(By.TAG_NAME, "input")
        input.send_keys("2017-11-11")
        input.clear()

In listener.js we make use of `atom.clearElement()` to clear the element. So it means that we need bug 1354211 to get this fixed.
Status: UNCONFIRMED → NEW
Depends on: 1354211
Ever confirmed: true
For advanced control elements such as <input type=date> we probably
need to follow the same recipe we use for interaction with <select>
elements:

	https://searchfox.org/mozilla-central/rev/550148ab69b2879bfb82ffa698720ede1fa626f2/testing/marionette/interaction.js#239-287
I don't think so. I would assume blindly that this is really related to the `clearElement()` method which we use from Selenium atoms. Keep in mind that support for type date started with Firefox 57, so the method might be broken for Firefox.
I talked with Alexei and he will add some tests to the Selenium repository, because as it looks like there are none yet for those new types of input elements.
the spec clearly says text based inputs for #clear so we need to probably make handling these clearer
The spec says:

> The Element Clear command scrolls into view an editable or resettable element and then attempts to clear its selected files or text content.

`text content` also includes `Context object’s value`, and that is what a date input has:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Value

Basically we should follow the `clear a resettable element` steps, right?
I recently defined a new ‘clear algorithm’ concept in WebDriver, and
for <input> elements it says: [1]

> The clear algorithm for input elements is to set the dirty value
> flag and dirty checkedness flag back to false, set the value of
> the element to an empty string, set the checkedness of the element
> to true if the element has a checked content attribute and false
> if it does not, empty the list of selected files, and then invoke
> the value sanitization algorithm, if the type attribute’s current
> state defines one.

This implies, like I may have incorrectly explained in comment #2,
that we need to issue some focus events and probably a change event.

I would quite like to see tests for this in WPT, considering we
don’t run the Selenium tests against our implementation.

  [1] https://w3c.github.io/webdriver/webdriver-spec.html#dfn-clear-algorithm
Assignee: nobody → ato
I looked at this on a plane recently and wrote up a decent number
of tests.  I discovered that Marionette still uses a Selenium atom for
the Element Clear command and that it is probably easier to rewrite the
command as part of https://bugzilla.mozilla.org/show_bug.cgi?id=1354211
than it is to upgrade/monkey patch the atom.
Assignee: ato → nobody
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.