mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
chore: small cleanups around actions (#9895)
This commit is contained in:
parent
94c33da946
commit
b244f035bc
@ -96,7 +96,6 @@ export class FrameExecutionContext extends js.ExecutionContext {
|
||||
${injectedScriptSource.source}
|
||||
return new pwExport(
|
||||
${this.frame._page._delegate.rafCountForStablePosition()},
|
||||
${!!process.env.PWTEST_USE_TIMEOUT_FOR_RAF},
|
||||
"${this.frame._page._browserContext._browser.options.name}",
|
||||
[${custom.join(',\n')}]
|
||||
);
|
||||
|
||||
@ -971,15 +971,6 @@ export class Frame extends SdkObject {
|
||||
return undefined as any;
|
||||
}
|
||||
|
||||
private async _retryWithSelectorIfNotConnected<R>(
|
||||
controller: ProgressController,
|
||||
selector: string, options: types.TimeoutOptions & types.StrictOptions,
|
||||
action: (progress: Progress, handle: dom.ElementHandle<Element>) => Promise<R | 'error:notconnected'>): Promise<R> {
|
||||
return controller.run(async progress => {
|
||||
return this._retryWithProgressIfNotConnected(progress, selector, options.strict, handle => action(progress, handle));
|
||||
}, this._page._timeoutSettings.timeout(options));
|
||||
}
|
||||
|
||||
async click(metadata: CallMetadata, selector: string, options: types.MouseClickOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions) {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
return controller.run(async progress => {
|
||||
@ -997,7 +988,7 @@ export class Frame extends SdkObject {
|
||||
async dragAndDrop(metadata: CallMetadata, source: string, target: string, options: types.DragActionOptions & types.PointerActionWaitOptions & types.NavigatingActionWaitOptions = {}) {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
await controller.run(async progress => {
|
||||
await dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, async handle => {
|
||||
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, async handle => {
|
||||
return handle._retryPointerAction(progress, 'move and down', false, async point => {
|
||||
await this._page.mouse.move(point.x, point.y);
|
||||
await this._page.mouse.down();
|
||||
@ -1007,7 +998,7 @@ export class Frame extends SdkObject {
|
||||
timeout: progress.timeUntilDeadline(),
|
||||
});
|
||||
}));
|
||||
await dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, async handle => {
|
||||
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, async handle => {
|
||||
return handle._retryPointerAction(progress, 'move and up', false, async point => {
|
||||
await this._page.mouse.move(point.x, point.y);
|
||||
await this._page.mouse.up();
|
||||
@ -1036,8 +1027,10 @@ export class Frame extends SdkObject {
|
||||
|
||||
async focus(metadata: CallMetadata, selector: string, options: types.TimeoutOptions = {}) {
|
||||
const controller = new ProgressController(metadata, this);
|
||||
await this._retryWithSelectorIfNotConnected(controller, selector, options, (progress, handle) => handle._focus(progress));
|
||||
await this._page._doSlowMo();
|
||||
await controller.run(async progress => {
|
||||
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, undefined, handle => handle._focus(progress)));
|
||||
await this._page._doSlowMo();
|
||||
}, this._page._timeoutSettings.timeout(options));
|
||||
}
|
||||
|
||||
async textContent(metadata: CallMetadata, selector: string, options: types.QueryOnSelectorOptions = {}): Promise<string | null> {
|
||||
|
||||
@ -66,10 +66,9 @@ export class InjectedScript {
|
||||
private _engines: Map<string, SelectorEngineV2>;
|
||||
_evaluator: SelectorEvaluatorImpl;
|
||||
private _stableRafCount: number;
|
||||
private _replaceRafWithTimeout: boolean;
|
||||
private _browserName: string;
|
||||
|
||||
constructor(stableRafCount: number, replaceRafWithTimeout: boolean, browserName: string, customEngines: { name: string, engine: SelectorEngine}[]) {
|
||||
constructor(stableRafCount: number, browserName: string, customEngines: { name: string, engine: SelectorEngine}[]) {
|
||||
this._evaluator = new SelectorEvaluatorImpl(new Map());
|
||||
|
||||
this._engines = new Map();
|
||||
@ -95,7 +94,6 @@ export class InjectedScript {
|
||||
this._engines.set(name, engine);
|
||||
|
||||
this._stableRafCount = stableRafCount;
|
||||
this._replaceRafWithTimeout = replaceRafWithTimeout;
|
||||
this._browserName = browserName;
|
||||
}
|
||||
|
||||
@ -404,7 +402,7 @@ export class InjectedScript {
|
||||
let samePositionCounter = 0;
|
||||
let lastTime = 0;
|
||||
|
||||
const predicate = (progress: InjectedScriptProgress, continuePolling: symbol) => {
|
||||
return this.pollRaf((progress, continuePolling) => {
|
||||
if (force) {
|
||||
progress.log(` forcing action`);
|
||||
return callback(node, progress, continuePolling);
|
||||
@ -455,12 +453,7 @@ export class InjectedScript {
|
||||
}
|
||||
|
||||
return callback(node, progress, continuePolling);
|
||||
};
|
||||
|
||||
if (this._replaceRafWithTimeout)
|
||||
return this.pollInterval(16, predicate);
|
||||
else
|
||||
return this.pollRaf(predicate);
|
||||
});
|
||||
}
|
||||
|
||||
elementState(node: Node, state: ElementStateWithoutStable): boolean | 'error:notconnected' {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user