core(full-page-screenshot): add full page screenshot to artifacts#9064
core(full-page-screenshot): add full page screenshot to artifacts#9064mattzeunert wants to merge 6 commits into
Conversation
| await emulation.enableNexus5X(this, deviceMetricOverrides); | ||
| } else if (settings.emulatedFormFactor === 'desktop') { | ||
| await emulation.enableDesktop(this); | ||
| await emulation.enableDesktop(this, deviceMetricOverrides); |
There was a problem hiding this comment.
Would it be appropriate to hook the options on the driver itself?
There was a problem hiding this comment.
What do you mean by that?
There was a problem hiding this comment.
If the extra param could be removed in favor for having it as a prop on this
There was a problem hiding this comment.
I'm not sure we want to clutter driver with additional properties just for the method here. It's a pretty busy class already 😆
patrickhulce
left a comment
There was a problem hiding this comment.
Looks pretty good! I might argue that if we're commenting out the audit we should probably not land the gatherer config change either, but most of this depends on how quickly we'll follow this up with user-facing changes to leverage this.
| data, | ||
| width, | ||
| height, | ||
| // todo: do we need these? should we create a new type? should we make them optional on the existing type? should we try to provide accurate values? |
There was a problem hiding this comment.
IMO we should just nix these from the type
There was a problem hiding this comment.
Sounds good. It makes sense to have the timings for the filmstrip, but Filmstrip is a separate type from Screenshot.
| async _takeScreenshot(passContext, maxScreenshotHeight) { | ||
| const driver = passContext.driver; | ||
| const metrics = await driver.sendCommand('Page.getLayoutMetrics'); | ||
| const width = await driver.evaluateAsync(`window.innerWidth`) * 2; |
There was a problem hiding this comment.
why * 2?
I thought we might want innerWidth * devicePixelRatio but then we force the deviceScaleFactor to 1 below so I'm not sure anymore
There was a problem hiding this comment.
Whoops, that slipped in when testing large screenshots.
|
|
||
| const Gatherer = require('./gatherer.js'); | ||
|
|
||
| // JPEG quality setting |
There was a problem hiding this comment.
can we link to that awesome exploration doc you made for how we landed on 30?
| * @return {Promise<void>} | ||
| */ | ||
| async beginEmulation(settings) { | ||
| async beginEmulation(settings, deviceMetricOverrides) { |
There was a problem hiding this comment.
my initial thought looking at this was that I was worried about emulatedFormFactor conflicting with deviceMetricOverrides, maybe add a brief comment explaining the use case for deviceMetricOverrides?
creating a nexus 5x with arbitrary screen height seems counter-intuitive at first :)
| const height = Math.min(metrics.contentSize.height, maxScreenshotHeight); | ||
|
|
||
| await driver.beginEmulation(passContext.settings, { | ||
| height, |
There was a problem hiding this comment.
mostly talking to the air here did we ever figure out what screenHeight does separately from height? desktop doesn't set screenHeight at the moment at all just wonder if that'll impact anything
it sets the screen rect but not sure what impact that has...
https://cs.chromium.org/chromium/src/content/renderer/render_widget_screen_metrics_emulator.cc?type=cs&sq=package:chromium&g=0&l=78-83
seems like it notifies some observers and kicks off orientation changes, but doesn't actually affect viewport size?
https://cs.chromium.org/chromium/src/content/renderer/render_widget.cc?type=cs&sq=package:chromium&g=0&l=2183
🤷♂
There was a problem hiding this comment.
screen size is the physical device size (DIP): https://cs.chromium.org/chromium/src/third_party/blink/public/web/web_device_emulation_params.h?l=26&rcl=c6f1509e8c13f8b0739c99b343d628a38f8a9da7
| const height = Math.min(metrics.contentSize.height, maxScreenshotHeight); | ||
|
|
||
| await driver.beginEmulation(passContext.settings, { | ||
| height, |
There was a problem hiding this comment.
screen size is the physical device size (DIP): https://cs.chromium.org/chromium/src/third_party/blink/public/web/web_device_emulation_params.h?l=26&rcl=c6f1509e8c13f8b0739c99b343d628a38f8a9da7
| * @return {Promise<LH.Artifacts.FullPageScreenshot>} | ||
| */ | ||
| async afterPass(passContext) { | ||
| let screenshot = await this._takeScreenshot(passContext, MAX_SCREENSHOT_HEIGHT); |
There was a problem hiding this comment.
should we scroll to the top of the page first? I think devtools does that.
| {deviceMetrics, setTouchEmulationEnabled, userAgent, deviceMetricOverrides} | ||
| ) { | ||
| if (deviceMetricOverrides) { | ||
| deviceMetrics = Object.assign({}, deviceMetrics, deviceMetricOverrides); |
There was a problem hiding this comment.
| deviceMetrics = Object.assign({}, deviceMetrics, deviceMetricOverrides); | |
| deviceMetrics = {...deviceMetrics, ...deviceMetricOverrides}; |
| driver.sendCommand('Network.enable'), | ||
| driver.sendCommand('Network.setUserAgentOverride', {userAgent: NEXUS5X_USERAGENT}), | ||
| driver.sendCommand('Emulation.setTouchEmulationEnabled', {enabled: true}), | ||
| driver.sendCommand('Network.setUserAgentOverride', {userAgent}), |
There was a problem hiding this comment.
should we be balancing domain enable / disable?
|
|
||
| /** | ||
| * @param {LH.Config.Settings} settings | ||
| * @param {{height?: number, screenHeight: number?, deviceScaleFactor?: number}} [deviceMetricOverrides] |
There was a problem hiding this comment.
| * @param {{height?: number, screenHeight: number?, deviceScaleFactor?: number}} [deviceMetricOverrides] | |
| * @param {{height?: number, screenHeight?: number, deviceScaleFactor?: number}} [deviceMetricOverrides] |
| height: 5000, | ||
| screenHeight: 5000, | ||
| }, | ||
| ]); |
There was a problem hiding this comment.
make expectations on the artifact too?
|
we did this in #10716 |
Capture a screenshot of the entire page, rather than just the above the fold content.
Splitting this off from this PR which actually uses the artifact.
What's the best way to test this? Add a new smoke test and unit test the gatherer with a mocked driver?
Related Issues/PRs
Part of #7327