diff --git a/lib/Page.js b/lib/Page.js index 5d0c2a1d..6a4895ef 100644 --- a/lib/Page.js +++ b/lib/Page.js @@ -400,11 +400,16 @@ class Page extends EventEmitter { */ async _screenshotTask(format, options) { await this._client.send('Target.activateTarget', {targetId: this._client.targetId()}); + let clip = options.clip ? Object.assign({}, options['clip']) : undefined; + if (clip) + clip.scale = 1; + if (options.fullPage) { const metrics = await this._client.send('Page.getLayoutMetrics'); const width = Math.ceil(metrics.contentSize.width); const height = Math.ceil(metrics.contentSize.height); - await this._client.send('Emulation.resetPageScaleFactor'); + // Overwrite clip for full page at all times. + clip = { x: 0, y: 0, width, height, scale: 1 }; const mobile = this._viewport.isMobile || false; const deviceScaleFactor = this._viewport.deviceScaleFactor || 1; const landscape = this._viewport.isLandscape || false; @@ -412,9 +417,6 @@ class Page extends EventEmitter { await this._client.send('Emulation.setDeviceMetricsOverride', { mobile, width, height, deviceScaleFactor, screenOrientation }); } - let clip = options.clip ? Object.assign({}, options['clip']) : undefined; - if (clip) - clip.scale = 1; let result = await this._client.send('Page.captureScreenshot', { format, quality: options.quality, clip }); if (options.fullPage)