Skip to content
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

Merged
merged 38 commits into from
Dec 22, 2020

Conversation

connorjclark
Copy link
Collaborator

ref #10781, #10816

@connorjclark connorjclark requested a review from a team as a code owner December 2, 2020 23:10
@connorjclark connorjclark requested review from adamraine and removed request for a team December 2, 2020 23:10
@google-cla google-cla bot added the cla: yes label Dec 2, 2020
@@ -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>}
Copy link
Collaborator Author

@connorjclark connorjclark Dec 2, 2020

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>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ya thanks 👍

lighthouse-core/gather/gatherers/full-page-screenshot.js Outdated Show resolved Hide resolved
/**
* @param {boolean} useIsolation
*/
function evaluateInPage(useIsolation) {
Copy link
Member

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?

Copy link
Member

@adamraine adamraine left a 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, {
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants