mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
feat(debug): allow using timeout for rafs for throttling debugging
This commit is contained in:
parent
0337928aa3
commit
f5fbea94bb
@ -647,10 +647,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
|
||||
return;
|
||||
}
|
||||
if (state === 'stable') {
|
||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||
const poll = await this._evaluateHandleInUtility(([injected, node, rafCount]) => {
|
||||
return injected.waitForDisplayedAtStablePosition(node, rafCount, false /* waitForEnabled */);
|
||||
}, rafCount);
|
||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||
const poll = await this._evaluateHandleInUtility(([injected, node, rafOptions]) => {
|
||||
return injected.waitForDisplayedAtStablePosition(node, rafOptions, false /* waitForEnabled */);
|
||||
}, { rafCount, useTimeout: !!process.env.PW_USE_TIMEOUT_FOR_RAF });
|
||||
const pollHandler = new InjectedScriptPollHandler(progress, poll);
|
||||
assertDone(throwRetargetableDOMError(await pollHandler.finish()));
|
||||
return;
|
||||
@ -694,10 +694,10 @@ export class ElementHandle<T extends Node = Node> extends js.JSHandle<T> {
|
||||
progress.log(` waiting for element to be visible, enabled and not moving`);
|
||||
else
|
||||
progress.log(` waiting for element to be visible and not moving`);
|
||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||
const poll = this._evaluateHandleInUtility(([injected, node, { rafCount, waitForEnabled }]) => {
|
||||
return injected.waitForDisplayedAtStablePosition(node, rafCount, waitForEnabled);
|
||||
}, { rafCount, waitForEnabled });
|
||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||
const poll = this._evaluateHandleInUtility(([injected, node, { rafOptions, waitForEnabled }]) => {
|
||||
return injected.waitForDisplayedAtStablePosition(node, rafOptions, waitForEnabled);
|
||||
}, { rafOptions: { rafCount, useTimeout: !!process.env.PW_USE_TIMEOUT_FOR_RAF }, waitForEnabled });
|
||||
const pollHandler = new InjectedScriptPollHandler(progress, await poll);
|
||||
const result = await pollHandler.finish();
|
||||
if (waitForEnabled)
|
||||
|
||||
@ -484,13 +484,13 @@ export class InjectedScript {
|
||||
input.dispatchEvent(new Event('change', { 'bubbles': true }));
|
||||
}
|
||||
|
||||
waitForDisplayedAtStablePosition(node: Node, rafCount: number, waitForEnabled: boolean): InjectedScriptPoll<'error:notconnected' | 'done'> {
|
||||
waitForDisplayedAtStablePosition(node: Node, rafOptions: { rafCount: number, useTimeout?: boolean }, waitForEnabled: boolean): InjectedScriptPoll<'error:notconnected' | 'done'> {
|
||||
let lastRect: { x: number, y: number, width: number, height: number } | undefined;
|
||||
let counter = 0;
|
||||
let samePositionCounter = 0;
|
||||
let lastTime = 0;
|
||||
|
||||
return this.pollRaf((progress, continuePolling) => {
|
||||
const predicate = (progress: InjectedScriptProgress, continuePolling: symbol) => {
|
||||
// First raf happens in the same animation frame as evaluation, so it does not produce
|
||||
// any client rect difference compared to synchronous call. We skip the synchronous call
|
||||
// and only force layout during actual rafs as a small optimisation.
|
||||
@ -505,7 +505,7 @@ export class InjectedScript {
|
||||
|
||||
// Drop frames that are shorter than 16ms - WebKit Win bug.
|
||||
const time = performance.now();
|
||||
if (rafCount > 1 && time - lastTime < 15)
|
||||
if (rafOptions.rafCount > 1 && time - lastTime < 15)
|
||||
return continuePolling;
|
||||
lastTime = time;
|
||||
|
||||
@ -518,7 +518,7 @@ export class InjectedScript {
|
||||
++samePositionCounter;
|
||||
else
|
||||
samePositionCounter = 0;
|
||||
const isStable = samePositionCounter >= rafCount;
|
||||
const isStable = samePositionCounter >= rafOptions.rafCount;
|
||||
const isStableForLogs = isStable || !lastRect;
|
||||
lastRect = rect;
|
||||
|
||||
@ -537,7 +537,11 @@ export class InjectedScript {
|
||||
else if (isDisabled)
|
||||
progress.logRepeating(` element is disabled - waiting...`);
|
||||
return continuePolling;
|
||||
});
|
||||
};
|
||||
if (rafOptions.useTimeout)
|
||||
return this.pollInterval(16, predicate);
|
||||
else
|
||||
return this.pollRaf(predicate);
|
||||
}
|
||||
|
||||
checkHitTargetAt(node: Node, point: { x: number, y: number }): 'error:notconnected' | 'done' | { hitTargetDescription: string } {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user