WebDriver:ElementSendKeys should not run unfocussing steps

RESOLVED FIXED in Firefox 59

Status

defect
P1
normal
RESOLVED FIXED
a year ago
a year ago

People

(Reporter: barancev, Assigned: ato)

Tracking

(Blocks 1 bug, {regression})

60 Branch
mozilla60
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox-esr52 unaffected, firefox58 unaffected, firefox59 fixed, firefox60 fixed)

Details

Attachments

(1 attachment)

Reporter

Description

a year ago
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36

Steps to reproduce:

Let's suppose we have an input and perform two sendKeys commands in a sequence:

element.sendKeys("a");
element.sendKeys("b");

It fires the following chain of events:
focus keydown keypress keyup change blur focus keydown keypress keyup change blur

But according to the specification, it should not unfocus the input element between commands and should fire:
focus keydown keypress keyup keydown keypress keyup

and only the next command that moves the focus should cause change and blur events.

Here is the cite from IRC chat with Simon Stewart:
https://botbot.me/freenode/selenium/2018-01-26/?msg=96179433&page=2

<barancev> simonstewart: AutomatedTester: should focus be moved out of an input field after sendKeys command?
<barancev> I mean, *immediately* after sendKeys, as a part of this command execution flow
<simonstewart> barancev: focus should stay where it is, unless the last key pressed is to move the focus out of the element (like "tab"). I think. Lemme check the spec
<simonstewart> The spec's pretty clear that the unfocusing steps are not run
<simonstewart> https://w3c.github.io/webdriver/webdriver-spec.html#element-send-keys
<simonstewart> Step 9 is the one that sets the focus, but only if the element isn't already focused
<simonstewart> And nothing after that unsets the focus
<simonstewart> sendKeys won't fire the blur event
<simonstewart> But if you click, that changes the active element
<simonstewart> And that will cause a blur event to fire
<simonstewart> (that is, you need to move focus, just as you would with a real browser)
Should be a regression from bug 1432864.
Blocks: 1432864
Flags: needinfo?(ato)
Keywords: regression
Reporter

Comment 2

a year ago
Seems to be a regression issue, it used to be spec conformant yesterday.
Assignee

Comment 3

a year ago
I would say the specification is inconsistent on this topic,
as other interaction commands such as Element Clear do run the
unfocussing steps.  I would expect a high-level command to either
unfocus or return focus to the previous focus area and the low-level
action commands to not alter focus in any way.

Filed https://github.com/w3c/webdriver/issues/1212 to clarify this.
Flags: needinfo?(ato)
Assignee

Updated

a year ago
Summary: sendKeys should not perform unfocusing steps → WebDriver:ElementSendKeys should not run unfocussing steps
Assignee

Updated

a year ago
No longer blocks: 1432864
Depends on: 1432864
Blocks: 1432864
Status: UNCONFIRMED → NEW
No longer depends on: 1432864
Ever confirmed: true
Assignee

Updated

a year ago
Priority: -- → P1
Assignee

Updated

a year ago
Blocks: webdriver
Assignee

Updated

a year ago
OS: Unspecified → All
Hardware: Unspecified → All
Andreas, so this is a regression in Firefox 59 now. Should we consider to revert the behavior for now to not cause trouble for people? Not sure how many will be affected, but I don't see that we might reach a consensus on the spec issue until 59 gets released. What do you think?
Flags: needinfo?(ato)
Assignee

Comment 5

a year ago
(In reply to Henrik Skupin (:whimboo) from comment #4)

> Andreas, so this is a regression in Firefox 59 now.

Well it’s not a regression if it is the correct behaviour (-:

> Should we consider to revert the behavior for now to not cause
> trouble for people? Not sure how many will be affected, but I
> don't see that we might reach a consensus on the spec issue until
> 59 gets released. What do you think?

I have pinged :automatedtester again on
https://github.com/w3c/webdriver/issues/1212.
Flags: needinfo?(ato)
Assignee

Updated

a year ago
Flags: needinfo?(dburns)
Assignee

Updated

a year ago
Priority: P1 → P2
Assignee

Comment 6

a year ago
So the conclusion from https://github.com/w3c/webdriver/issues/1212
is that Element Clear _should_ run unfocussing steps, whereas
Element Send keys _should not_, for historical reasons.
Flags: needinfo?(dburns)
Comment hidden (mozreview-request)
Assignee

Updated

a year ago
Assignee: nobody → ato
Status: NEW → ASSIGNED
Assignee

Updated

a year ago
Priority: P2 → P1

Comment 8

a year ago
mozreview-review
Comment on attachment 8953025 [details]
Bug 1433463 - WebDriver:ElementSendKeys should not run unfocussing steps.

https://reviewboard.mozilla.org/r/222302/#review228194
Attachment #8953025 - Flags: review?(dburns) → review+
Comment hidden (mozreview-request)

Comment 10

a year ago
Pushed by atolfsen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/042d7adef0bd
WebDriver:ElementSendKeys should not run unfocussing steps. r=automatedtester
Created web-platform-tests PR https://github.com/w3c/web-platform-tests/pull/9631 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.

Comment 13

a year ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/042d7adef0bd
Status: ASSIGNED → RESOLVED
Last Resolved: a year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Upstream PR merged
Assignee

Comment 15

a year ago
Sheriffs: Can we try uplifting this to beta?  If it doesn’t apply, let me know and I can rebase it.
Whiteboard: [checkin-needed-beta]
Upstream PR merged
You need to log in before you can comment on or make changes to this bug.