This reverts commit 7fe763c1fc
.
This commit is contained in:
Родитель
91408f2c5e
Коммит
136c4e10e6
|
@ -317,6 +317,11 @@ export class CRPage implements PageDelegate {
|
|||
return this._sessionForHandle(handle)._getContentQuads(handle);
|
||||
}
|
||||
|
||||
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
|
||||
await handle.evaluateInUtility(([injected, node, files]) =>
|
||||
injected.setInputFiles(node, files), files);
|
||||
}
|
||||
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void> {
|
||||
const frame = await handle.ownerFrame();
|
||||
if (!frame)
|
||||
|
|
|
@ -639,7 +639,7 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
|
|||
if (localPaths)
|
||||
await this._page._delegate.setInputFilePaths(retargeted, localPaths);
|
||||
else
|
||||
await retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), files as types.FilePayload[]);
|
||||
await this._page._delegate.setInputFiles(retargeted, files as types.FilePayload[]);
|
||||
});
|
||||
await this._page._doSlowMo();
|
||||
return 'done';
|
||||
|
|
|
@ -527,6 +527,11 @@ export class FFPage implements PageDelegate {
|
|||
return result.quads.map(quad => [ quad.p1, quad.p2, quad.p3, quad.p4 ]);
|
||||
}
|
||||
|
||||
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
|
||||
await handle.evaluateInUtility(([injected, node, files]) =>
|
||||
injected.setInputFiles(node, files), files);
|
||||
}
|
||||
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ export interface PageDelegate {
|
|||
getContentFrame(handle: dom.ElementHandle): Promise<frames.Frame | null>; // Only called for frame owner elements.
|
||||
getOwnerFrame(handle: dom.ElementHandle): Promise<string | null>; // Returns frameId.
|
||||
getContentQuads(handle: dom.ElementHandle): Promise<types.Quad[] | null>;
|
||||
setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void>;
|
||||
setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void>;
|
||||
getBoundingBox(handle: dom.ElementHandle): Promise<types.Rect | null>;
|
||||
getFrameElement(frame: frames.Frame): Promise<dom.ElementHandle>;
|
||||
|
|
|
@ -926,6 +926,16 @@ export class WKPage implements PageDelegate {
|
|||
]);
|
||||
}
|
||||
|
||||
async setInputFiles(handle: dom.ElementHandle<HTMLInputElement>, files: types.FilePayload[]): Promise<void> {
|
||||
const objectId = handle._objectId;
|
||||
const protocolFiles = files.map(file => ({
|
||||
name: file.name,
|
||||
type: file.mimeType,
|
||||
data: file.buffer,
|
||||
}));
|
||||
await this._session.send('DOM.setInputFiles', { objectId, files: protocolFiles });
|
||||
}
|
||||
|
||||
async setInputFilePaths(handle: dom.ElementHandle<HTMLInputElement>, files: string[]): Promise<void> {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче