-
Notifications
You must be signed in to change notification settings - Fork 6
Try: Add Firefox support to benchmark-web-vitals #191
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
base: main
Are you sure you want to change the base?
Conversation
| } | ||
| const page = await browser.newPage(); | ||
| await page.setBypassCSP( true ); // Bypass CSP so the web vitals script tag can be injected below. | ||
| if ( 'firefox' !== params.browser ) { |
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.
Without this conditional, I get an error:
CDP support is required for this feature. The current browser does not support CDP.
b70109f to
0d07a0e
Compare
| await page.click( 'body', { | ||
| offset: { x: -500, y: -500 }, | ||
| } ); | ||
| await page.mouse.click( 0, 0 ); |
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 made this change because when using the original, Firefox complains with:
Error: Protocol error (input.performActions): move target out of bounds Move target (-500, -1606) is out of bounds of viewport dimensions (960, 700)
When I try changing the coordinates to 0,0 then the error is:
Error: Protocol error (input.performActions): move target out of bounds Move target (0, -1106) is out of bounds of viewport dimensions (960, 700)
Using negative coordinates with page.mouse.click() also results in an error:
Error: Protocol error (input.performActions): move target out of bounds Move target (-500, -500) is out of bounds of viewport dimensions (960, 700)
So this is why I changed it to 0,0.
444c8e5 to
10912a5
Compare
| if ( params.browser === 'firefox' ) { | ||
| throw new Error( | ||
| 'Network emulation is not currently available in Firefox.' | ||
| ); | ||
| } |
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.
Without this conditional, I get an error:
UnsupportedOperation
at BidiPage.emulateNetworkConditions (file:///Users/westonruter/repos/wpp-research/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Page.js:576:23)
at benchmarkURL (file:///Users/westonruter/repos/wpp-research/cli/commands/benchmark-web-vitals.mjs:591:16)
at async handler (file:///Users/westonruter/repos/wpp-research/cli/commands/benchmark-web-vitals.mjs:465:42)
at async Command.<anonymous> (file:///Users/westonruter/repos/wpp-research/cli/run.mjs:79:4)
After doing
npm install, do:You can then specify that you want to benchmark with Firefox by passing
firefoxto the new--browser(-b) argument.Note that network emulation and CPU throttling are not currently supported. Also, bypassing CSP is not supported so injecting the web-vitals.js script may not work if attempting to benchmark a site which is using a Content Security Policy.
Chrome
Firefox