-
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
Migrate evaluateAsync to Runtime.evaluate(awaitPromise) #793
Conversation
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.
We were waiting until m54 hit stable to do this (#580), but as of this week, 54 is the new stable. \o/
There's a few issues that travis picked up in the PR:
https://travis-ci.org/GoogleChrome/lighthouse/jobs/168801013#L290
Aside from those, this is looking on point. Excited to simplify this stuff.
Made the tests happy |
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.
just a few things, half of which are fixing up what the code should have already been doing :)
// If this gets to 60s and it hasn't been resolved, reject the Promise. | ||
asyncTimeout = setTimeout( | ||
let asyncTimeout = setTimeout( |
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.
const
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.
Done.
}); | ||
axe.a11yCheck(document, fulfill); | ||
return result; |
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.
rather than expose the resolve
function external to the promise, you could instead do
function runA11yChecks() {
return new Promise((resolve, reject) => {
axe.a11yCheck(document, resolve);
});
}
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.
Done. We are using single line callback -> Promise conversion in devtools, but with your linting it does not fit a line, so your version works better in your source base.
}); | ||
}).catch(_ => { | ||
__returnResults(undefined); | ||
// Empty catch |
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.
while you're changing this, maybe we should just drop the catch
handler here? It isn't providing additional feedback and a rejected promise from evaluateAsync
is caught in afterPass
anyways
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.
Done.
@@ -146,48 +146,20 @@ class Driver { | |||
|
|||
evaluateAsync(asyncExpression) { |
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.
While you're in here, would you mind adding a doc string? Maybe something like
/**
* Evaluate an expression in the context of the current page. Expression must
* evaluate to a Promise. Returns a promise that resolves on asyncExpression's
* resolved value.
* @param {string} asyncExpression
* @return {!Promise<*>}
*/
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.
Done.
when does m54 go 100%? End of the week? |
9268134
to
f605c50
Compare
M54 is rolling out today so should be a few days. I've heard it occasionally takes up to a week to fully ramp up to 100% but given this is master and we're not tagging a release anytime soon, it seems okay to land. |
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. We can wait for @paulirish's +1 before merging
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.
So good.
edit by paulirish: fixes #580