-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(emulation): use Moto G4 for mobile emulation #10191
Changes from 1 commit
0d1f549
39a4101
748d005
4a8c369
d7e2b22
d294ea8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,19 +8,18 @@ | |
/** @typedef {import('../gather/driver.js')} Driver */ | ||
|
||
/** | ||
* Nexus 5X metrics adapted from emulated_devices/module.json | ||
* @type {LH.Crdp.Emulation.SetDeviceMetricsOverrideRequest} | ||
*/ | ||
const NEXUS5X_EMULATION_METRICS = { | ||
const MOTOG4_EMULATION_METRICS = { | ||
mobile: true, | ||
screenWidth: 412, | ||
screenHeight: 660, | ||
width: 412, | ||
height: 660, | ||
screenWidth: 360, | ||
screenHeight: 640, | ||
width: 360, | ||
height: 640, | ||
positionX: 0, | ||
positionY: 0, | ||
scale: 1, | ||
deviceScaleFactor: 2.625, | ||
deviceScaleFactor: 2.625, // ?? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what the heck is this @paulirish There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that should be the device DPR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. math checks out too |
||
screenOrientation: { | ||
angle: 0, | ||
type: 'portraitPrimary', | ||
|
@@ -39,7 +38,7 @@ const DESKTOP_EMULATION_METRICS = { | |
}; | ||
|
||
// eslint-disable-next-line max-len | ||
const NEXUS5X_USERAGENT = 'Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3963.0 Mobile Safari/537.36 Chrome-Lighthouse'; | ||
const MOTOG4_USERAGENT = 'Mozilla/5.0 (Linux; Android 6.0.1; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3963.0 Mobile Safari/537.36 Chrome-Lighthouse'; | ||
patrickhulce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line max-len | ||
const DESKTOP_USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3963.0 Safari/537.36 Chrome-Lighthouse'; | ||
|
||
|
@@ -64,8 +63,8 @@ const NO_CPU_THROTTLE_METRICS = { | |
|
||
const emulationParams = { | ||
mobile: { | ||
userAgent: NEXUS5X_USERAGENT, | ||
metrics: NEXUS5X_EMULATION_METRICS, | ||
userAgent: MOTOG4_USERAGENT, | ||
metrics: MOTOG4_EMULATION_METRICS, | ||
touchEnabled: true, | ||
}, | ||
desktop: { | ||
|
@@ -161,6 +160,6 @@ module.exports = { | |
enableCPUThrottling, | ||
disableCPUThrottling, | ||
goOffline, | ||
MOBILE_USERAGENT: NEXUS5X_USERAGENT, | ||
MOBILE_USERAGENT: MOTOG4_USERAGENT, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice thinking here on the export |
||
DESKTOP_USERAGENT, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -197,10 +197,10 @@ describe('ReportRenderer', () => { | |
assert.ok(descriptions.length >= 3); | ||
|
||
const descriptionsTxt = descriptions.map(el => el.textContent).join('\n'); | ||
assert.ok(/Nexus/.test(descriptionsTxt), 'should have added device emulation'); | ||
assert.ok(/RTT/.test(descriptionsTxt), 'should have added network'); | ||
assert.ok(/\dx/.test(descriptionsTxt), 'should have added CPU'); | ||
assert.ok(descriptionsTxt.includes(sampleResults.userAgent), 'user agent populated'); | ||
expect(descriptionsTxt).toContain('Moto G4'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. asserts are bad. |
||
expect(descriptionsTxt).toContain('RTT'); | ||
expect(descriptionsTxt).toMatch(/\dx/); | ||
expect(descriptionsTxt).toContain(sampleResults.userAgent); | ||
}); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to look at an actual device and see what a browser reports this as.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
360 looks right https://github.com/WPO-Foundation/webpagetest/blob/901d2906711c32577f9c8e19603cf491096fcbf8/www/settings/mobile_devices.ini#L7
could use a WPT run if you need to to verify