w3c / webdriver

Remote control interface that enables introspection and control of user agents.
https://w3c.github.io/webdriver/
Other
685 stars 195 forks source link

Clearing input cancel list in Element Send Keys #1809

Open grokys opened 6 months ago

grokys commented 6 months ago

Element Send Keys details the following steps:

  1. Let source be the result of create an input source with input state, and "key".

  2. Add an input source with input state, input id and source.

  3. Dispatch actions for a string with arguments input state, input id, and source, text, and session's current browsing context.

  4. Remove an input source with input state and input id.

Dispatch actions for a string then eventually dispatches keyDown actions, which in dispatch tick actions says:

If subtype is "keyDown", append a copy of action object with the subtype property changed to "keyUp" to input state’s input cancel list.

Once that is done we arrive at step 14 in Element Send Keys: Remove an input source. This says:

Assert: None of the items in input state's input cancel list has id equal to input id.

But I can't find the place in the spec where the input cancel list should be cleared: the only reference to clearing the input cancel list is in Release Actions.

grokys commented 6 months ago

I suspect that "undo actions" in dispatch actions for a string may be a vestige from an older version of the spec for two reasons:

ChernyshevDS commented 5 months ago

@grokys Hello. I'm struggling with the same task as you trying to implement actions handling according to the spec, and I think the spec has a bigger flaw, that confused you and me regarding the input cancel list, and considering you spent your time scrutinizing the spec I'll be grateful for your feedback on my thoughts.

Any key down action (not only modifiers) dispatched with dispatch tick actions adds a key up action to input cancel list, which is global for all input state, not a particular input source. However, the only method to remove actions from this list is release actions. I beleive, dispatching a key up action should remove corresponding actions from input cancel list, otherwise we end up with a lot of duplicated key up actions on release actions. Same goes for pointer up actions.

Looking at the description of a dispatch actions for a string, we can see that undo actions hold only modifier keys state for a temporary key input source, created in element send keys, and these modifiers are cleared at the end of element send keys, so I do not agree with you that input cancel list may be used to clear modifiers state.

Adding to a confusion here: we have a global key state, which combines the state of possibly multiple key input sources, but it's not used during key events processing. Let's assume that we called perform actions with shift key down event. After the processing the input state contains one key input source with shift property set to true. Shouldn't this shift property be taken into account somehow if we call element send keys next? No idea...

ChernyshevDS commented 5 months ago

Found another inconsistency in spec: dispatch actions for a string appends shift key down actions for shifted characters thus adding cancelling shift key up to input cancel list, although in this context the undo actions map should be used, otherwise these actions are not executed in clear modifiers key state.

stp-ekioh commented 2 months ago

Am trying to implement this specification and have run into the same issue - does anyone involved with the spec have any comment on this? Are the specs still being updated?