mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-13 17:14:02 +03:00
chore: move Frame.waitForTimeout to the server side (#9053)
This commit is contained in:
parent
854cf9c25c
commit
d354d14fb9
@ -446,7 +446,7 @@ export class Frame extends ChannelOwner<channels.FrameChannel, channels.FrameIni
|
||||
|
||||
async waitForTimeout(timeout: number) {
|
||||
return this._wrapApiCall(async (channel: channels.FrameChannel) => {
|
||||
await new Promise(fulfill => setTimeout(fulfill, timeout));
|
||||
await channel.waitForTimeout({ timeout });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -215,6 +215,10 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameInitializer
|
||||
return await this._frame.uncheck(metadata, params.selector, params);
|
||||
}
|
||||
|
||||
async waitForTimeout(params: channels.FrameWaitForTimeoutParams, metadata: CallMetadata): Promise<void> {
|
||||
return await this._frame.waitForTimeout(metadata, params.timeout);
|
||||
}
|
||||
|
||||
async waitForFunction(params: channels.FrameWaitForFunctionParams, metadata: CallMetadata): Promise<channels.FrameWaitForFunctionResult> {
|
||||
return { handle: ElementHandleDispatcher.fromJSHandle(this._scope, await this._frame._waitForFunctionExpression(metadata, params.expression, params.isFunction, parseArgument(params.arg), params)) };
|
||||
}
|
||||
|
@ -1578,6 +1578,7 @@ export interface FrameChannel extends Channel {
|
||||
title(params?: FrameTitleParams, metadata?: Metadata): Promise<FrameTitleResult>;
|
||||
type(params: FrameTypeParams, metadata?: Metadata): Promise<FrameTypeResult>;
|
||||
uncheck(params: FrameUncheckParams, metadata?: Metadata): Promise<FrameUncheckResult>;
|
||||
waitForTimeout(params: FrameWaitForTimeoutParams, metadata?: Metadata): Promise<FrameWaitForTimeoutResult>;
|
||||
waitForFunction(params: FrameWaitForFunctionParams, metadata?: Metadata): Promise<FrameWaitForFunctionResult>;
|
||||
waitForSelector(params: FrameWaitForSelectorParams, metadata?: Metadata): Promise<FrameWaitForSelectorResult>;
|
||||
}
|
||||
@ -2107,6 +2108,13 @@ export type FrameUncheckOptions = {
|
||||
trial?: boolean,
|
||||
};
|
||||
export type FrameUncheckResult = void;
|
||||
export type FrameWaitForTimeoutParams = {
|
||||
timeout: number,
|
||||
};
|
||||
export type FrameWaitForTimeoutOptions = {
|
||||
|
||||
};
|
||||
export type FrameWaitForTimeoutResult = void;
|
||||
export type FrameWaitForFunctionParams = {
|
||||
expression: string,
|
||||
isFunction?: boolean,
|
||||
@ -3695,6 +3703,7 @@ export const commandsWithTracingSnapshots = new Set([
|
||||
'Frame.textContent',
|
||||
'Frame.type',
|
||||
'Frame.uncheck',
|
||||
'Frame.waitForTimeout',
|
||||
'Frame.waitForFunction',
|
||||
'Frame.waitForSelector',
|
||||
'JSHandle.evaluateExpression',
|
||||
|
@ -1687,6 +1687,12 @@ Frame:
|
||||
snapshot: true
|
||||
pausesBeforeInput: true
|
||||
|
||||
waitForTimeout:
|
||||
parameters:
|
||||
timeout: number
|
||||
tracing:
|
||||
snapshot: true
|
||||
|
||||
waitForFunction:
|
||||
parameters:
|
||||
expression: string
|
||||
|
@ -846,6 +846,9 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
|
||||
timeout: tOptional(tNumber),
|
||||
trial: tOptional(tBoolean),
|
||||
});
|
||||
scheme.FrameWaitForTimeoutParams = tObject({
|
||||
timeout: tNumber,
|
||||
});
|
||||
scheme.FrameWaitForFunctionParams = tObject({
|
||||
expression: tString,
|
||||
isFunction: tOptional(tBoolean),
|
||||
|
@ -1175,6 +1175,13 @@ export class Frame extends SdkObject {
|
||||
}, this._page._timeoutSettings.timeout(options));
|
||||
}
|
||||
|
||||
async waitForTimeout(metadata: CallMetadata, timeout: number) {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
return controller.run(async () => {
|
||||
await new Promise(resolve => setTimeout(resolve, timeout));
|
||||
});
|
||||
}
|
||||
|
||||
async _waitForFunctionExpression<R>(metadata: CallMetadata, expression: string, isFunction: boolean | undefined, arg: any, options: types.WaitForFunctionOptions, world: types.World = 'main'): Promise<js.SmartHandle<R>> {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
if (typeof options.pollingInterval === 'number')
|
||||
|
@ -159,6 +159,7 @@ test('should open simple trace viewer', async ({ showTraceViewer }) => {
|
||||
/page.evaluate— \d+ms/,
|
||||
/page.click"Click"— \d+ms/,
|
||||
/page.waitForNavigation— \d+ms/,
|
||||
/page.waitForTimeout— \d+ms/,
|
||||
/page.gotohttp:\/\/localhost:\d+\/frames\/frame.html— \d+ms/,
|
||||
/page.setViewportSize— \d+ms/,
|
||||
/page.hoverbody— \d+ms/,
|
||||
|
Loading…
Reference in New Issue
Block a user