WebDriver:ElementSendKeys should not run unfocussing steps

RESOLVED FIXED in Firefox 59

Status

P1
normal
RESOLVED FIXED
8 months ago
6 months ago

People

(Reporter: barancev, Assigned: ato)

Tracking

(Blocks: 1 bug, {regression})

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

Firefox Tracking Flags

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

Details

Attachments

(1 attachment)

(Reporter)

Description

8 months 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
status-firefox59: --- → unaffected
status-firefox60: --- → affected
Flags: needinfo?(ato)
Keywords: regression
(Reporter)

Comment 2

8 months ago
Seems to be a regression issue, it used to be spec conformant yesterday.
(Assignee)

Comment 3

8 months 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

8 months ago
Summary: sendKeys should not perform unfocusing steps → WebDriver:ElementSendKeys should not run unfocussing steps
(Assignee)

Updated

8 months ago
No longer blocks: 1432864
Depends on: 1432864
Blocks: 1432864
Status: UNCONFIRMED → NEW
No longer depends on: 1432864
Ever confirmed: true
status-firefox58: --- → unaffected
status-firefox59: unaffected → affected
(Assignee)

Updated

8 months ago
Priority: -- → P1
(Assignee)

Updated

8 months ago
Blocks: 721859
(Assignee)

Updated

8 months 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

8 months 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

7 months ago
Flags: needinfo?(dburns)
(Assignee)

Updated

7 months ago
Priority: P1 → P2
(Assignee)

Comment 6

7 months 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

7 months ago
Assignee: nobody → ato
Status: NEW → ASSIGNED
(Assignee)

Updated

7 months ago
Priority: P2 → P1

Comment 8

7 months 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

7 months 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

7 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/042d7adef0bd
Status: ASSIGNED → RESOLVED
Last Resolved: 7 months ago
status-firefox60: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
Upstream PR merged
(Assignee)

Comment 15

7 months 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]
status-firefox-esr52: --- → unaffected

Comment 16

7 months ago
bugherderuplift
https://hg.mozilla.org/releases/mozilla-beta/rev/c4fe0ca380a6
status-firefox59: affected → fixed
Whiteboard: [checkin-needed-beta]
Upstream PR merged
You need to log in before you can comment on or make changes to this bug.