New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 667387 link

Starred by 44 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Bug-Regression


Previous locations:
chromedriver:1559


Sign in to add a comment

Key events from Input.dispatchKeyEvent no longer get handled by browser process

Project Member Reported by gmanikpure@chromium.org, Oct 19 2016

Issue description

Arrow down & up keys do not work when trying to select the text from autofill dropdown in an input element.

Repro testcase is as follows :

//Enable the autofill settings
	    ChromeOptions options = new ChromeOptions();
	    Map<String, Object> prefs = new HashMap<String, Object>();
	    HashMap<String, Object> autofill = new HashMap<String, Object>();
	    autofill.put("enabled", true);
	    prefs.put("autofill", Arrays.asList(autofill));
	    options.setExperimentalOption("prefs", prefs);

//test
	    WebDriver driver= new ChromeDriver(options);
	    driver.get("file:///path/to/testPage.html");
	    WebElement elem = driver.findElement(By.name("firstname"));
	    elem.clear();
	    elem.sendKeys("test");
	    driver.findElement(By.id("sub")).click();
	    Thread.sleep(1000);
	    WebElement elem1 = driver.findElement(By.name("firstname"));
	    elem1.clear();
	    elem1.sendKeys("te");
	    Thread.sleep(1000);
	    elem1.sendKeys(Keys.ARROW_DOWN);
	    Thread.sleep(2000);
	    elem1.sendKeys(Keys.ARROW_UP);

testPage.html:

<!DOCTYPE html>
<html>
<body>

<form >
  First name:<br>
  <input type="text" name="firstname" value="first name">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="last name">
  <br><br>
  <input id= "sub" type="submit" value="Submit">
</form> 

</body>
</html>

Issue happens on Chrome v54.0.2840.59 with Chromedriver 2.24
whereas, the above test works as expected on Chrome v53 with v2.24

Another observation - In input element, Down/Up arrow keys acts like Right/Left arrow keys respectively and scrolls right to left across the autofilled text.
 
correction (in above 'another observation' line) : Down/Up arrow keys act like HOME/END keys respectively.

Comment 3 by ma...@chromium.org, Oct 21 2016

Cc: ma...@chromium.org

Comment 4 by ma...@chromium.org, Oct 24 2016

Thanks for any help on this, it is blocking my project at the moment (need latest Stable version of Chrome).
This is due to crrev.com/404984, which prevents the browser process from handling any keyboard shortcuts that could be triggered by these synthetic input events.

(I'm assuming that the autocomplete stuff is handled in the browser process, correct me if I'm wrong)

So the only way to fix this would be to have Input.dispatchKeyEvent set skip_in_browser=false. Or maybe we could make it a parameter? dgozman@, how feasible is this?
Cc: dgozman@chromium.org
skip_in_browser is there to fight null-pointer, since we don't have real native event. The question is why up/down are handled in browser? Let's ask someone from editing team.
In this case, the autocomplete code is implemented in the browser, so they need this for testing.

When you say "we don't have real native event", does this mean that NativeWebKeyboardEvent::os_event needs to be set? Maybe we can modify DispatchKeyEvent to build a fake ui::Event (or whatever we need for the platform)?

Comment 9 by ma...@chromium.org, Nov 18 2016

Ping dgozman would love your opinion.
re #c8: sure we can explore building a fake ui::Event. skip_in_browser was the easiest way, but if it doesn't work it makes sense to explore other options.

Comment 11 by ma...@chromium.org, Nov 19 2016

Is there hope of undoing the change that broke this for us? I am not familiar with the reasons of the change.

Thanks for your help

Comment 12 by heyhe...@gmail.com, Nov 20 2016

Nothing to add except to emphasize the importance of fixing this, for some of us at least.
Summary: Key events from Input.dispatchKeyEvent no longer get handled by browser process (was: Arrow down/up keys are not working on input element)
Project: chromium
Moved issue chromedriver:1559 to now be  issue chromium:667387 .
So, where is no way anymore to use hacks like open new tab with ctrl + t, close tab with ctrl + w and etc? Sounds pretty sad.
I'm also very much dependent on this issue.

