mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
chore: remove screenshot options for firefox (#11026)
This commit is contained in:
parent
ace1230e41
commit
2a7d4ab1ad
@ -18,7 +18,7 @@ import type {Readable} from 'stream';
|
|||||||
|
|
||||||
import {type Protocol} from 'devtools-protocol';
|
import {type Protocol} from 'devtools-protocol';
|
||||||
|
|
||||||
import type {Browser} from '../api/Browser.js';
|
import {type Browser} from '../api/Browser.js';
|
||||||
import type {BrowserContext} from '../api/BrowserContext.js';
|
import type {BrowserContext} from '../api/BrowserContext.js';
|
||||||
import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js';
|
import {CDPSessionEvent, type CDPSession} from '../api/CDPSession.js';
|
||||||
import {type ElementHandle} from '../api/ElementHandle.js';
|
import {type ElementHandle} from '../api/ElementHandle.js';
|
||||||
@ -33,9 +33,9 @@ import {
|
|||||||
type MediaFeature,
|
type MediaFeature,
|
||||||
type Metrics,
|
type Metrics,
|
||||||
type NewDocumentScriptEvaluation,
|
type NewDocumentScriptEvaluation,
|
||||||
|
type ScreenshotClip,
|
||||||
type ScreenshotOptions,
|
type ScreenshotOptions,
|
||||||
type WaitTimeoutOptions,
|
type WaitTimeoutOptions,
|
||||||
type ScreenshotClip,
|
|
||||||
} from '../api/Page.js';
|
} from '../api/Page.js';
|
||||||
import {
|
import {
|
||||||
ConsoleMessage,
|
ConsoleMessage,
|
||||||
@ -74,6 +74,7 @@ import {type DeviceRequestPrompt} from './DeviceRequestPrompt.js';
|
|||||||
import {CdpDialog} from './Dialog.js';
|
import {CdpDialog} from './Dialog.js';
|
||||||
import {EmulationManager} from './EmulationManager.js';
|
import {EmulationManager} from './EmulationManager.js';
|
||||||
import {createCdpHandle, releaseObject} from './ExecutionContext.js';
|
import {createCdpHandle, releaseObject} from './ExecutionContext.js';
|
||||||
|
import {FirefoxTargetManager} from './FirefoxTargetManager.js';
|
||||||
import {type CdpFrame} from './Frame.js';
|
import {type CdpFrame} from './Frame.js';
|
||||||
import {FrameManager, FrameManagerEvent} from './FrameManager.js';
|
import {FrameManager, FrameManagerEvent} from './FrameManager.js';
|
||||||
import {CdpKeyboard, CdpMouse, CdpTouchscreen} from './Input.js';
|
import {CdpKeyboard, CdpMouse, CdpTouchscreen} from './Input.js';
|
||||||
@ -1052,11 +1053,17 @@ export class CdpPage extends Page {
|
|||||||
captureBeyondViewport,
|
captureBeyondViewport,
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
|
const isFirefox =
|
||||||
|
this.target()._targetManager() instanceof FirefoxTargetManager;
|
||||||
|
|
||||||
await using stack = new AsyncDisposableStack();
|
await using stack = new AsyncDisposableStack();
|
||||||
if (omitBackground && (type === 'png' || type === 'webp')) {
|
// Firefox omits background by default; it's not configurable.
|
||||||
|
if (!isFirefox && omitBackground && (type === 'png' || type === 'webp')) {
|
||||||
await this.#emulationManager.setTransparentBackgroundColor();
|
await this.#emulationManager.setTransparentBackgroundColor();
|
||||||
stack.defer(async () => {
|
stack.defer(async () => {
|
||||||
await this.#emulationManager.resetDefaultBackgroundColor();
|
await this.#emulationManager
|
||||||
|
.resetDefaultBackgroundColor()
|
||||||
|
.catch(debugError);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1076,15 +1083,16 @@ export class CdpPage extends Page {
|
|||||||
clip = getIntersectionRect(clip, viewport);
|
clip = getIntersectionRect(clip, viewport);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We need to do these spreads because Firefox doesn't allow unknown options.
|
||||||
const {data} = await this.#client.send('Page.captureScreenshot', {
|
const {data} = await this.#client.send('Page.captureScreenshot', {
|
||||||
format: type,
|
format: type,
|
||||||
optimizeForSpeed,
|
...(optimizeForSpeed ? {optimizeForSpeed} : {}),
|
||||||
quality,
|
...(quality !== undefined ? {quality} : {}),
|
||||||
clip: clip && {
|
clip: clip && {
|
||||||
...clip,
|
...clip,
|
||||||
scale: clip.scale ?? 1,
|
scale: clip.scale ?? 1,
|
||||||
},
|
},
|
||||||
fromSurface,
|
...(!fromSurface ? {fromSurface} : {}),
|
||||||
captureBeyondViewport,
|
captureBeyondViewport,
|
||||||
});
|
});
|
||||||
return data;
|
return data;
|
||||||
|
Loading…
Reference in New Issue
Block a user