Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Issue 2785083002: Use devtools to set user agent in chromedriver (Closed)

Created:
3 years, 8 months ago by irisu
Modified:
3 years, 8 months ago
Reviewers:
johnchen, stgao, Sami
CC:
chromium-reviews, samuong+watch_chromium.org, pfeldman, devtools-reviews_chromium.org, srawlins
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Use devtools to set user agent in chromedriver Use Network.setUserAgentOverride instead of using --user-agent to override the user agent for mobileEmulation. This is needed to support mobileEmulation with headless chrome, without adding the --user-agent flag to headless. BUG=604324

Patch Set 1 #

Total comments: 6

Patch Set 2 : Fix Sami's comments and tests #

Patch Set 3 : Add new tab test #

Total comments: 4

Patch Set 4 : Fix New Tab test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+84 lines, -32 lines) Patch
M chrome/test/chromedriver/capabilities.h View 1 chunk +3 lines, -0 lines 0 comments Download
M chrome/test/chromedriver/capabilities.cc View 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/test/chromedriver/capabilities_unittest.cc View 1 2 chunks +2 lines, -6 lines 0 comments Download
M chrome/test/chromedriver/chrome/chrome_desktop_impl.cc View 1 chunk +4 lines, -4 lines 0 comments Download
M chrome/test/chromedriver/chrome/chrome_impl.cc View 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/chromedriver/chrome/devtools_http_client.h View 1 3 chunks +4 lines, -1 line 0 comments Download
M chrome/test/chromedriver/chrome/devtools_http_client.cc View 1 4 chunks +9 lines, -3 lines 0 comments Download
M chrome/test/chromedriver/chrome/mobile_emulation_override_manager.h View 1 2 chunks +3 lines, -1 line 0 comments Download
M chrome/test/chromedriver/chrome/mobile_emulation_override_manager.cc View 1 2 chunks +18 lines, -3 lines 0 comments Download
M chrome/test/chromedriver/chrome/mobile_emulation_override_manager_unittest.cc View 1 3 chunks +6 lines, -3 lines 0 comments Download
M chrome/test/chromedriver/chrome/web_view_impl.h View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/test/chromedriver/chrome/web_view_impl.cc View 1 chunk +9 lines, -5 lines 0 comments Download
M chrome/test/chromedriver/chrome_launcher.cc View 1 chunk +2 lines, -1 line 0 comments Download
M chrome/test/chromedriver/test/run_py_tests.py View 1 2 3 2 chunks +19 lines, -1 line 0 comments Download

Messages

Total messages: 32 (22 generated)
irisu
3 years, 8 months ago (2017-03-30 07:06:18 UTC) #2
Sami
Thanks, this is what I had in mind. Non-owner lgtm with a couple of comments. ...
3 years, 8 months ago (2017-03-30 11:21:43 UTC) #3
irisu
https://codereview.chromium.org/2785083002/diff/1/chrome/test/chromedriver/chrome/devtools_http_client.h File chrome/test/chromedriver/chrome/devtools_http_client.h (right): https://codereview.chromium.org/2785083002/diff/1/chrome/test/chromedriver/chrome/devtools_http_client.h#newcode99 chrome/test/chromedriver/chrome/devtools_http_client.h:99: const std::string user_agent(); On 2017/03/30 11:21:42, Sami wrote: > ...
3 years, 8 months ago (2017-03-31 01:58:10 UTC) #19
irisu
3 years, 8 months ago (2017-04-03 03:31:44 UTC) #21
johnchen
lgtm
3 years, 8 months ago (2017-04-03 14:58:39 UTC) #22
stgao
This looks good to me in general. And johnchen@'s approval is sufficient now for CQ ...
3 years, 8 months ago (2017-04-03 18:28:52 UTC) #23
irisu
On 2017/04/03 18:28:52, stgao(ping after 24h) wrote: > This looks good to me in general. ...
3 years, 8 months ago (2017-04-05 03:10:12 UTC) #26
stgao
Sorry, I might have confused you on the user-agent of the new-tab thing. I commented ...
3 years, 8 months ago (2017-04-05 04:17:08 UTC) #29
irisu
https://codereview.chromium.org/2785083002/diff/80001/chrome/test/chromedriver/test/run_py_tests.py File chrome/test/chromedriver/test/run_py_tests.py (right): https://codereview.chromium.org/2785083002/diff/80001/chrome/test/chromedriver/test/run_py_tests.py#newcode1915 chrome/test/chromedriver/test/run_py_tests.py:1915: driver.MouseClick() On 2017/04/05 04:17:08, stgao(ping after 24h) wrote: > ...
3 years, 8 months ago (2017-04-05 06:44:33 UTC) #30
Sami
3 years, 8 months ago (2017-04-05 13:52:04 UTC) #31
https://codereview.chromium.org/2785083002/diff/80001/chrome/test/chromedrive...
File chrome/test/chromedriver/test/run_py_tests.py (right):

https://codereview.chromium.org/2785083002/diff/80001/chrome/test/chromedrive...
chrome/test/chromedriver/test/run_py_tests.py:1915: driver.MouseClick()
On 2017/04/05 06:44:33, irisu wrote:
> On 2017/04/05 04:17:08, stgao(ping after 24h) wrote:
> > What's the user-agent if the new tab itself directly loads the "/userAgent"
> > below before Devtools connects to the new tab and instructs it to simulate
the
> > user-agent?
> 
> Sorry for that misunderstanding. Modified the test and you are correct - this
> test now fails.
> 
> I will try looking at the docs for a fix, otherwise it may be best to add the
> user-agent flag to headless after all to avoid this.

Right, looks like we need to support a default user agent after all for this
reason.

Powered by Google App Engine
This is Rietveld 408576698