diff --git a/src/common/Page.ts b/src/common/Page.ts index 9df29693..cf313bcf 100644 --- a/src/common/Page.ts +++ b/src/common/Page.ts @@ -1680,20 +1680,8 @@ export class Page extends EventEmitter { const width = Math.ceil(metrics.contentSize.width); const height = Math.ceil(metrics.contentSize.height); - // Overwrite clip for full page at all times. + // Overwrite clip for full page. clip = { x: 0, y: 0, width, height, scale: 1 }; - const { isMobile = false, deviceScaleFactor = 1, isLandscape = false } = - this._viewport || {}; - const screenOrientation: Protocol.Emulation.ScreenOrientation = isLandscape - ? { angle: 90, type: 'landscapePrimary' } - : { angle: 0, type: 'portraitPrimary' }; - await this._client.send('Emulation.setDeviceMetricsOverride', { - mobile: isMobile, - width, - height, - deviceScaleFactor, - screenOrientation, - }); } const shouldSetDefaultBackground = options.omitBackground && format === 'png'; @@ -1705,6 +1693,7 @@ export class Page extends EventEmitter { format, quality: options.quality, clip, + captureBeyondViewport: true, }); if (shouldSetDefaultBackground) await this._client.send('Emulation.setDefaultBackgroundColorOverride'); diff --git a/test/golden-chromium/screenshot-offscreen-clip-artefacts.png b/test/golden-chromium/screenshot-offscreen-clip-artefacts.png deleted file mode 100644 index c41be2be..00000000 Binary files a/test/golden-chromium/screenshot-offscreen-clip-artefacts.png and /dev/null differ diff --git a/test/golden-chromium/screenshot-offscreen-clip.png b/test/golden-chromium/screenshot-offscreen-clip.png index 1e1fc6e3..e503f801 100644 Binary files a/test/golden-chromium/screenshot-offscreen-clip.png and b/test/golden-chromium/screenshot-offscreen-clip.png differ diff --git a/test/golden-firefox/screenshot-offscreen-clip-artefacts.png b/test/golden-firefox/screenshot-offscreen-clip-artefacts.png deleted file mode 100644 index 846b8103..00000000 Binary files a/test/golden-firefox/screenshot-offscreen-clip-artefacts.png and /dev/null differ diff --git a/test/screenshot.spec.ts b/test/screenshot.spec.ts index 607b1369..55b422e0 100644 --- a/test/screenshot.spec.ts +++ b/test/screenshot.spec.ts @@ -50,26 +50,8 @@ describe('Screenshots', function () { }); expect(screenshot).toBeGolden('screenshot-clip-rect.png'); }); - // TODO: enable after the screenshot is fixed. - // https://crbug.com/1173457 - it.skip('should clip elements to the viewport size without artefacts', async () => { - const { page, server } = getTestState(); - await page.setViewport({ width: 50, height: 50 }); - await page.goto(server.PREFIX + '/grid.html'); - const screenshot = await page.screenshot({ - clip: { - x: 25, - y: 25, - width: 100, - height: 100, - }, - }); - expect(screenshot).toBeGolden('screenshot-offscreen-clip.png'); - }); - // TODO: remove after the screenshot is fixed. - // https://crbug.com/1173457 itFailsFirefox( - 'should clip elements to the viewport size with artefacts', + 'should get screenshot bigger than the viewport', async () => { const { page, server } = getTestState(); await page.setViewport({ width: 50, height: 50 }); @@ -82,9 +64,7 @@ describe('Screenshots', function () { height: 100, }, }); - expect(screenshot).toBeGolden( - 'screenshot-offscreen-clip-artefacts.png' - ); + expect(screenshot).toBeGolden('screenshot-offscreen-clip.png'); } ); it('should run in parallel', async () => {