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;
|
return;
|
||||||
}
|
}
|
||||||
if (state === 'stable') {
|
if (state === 'stable') {
|
||||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||||
const poll = await this._evaluateHandleInUtility(([injected, node, rafCount]) => {
|
const poll = await this._evaluateHandleInUtility(([injected, node, rafOptions]) => {
|
||||||
return injected.waitForDisplayedAtStablePosition(node, rafCount, false /* waitForEnabled */);
|
return injected.waitForDisplayedAtStablePosition(node, rafOptions, false /* waitForEnabled */);
|
||||||
}, rafCount);
|
}, { rafCount, useTimeout: !!process.env.PW_USE_TIMEOUT_FOR_RAF });
|
||||||
const pollHandler = new InjectedScriptPollHandler(progress, poll);
|
const pollHandler = new InjectedScriptPollHandler(progress, poll);
|
||||||
assertDone(throwRetargetableDOMError(await pollHandler.finish()));
|
assertDone(throwRetargetableDOMError(await pollHandler.finish()));
|
||||||
return;
|
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`);
|
progress.log(` waiting for element to be visible, enabled and not moving`);
|
||||||
else
|
else
|
||||||
progress.log(` waiting for element to be visible and not moving`);
|
progress.log(` waiting for element to be visible and not moving`);
|
||||||
const rafCount = this._page._delegate.rafCountForStablePosition();
|
const rafCount = this._page._delegate.rafCountForStablePosition();
|
||||||
const poll = this._evaluateHandleInUtility(([injected, node, { rafCount, waitForEnabled }]) => {
|
const poll = this._evaluateHandleInUtility(([injected, node, { rafOptions, waitForEnabled }]) => {
|
||||||
return injected.waitForDisplayedAtStablePosition(node, rafCount, waitForEnabled);
|
return injected.waitForDisplayedAtStablePosition(node, rafOptions, waitForEnabled);
|
||||||
}, { rafCount, waitForEnabled });
|
}, { rafOptions: { rafCount, useTimeout: !!process.env.PW_USE_TIMEOUT_FOR_RAF }, waitForEnabled });
|
||||||
const pollHandler = new InjectedScriptPollHandler(progress, await poll);
|
const pollHandler = new InjectedScriptPollHandler(progress, await poll);
|
||||||
const result = await pollHandler.finish();
|
const result = await pollHandler.finish();
|
||||||
if (waitForEnabled)
|
if (waitForEnabled)
|
||||||
|
|
|
||||||
|
|
@ -484,13 +484,13 @@ export class InjectedScript {
|
||||||
input.dispatchEvent(new Event('change', { 'bubbles': true }));
|
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 lastRect: { x: number, y: number, width: number, height: number } | undefined;
|
||||||
let counter = 0;
|
let counter = 0;
|
||||||
let samePositionCounter = 0;
|
let samePositionCounter = 0;
|
||||||
let lastTime = 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
|
// 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
|
// any client rect difference compared to synchronous call. We skip the synchronous call
|
||||||
// and only force layout during actual rafs as a small optimisation.
|
// 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.
|
// Drop frames that are shorter than 16ms - WebKit Win bug.
|
||||||
const time = performance.now();
|
const time = performance.now();
|
||||||
if (rafCount > 1 && time - lastTime < 15)
|
if (rafOptions.rafCount > 1 && time - lastTime < 15)
|
||||||
return continuePolling;
|
return continuePolling;
|
||||||
lastTime = time;
|
lastTime = time;
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ export class InjectedScript {
|
||||||
++samePositionCounter;
|
++samePositionCounter;
|
||||||
else
|
else
|
||||||
samePositionCounter = 0;
|
samePositionCounter = 0;
|
||||||
const isStable = samePositionCounter >= rafCount;
|
const isStable = samePositionCounter >= rafOptions.rafCount;
|
||||||
const isStableForLogs = isStable || !lastRect;
|
const isStableForLogs = isStable || !lastRect;
|
||||||
lastRect = rect;
|
lastRect = rect;
|
||||||
|
|
||||||
|
|
@ -537,7 +537,11 @@ export class InjectedScript {
|
||||||
else if (isDisabled)
|
else if (isDisabled)
|
||||||
progress.logRepeating(` element is disabled - waiting...`);
|
progress.logRepeating(` element is disabled - waiting...`);
|
||||||
return continuePolling;
|
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 } {
|
checkHitTargetAt(node: Node, point: { x: number, y: number }): 'error:notconnected' | 'done' | { hitTargetDescription: string } {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue