-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add device emulation to benchmark-web-vitals
#166
base: main
Are you sure you want to change the base?
Conversation
benchmark-web-vitals
await page | ||
.mainFrame() | ||
.waitForFunction( | ||
`window.innerWidth === ${ params.windowViewport.width } && window.innerHeight === ${ params.windowViewport.height }` | ||
); |
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.
I removed this code because it with the deviceScaleFactor
coming from device emulation, I found the innerWidth
and innerHeight
to be the viewport's dimensions multiplied by the device scale factor. While I could implement that adjustment, I didn't find that this code was actually necessary.
@@ -338,7 +357,7 @@ export async function handler( opt ) { | |||
const params = getParamsFromOptions( opt ); | |||
const results = []; | |||
|
|||
const browser = await puppeteer.launch( { headless: 'new' } ); | |||
const browser = await puppeteer.launch( { headless: true } ); |
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.
This change was caught by TypeScript since Puppeteer the new headless mode is now the default.
This is a follow-up to #164.
Being able to specify the window dimensions alone is not always sufficient to test a page. In particular, there is also the device scale factor which is often higher on mobile devices. More importantly, if the user agent is not indicating a mobile device then a site may return a page formatted for desktop. This PR introduces a
--emulate-device
(-e
) parameter to specify one of the known devices in Puppeteer. The--window-viewport
arg may still be supplied, and it will override thewidth
andheight
of the emulated device. If no device is being emulated, then the default viewport remains 960x700.