nits
This commit is contained in:
parent
f86c2e6c27
commit
bb6be58b3d
|
|
@ -262,8 +262,8 @@ export async function convertInputFiles(files: string | FilePayload | string[] |
|
||||||
if (items.some(item => typeof item === 'string')) {
|
if (items.some(item => typeof item === 'string')) {
|
||||||
if (!items.every(item => typeof item === 'string'))
|
if (!items.every(item => typeof item === 'string'))
|
||||||
throw new Error('File paths cannot be mixed with buffers');
|
throw new Error('File paths cannot be mixed with buffers');
|
||||||
const itemFileType = (await Promise.all(items.map(async item => (await fs.promises.stat(item as string)).isDirectory() ? 'directory' : 'file')));
|
const itemFileTypes = (await Promise.all(items.map(async item => (await fs.promises.stat(item as string)).isDirectory() ? 'directory' : 'file')));
|
||||||
if (new Set(itemFileType).size > 1 || itemFileType.filter(type => type === 'directory').length > 1)
|
if (new Set(itemFileTypes).size > 1 || itemFileTypes.filter(type => type === 'directory').length > 1)
|
||||||
throw new Error('File paths must be all files or a single directory');
|
throw new Error('File paths must be all files or a single directory');
|
||||||
|
|
||||||
if (context._connection.isRemote()) {
|
if (context._connection.isRemote()) {
|
||||||
|
|
|
||||||
|
|
@ -647,8 +647,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
|
||||||
await Promise.all(localPaths.map(localPath => (
|
await Promise.all(localPaths.map(localPath => (
|
||||||
fs.promises.access(localPath, fs.constants.F_OK)
|
fs.promises.access(localPath, fs.constants.F_OK)
|
||||||
)));
|
)));
|
||||||
const isDirectoryUpload = localPaths.length === 1 ? (await fs.promises.stat(localPaths[0])).isDirectory() : false;
|
const itemFileTypes = (await Promise.all(localPaths.map(async item => (await fs.promises.stat(item as string)).isDirectory() ? 'directory' : 'file')));
|
||||||
const waitForChangeEvent = isDirectoryUpload ? this.evaluateInUtility(([_, node]) => new Promise<any>(fulfill => {
|
if (new Set(itemFileTypes).size > 1 || itemFileTypes.filter(type => type === 'directory').length > 1)
|
||||||
|
throw new Error('File paths must be all files or a single directory');
|
||||||
|
const waitForChangeEvent = itemFileTypes.includes('directory') ? this.evaluateInUtility(([_, node]) => new Promise<any>(fulfill => {
|
||||||
node.addEventListener('change', fulfill, { once: true });
|
node.addEventListener('change', fulfill, { once: true });
|
||||||
}), undefined) : Promise.resolve();
|
}), undefined) : Promise.resolve();
|
||||||
await this._page._delegate.setInputFilePaths(retargeted, localPaths);
|
await this._page._delegate.setInputFilePaths(retargeted, localPaths);
|
||||||
|
|
|
||||||
|
|
@ -225,12 +225,12 @@ export class WKPage implements PageDelegate {
|
||||||
}
|
}
|
||||||
if (this._page.fileChooserIntercepted())
|
if (this._page.fileChooserIntercepted())
|
||||||
promises.push(session.send('Page.setInterceptFileChooserDialog', { enabled: true }));
|
promises.push(session.send('Page.setInterceptFileChooserDialog', { enabled: true }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'DeviceOrientationEventEnabled' as any, value: contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'DeviceOrientationEventEnabled', value: contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'FullScreenEnabled' as any, value: !contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'FullScreenEnabled', value: !contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'NotificationsEnabled' as any, value: !contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'NotificationsEnabled', value: !contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'PointerLockEnabled' as any, value: !contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'PointerLockEnabled', value: !contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeMonthEnabled' as any, value: contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeMonthEnabled', value: contextOptions.isMobile }));
|
||||||
promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeWeekEnabled' as any, value: contextOptions.isMobile }));
|
promises.push(session.send('Page.overrideSetting', { setting: 'InputTypeWeekEnabled', value: contextOptions.isMobile }));
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue