Closed Bug 1433463 Opened 6 years ago Closed 6 years ago

WebDriver:ElementSendKeys should not run unfocussing steps

Categories

(Remote Protocol :: Marionette, defect, P1)

60 Branch
defect

Tracking

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

RESOLVED FIXED
mozilla60
Tracking Status
firefox-esr52 --- unaffected
firefox58 --- unaffected
firefox59 --- fixed
firefox60 --- fixed

People

(Reporter: barancev, Assigned: ato)

References

(Blocks 1 open bug)

Details

(Keywords: regression)

Attachments

(1 file)

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
Seems to be a regression issue, it used to be spec conformant yesterday.
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)
Summary: sendKeys should not perform unfocusing steps → WebDriver:ElementSendKeys should not run unfocussing steps
No longer blocks: 1432864
Depends on: 1432864
Blocks: 1432864
Status: UNCONFIRMED → NEW
No longer depends on: 1432864
Ever confirmed: true
Priority: -- → P1
Blocks: webdriver
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)
(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)
Flags: needinfo?(dburns)
Priority: P1 → P2
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)
Assignee: nobody → ato
Status: NEW → ASSIGNED
Priority: P2 → P1
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+
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.
https://hg.mozilla.org/mozilla-central/rev/042d7adef0bd
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla60
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]
Product: Testing → Remote Protocol
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: