fix: make screenshots work in puppeteer-web (#6936)

This commit is contained in:
Joel Griffith 2021-03-15 02:05:15 -07:00 committed by GitHub
parent 1c2479a6cd
commit 5f24f60819
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1740,13 +1740,16 @@ export class Page extends EventEmitter {
options.encoding === 'base64'
? result.data
: Buffer.from(result.data, 'base64');
if (!isNode && options.path) {
throw new Error(
'Screenshots can only be written to a file path in a Node environment.'
);
if (options.path) {
if (!isNode) {
throw new Error(
'Screenshots can only be written to a file path in a Node environment.'
);
}
const fs = await helper.importFSModule();
await fs.promises.writeFile(options.path, buffer);
}
const fs = await helper.importFSModule();
if (options.path) await fs.promises.writeFile(options.path, buffer);
return buffer;
function processClip(