Comment 17 by ma...@chromium.org, Nov 25 2016

Cc: se...@chromium.org rogerm@chromium.org
Owner: dgozman@chromium.org
Status: Assigned (was: Untriaged)
Hi Dmitry, please let us now if there is a possible fix that could be done. This is hindering the launch of our testing framework (we developed it with M53 and on M54+ we can't test Autofill interactions, which are arrow up/down events in the browser).
 Issue chromedriver:1040  has been merged into this issue.
Cc: ajha@chromium.org
 Issue chromedriver:1554  has been merged into this issue.
 Issue 659939  has been merged into this issue.
 Issue chromedriver:1642  has been merged into this issue.

Comment 23 Deleted

Really need this addressed, especially for the Ctrl+Tab, Ctrl+Shift+Tab, but for any keyboard interaction through ChromeDriver.  Really need to be able to automate anything the user might do, simulating as closely as possible if necessary.
Could you tell me when this will be resolved?
Owner: allada@chromium.org

Comment 27 by se...@chromium.org, Jan 23 2017

Any updates on this?
This is blocking our tests. Please let me know when this can be resolved. Thanks.
It's becoming a major problem on our side as well :/ 
We have problems with former Chromedrivers, and we can not migrate on a more recent version because of this.
Any chance we can get this in Q1?
Components: Tests>WebDriver
Labels: Pri-1 Type-Bug-Regression
Status: Started (was: Assigned)
I spoke to dgozman@ about this. There is no simple solution to this problem. We discussed a couple early solutions but none of them are very good.

I am at the exploration part of fixing this. I am not going to promise anything, but this bug will likely be fixed this quarter. However, fixes to bugs like this have a tendency to get reverted once or twice :-(, so don't hold your breath quite yet.

I am flagging this as "Started", but we do not know what we will do to fix it yet.
Thanks for the update! :) We'll stay tuned.
Any update?
Status: Fixed (was: Started)
This should be fixed. Please check to make sure it works for you on Canary in the next few days.

Sorry about the delay.
Project Member

Comment 36 by bugdroid1@chromium.org, Jun 10 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3505cba91e5a004726c286f4396caf2aae3c2e17

commit 3505cba91e5a004726c286f4396caf2aae3c2e17
Author: thakis <thakis@chromium.org>
Date: Sat Jun 10 18:10:52 2017

Revert of ChromeDriver: Handle key events properly on Mac (patchset #6 id:440001 of https://codereview.chromium.org/2656903005/ )

Reason for revert:
Speculative, might have caused  https://crbug.com/732053 

Original issue's description:
> ChromeDriver: Handle key events properly on Mac
>
> Fixes devtool's emulation of key input events to emulate
> os key event for OSX.
>
> BUG= 667387 
>
> Review-Url: https://codereview.chromium.org/2656903005
> Cr-Commit-Position: refs/heads/master@{#478407}
> Committed: https://chromium.googlesource.com/chromium/src/+/fa84ab9619de73a61d305c7459fc186e99b0d291

TBR=dgozman@chromium.org,rohitrao@chromium.org,pfeldman@chromium.org,luoe@chromium.org,erikchen@chromium.org,allada@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG= 667387 

Review-Url: https://codereview.chromium.org/2932223002
Cr-Commit-Position: refs/heads/master@{#478518}

[modify] https://crrev.com/3505cba91e5a004726c286f4396caf2aae3c2e17/chrome/browser/devtools/devtools_sanity_browsertest.cc
[delete] https://crrev.com/f823f843f06636feb082521d76c282a16fe2d577/chrome/test/data/devtools/dispatch_key_event_shows_auto_fill.html
[modify] https://crrev.com/3505cba91e5a004726c286f4396caf2aae3c2e17/content/browser/BUILD.gn
[modify] https://crrev.com/3505cba91e5a004726c286f4396caf2aae3c2e17/content/browser/devtools/protocol/input_handler.cc
[delete] https://crrev.com/f823f843f06636feb082521d76c282a16fe2d577/content/browser/devtools/protocol/native_input_event_builder.h
[delete] https://crrev.com/f823f843f06636feb082521d76c282a16fe2d577/content/browser/devtools/protocol/native_input_event_builder_mac.mm
[modify] https://crrev.com/3505cba91e5a004726c286f4396caf2aae3c2e17/third_party/WebKit/Source/devtools/front_end/Tests.js

Status: Started (was: Fixed)

Comment 38 by ma...@chromium.org, Jun 10 2017

Thanks for working on this allada@. Is the proposed fix only for Mac? Last time I had checked, I was having this issue on Linux. 
This patch sadly got reverted (like I said earlier... these types of changes often get reverted) because it broke a perf test. I am still looking into what is actually wrong.
Any update? Thanks!
I started going down the route to fill in the needed info to send the event to browser, but because of the many differences between OSs and edge cases, I decided that the best route might be to simply forward the info to browser if native_virtual_key was sent. This will give devs the ability to test more precisely per OS at the expense of needing to keep the OS specific key lookup tables themselves.

I uploaded a new patch here that should do this:
https://chromium-review.googlesource.com/c/562559/

Does this sound like a good enough compromise?
Hi,
The patch you are referring to is wrong ("Fixed filmstrip so reset shows proper message"), could you add the correct link?
Sorry correct link is here: https://chromium-review.googlesource.com/c/562583/
Hi,

Disclaimer: I have no knowledge of how Chromium works and it has been over a decade since I wrote code in C++ :)

From looking at the code, it seems that this issue will have been fixed for Mac, but not for other Linux platforms.
#44
TL;DR:
Mac is the only OS blocking this from being fixed, which is to only remove a single line of code: "event.skip_in_browser = true;".

Detail:
We are explicitly forcing the events to skip browser right now because on Mac they do not have an os_event on the NativeEvent and it's needed for some Mac specific stuff. The solution was to construct a Mac os_event and attach it to the NativeEvent, but then it was failing some other performance tests because if you did not specify the character being pressed mac would open the help dialog in chrome because the event somehow triggers the OS to open the help dialog of the application.
OK, got it- removing "event.skip_in_browser = true;" will solve this issue for all operating systems, except for Mac which required an additional implementation.
Sounds good!

Comment 47 by jsaul@google.com, Jul 12 2017

Cc: jsaul@google.com mailtoayush@google.com
Project Member

Comment 48 by bugdroid1@chromium.org, Jul 26 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e83d216ed9fe24c61c7e5647c69887160e283ffd

commit e83d216ed9fe24c61c7e5647c69887160e283ffd
Author: Blaise <allada@chromium.org>
Date: Wed Jul 26 19:09:12 2017

Chromedriver: Fix test failure for emulating key event

This patch fixes a bug introduced in
https://chromium-review.googlesource.com/c/562583/ where chromedriver
was sending nativekeyevent to inspector protocol when not nessessary.

BUG= 667387 ,  732053 ,  chromedriver:1896 

Change-Id: I884c5d1b57900618a7bcbf164c4a70b0455f83a4
Reviewed-on: https://chromium-review.googlesource.com/585651
Reviewed-by: John Budorick <jbudorick@chromium.org>
Commit-Queue: Blaise Bruer <allada@chromium.org>
Cr-Commit-Position: refs/heads/master@{#489717}
[modify] https://crrev.com/e83d216ed9fe24c61c7e5647c69887160e283ffd/chrome/test/chromedriver/chrome/web_view_impl.cc

Status: Fixed (was: Started)
I forgot to mark the patch that fixed it with the bug.

This should now be fixed in this patch:
https://chromium-review.googlesource.com/c/562583/
 Issue chromedriver:2265  has been merged into this issue.
Issue is not fixed.

Please refer to comment from 2265

"https://bugs.chromium.org/p/chromium/issues/detail?id=667387#c49 per this issue is fixed but I can still reproduce.

I feel marking ticket as duplicate of already fixed one is not valid.

Please re-open"

Sign in to add a comment