catchpoint / WebPageTest

Official repository for WebPageTest
Other
3.06k stars 713 forks source link

setUserAgent not respected in scripted tests #1304

Closed gilbertococchi closed 3 months ago

gilbertococchi commented 4 years ago

https://webpagetest.org/result/191011_GX_0c8cb1c62558a1889e0f9bbc5136ffc8/1/details/#step1_request198

Script:

setActivityTimeout  30000
setUserAgent    Mozilla/5.0 (Linux; Android 8.1.0; Pixel 2 Build/OPM1.171019.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Mobile Safari/537.36 PTST/191007.161036
navigate    https://mobile.yoox.com/us/women/clothing%20new%20arrivals/shoponline
sleep   30
execAndWait  document.querySelectorAll('a.itemContainer')[0].click()

Request Headers User Agent for https://mobile.yoox.com/scripts/client/yoox/js/dist/sw.js user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36

Expected User Agent: user-agent: Mozilla/5.0 (Linux; Android 8.1.0; Pixel 2 Build/OPM1.171019.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Mobile Safari/537.36 PTST/191007.161036 Also when adding the standard Chrome Mobile UA Emulation and/or the Discard HTTP Headers option the request would still receive the Default Chrome UA:

https://webpagetest.org/result/191011_N1_706c425c6e3488579c142d171514f112/1/details/#step1_request186

https://webpagetest.org/result/191011_C5_da68801f738d0ea907bef80f155be3bd/1/details/#waterfall_view_step1

vibaldem commented 4 years ago

We've seen this happen in our private instance when the requests come from service worker or from a different context. The devtools user agent override only seems to apply to the current target.
As a work around we applied the custom user agent at launch using --user-agent startup flag and that seems to apply to all requests.

github-actions[bot] commented 3 months ago

We're in the process of cleaning up issues on this project in order to ensure we're able to stay on top of high priority bugs and feature requests. As a part of this process, we're automatically closing any issues that have had no activity within the last two years, including this one, since the codebase has changed dramatically in that time. If you feel this is still relevant, please file a new issue using the relevant issue template so we can get it prioritized. Thanks!