-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: replace most usages of evaluateAsync with structured evaluate #11754
Conversation
@@ -484,7 +489,7 @@ class Driver { | |||
* @param {{args: T, useIsolation?: boolean, deps?: Array<Function|string>}} options `args` should | |||
* match the args of `mainFn`, and can be any serializable value. `deps` are functions that must be | |||
* defined for `mainFn` to work. | |||
* @return {Promise<R>} | |||
* @return {FlattenedPromise<R>} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise results in Promise<Promise<...>>
, given some main functions (first arg to evaluate
) return promises. see microsoft/TypeScript#27711 (comment) for more
@@ -26,6 +26,7 @@ declare global { | |||
export interface FRTransitionalDriver { | |||
defaultSession: FRProtocolSession; | |||
evaluateAsync(expression: string, options?: {useIsolation?: boolean}): Promise<any>; | |||
evaluate<T extends any[], R>(mainFn: (...args: T) => R, options: {args: T, useIsolation?: boolean, deps?: Array<Function|string>}): FlattenedPromise<R>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickhulce ya?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya thanks 👍
/** | ||
* @param {boolean} useIsolation | ||
*/ | ||
function evaluateInPage(useIsolation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding another evaluate function seems unnecessary. I think it's better to just use
passContext.driver.evaluate
twice.
Bump, WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
||
/** @type {LH.Artifacts['IFrameElements']} */ | ||
const iframeElements = await driver.evaluateAsync(expression, {useIsolation: true}); | ||
const iframeElements = await driver.evaluate(collectIFrameElements, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yikes! almost missed this. forgot to include useIsolation: true
.
ref #10781, #10816