Skip to content

Conversation

@patrickhulce
Copy link
Collaborator

@patrickhulce patrickhulce commented Dec 19, 2016

R: @brendankenny

Fixes evaluateAsync behavior when zone.js has mucked with Promise.
Adds zone.js to the smoke tests so regression won't happen again.

Addresses #1173

Fixes evaluateAsync behavior when [zone.js](https://github.com/angular/zone.js) has mucked with Promise.
Adds zone.js to the smoke tests so regression won't happen again.

Addresses #1177.
Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

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


this.sendCommand('Runtime.evaluate', {
// We need to wrap the raw expression for several purposes
// We need to expliticly wrap the raw expression for several purposes:
Copy link
Contributor

Choose a reason for hiding this comment

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

explicitly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, done :)

@brendankenny
Copy link
Contributor

Should we bring in zones via npm?

Looks like you didn't have to modify @patrickhulce, so this could work this time?

@patrickhulce
Copy link
Collaborator Author

yeah true I didn't this time around, will fix

const thirdPartyPath = '../../../lighthouse-core/third_party';
absoluteFilePath = path.join(__dirname, `${thirdPartyPath}/promise-polyfill/promise.js`);
// We bring in an aggressive Promise polyfill (zone) to ensure we don't still fail.
const zonePath = '../../../node_modules/zone.js';
Copy link
Contributor

Choose a reason for hiding this comment

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

'../../../node_modules/`

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ebidel not sure what you're requesting here, to change zonePath to nodeModule path?

Copy link
Contributor

Choose a reason for hiding this comment

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

OH nvm. This is probably where it gets installed. Just looks funny from a reviewer's perspective :)

Copy link
Contributor

Choose a reason for hiding this comment

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

All 👍

.then(_ => ${expression})
.catch(${wrapRuntimeEvalErrorInBrowser.toString()})
.then(resolve);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried a few permutations of this and it looks like this is about the only decent one that works :) Reason in #1173 (comment).

For anyone following along, the nice thing about this form is that it lets the polyfill handle resolving to a value (or error), and then all we have to assume is that our __nativePromise constructor is intact, not our earlier assumption that its prototype chain had also not been altered

Copy link
Contributor

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

Looks great. Nice detective work.

@brendankenny brendankenny merged commit 54fe456 into master Dec 19, 2016
@brendankenny brendankenny deleted the fix_promise_polyfill_again branch December 19, 2016 23:29
andrewrota pushed a commit to andrewrota/lighthouse that referenced this pull request Jan 13, 2017
…Chrome#1178)

* Fix `driver.evaluateAsync` behavior when [zone.js](https://github.com/angular/zone.js) has mucked with Promise.

* Add zone.js to the smoke tests so regression won't happen again.

* Remove old testing promise-polyfill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants