mirror of
https://github.com/microsoft/playwright.git
synced 2024-11-28 17:44:33 +03:00
feat: large files upload in ff and wk (#12937)
This commit is contained in:
parent
c8cc62a2e6
commit
97e8ead57c
@ -533,7 +533,15 @@ export class FFPage implements PageDelegate {
|
||||
}
|
||||
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
await Promise.all([
|
||||
this._session.send('Page.setFileInputFiles', {
|
||||
frameId: handle._context.frame._id,
|
||||
objectId: handle._objectId,
|
||||
files
|
||||
}),
|
||||
handle.dispatchEvent('input'),
|
||||
handle.dispatchEvent('change')
|
||||
]);
|
||||
}
|
||||
|
||||
async adoptElementHandle<T extends Node>(handle: dom.ElementHandle<T>, to: dom.FrameExecutionContext): Promise<dom.ElementHandle<T>> {
|
||||
|
@ -936,8 +936,13 @@ export class WKPage implements PageDelegate {
|
||||
await this._session.send('DOM.setInputFiles', { objectId, files: protocolFiles });
|
||||
}
|
||||
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, paths: string[]): Promise<void> {
|
||||
const pageProxyId = this._pageProxySession.sessionId;
|
||||
const objectId = handle._objectId;
|
||||
await Promise.all([
|
||||
this._pageProxySession.connection.browserSession.send('Playwright.grantFileReadAccess', { pageProxyId, paths }),
|
||||
this._session.send('DOM.setInputFiles', { objectId, paths })
|
||||
]);
|
||||
}
|
||||
|
||||
async adoptElementHandle<T extends Node>(handle: dom.ElementHandle<T>, to: dom.FrameExecutionContext): Promise<dom.ElementHandle<T>> {
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import * as path from 'path';
|
||||
import { getUserAgent } from '../packages/playwright-core/lib/utils/utils';
|
||||
import WebSocket from 'ws';
|
||||
@ -574,8 +575,8 @@ test('should fulfill with global fetch result', async ({ browserType, startRemot
|
||||
expect(await response.json()).toEqual({ 'foo': 'bar' });
|
||||
});
|
||||
|
||||
test('should upload large file', async ({ browserType, startRemoteServer, server, browserName }, testInfo) => {
|
||||
test.skip(browserName !== 'chromium');
|
||||
test('should upload large file', async ({ browserType, startRemoteServer, server, browserName, isMac }, testInfo) => {
|
||||
test.skip(browserName === 'webkit' && isMac && parseInt(os.release(), 10) < 20, 'WebKit for macOS 10.15 is frozen and does not have corresponding protocol features.');
|
||||
test.slow();
|
||||
const remoteServer = await startRemoteServer();
|
||||
const browser = await browserType.connect(remoteServer.wsEndpoint());
|
||||
|
@ -20,6 +20,7 @@ import { attachFrame } from '../config/utils';
|
||||
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
import formidable from 'formidable';
|
||||
|
||||
it('should upload the file', async ({ page, server, asset }) => {
|
||||
@ -36,8 +37,8 @@ it('should upload the file', async ({ page, server, asset }) => {
|
||||
}, input)).toBe('contents of the file');
|
||||
});
|
||||
|
||||
it('should upload large file', async ({ page, server, browserName }, testInfo) => {
|
||||
it.skip(browserName !== 'chromium');
|
||||
it('should upload large file', async ({ page, server, browserName, isMac }, testInfo) => {
|
||||
it.skip(browserName === 'webkit' && isMac && parseInt(os.release(), 10) < 20, 'WebKit for macOS 10.15 is frozen and does not have corresponding protocol features.');
|
||||
it.slow();
|
||||
await page.goto(server.PREFIX + '/input/fileupload.html');
|
||||
const uploadFile = testInfo.outputPath('200MB.zip');
|
||||
|
Loading…
Reference in New Issue
Block a user