chore: small refactor for screenshotTask (#9451)

This commit is contained in:
Junyan 2023-01-02 18:01:36 +08:00 committed by GitHub
parent 86441e313d
commit 6bc152ece0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1377,14 +1377,13 @@ export class CDPPage extends Page {
const fromSurface = options.fromSurface; const fromSurface = options.fromSurface;
if (options.fullPage) { if (options.fullPage) {
const metrics = await this.#client.send('Page.getLayoutMetrics');
// Fallback to `contentSize` in case of using Firefox.
const {width, height} = metrics.cssContentSize || metrics.contentSize;
// Overwrite clip for full page. // Overwrite clip for full page.
clip = undefined; clip = undefined;
if (!captureBeyondViewport) { if (!captureBeyondViewport) {
const metrics = await this.#client.send('Page.getLayoutMetrics');
// Fallback to `contentSize` in case of using Firefox.
const {width, height} = metrics.cssContentSize || metrics.contentSize;
const { const {
isMobile = false, isMobile = false,
deviceScaleFactor = 1, deviceScaleFactor = 1,