feat: default screenshot jpeg quality to 80 (#22966)

Fixes https://github.com/microsoft/playwright/issues/22436
This commit is contained in:
Andrey Lushnikov 2023-05-11 18:09:19 +00:00 committed by GitHub
parent 8a09d6dc0b
commit d7f5f1f5fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -440,6 +440,7 @@ export class FFPage implements PageDelegate {
const { data } = await this._session.send('Page.screenshot', {
mimeType: ('image/' + format) as ('image/png' | 'image/jpeg'),
clip: documentRect,
quality,
omitDeviceScaleFactor: scale === 'css',
});
return Buffer.from(data, 'base64');

View File

@ -288,7 +288,8 @@ export class Screenshotter {
const cleanupHighlight = await this._maskElements(progress, options);
progress.throwIfAborted(); // Avoid extra work.
const buffer = await this._page._delegate.takeScreenshot(progress, format, documentRect, viewportRect, options.quality, fitsViewport, options.scale || 'device');
const quality = format === 'jpeg' ? options.quality ?? 80 : undefined;
const buffer = await this._page._delegate.takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, options.scale || 'device');
progress.throwIfAborted(); // Avoid restoring after failure - should be done by cleanup.
await cleanupHighlight();