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

fix: promise support with webFrameMain.executeJavaScript #35292

Merged
merged 2 commits into from Aug 17, 2022

Conversation

deepak1556
Copy link
Member

@deepak1556 deepak1556 commented Aug 10, 2022

Description of Change

Closes #32756.
Closes #32164.

PR changes the backend for WebFrameMain::ExecuteJavaScript to use the version that allows resolving promises before returning the result. Not sure why the previous version which does not support promises https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/render_frame_host_impl.cc;l=2667-2670 was adopted in 704d69a but this aligns the behavior with WebFrame::ExecuteJavaScript.

Was identified when writing tests for #35281

Checklist

Release Notes

Notes: fix enable promise support with webFrameMain.executeJavaScript

@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Aug 10, 2022
@deepak1556 deepak1556 added semver/patch backwards-compatible bug fixes target/20-x-y target/21-x-y PR should also be added to the "21-x-y" branch. labels Aug 10, 2022
Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

Good find! I looked into this a couple months ago and I think the promise resolution behavior is relatively new, added after webFrameMain was introduced.

shell/browser/api/electron_api_web_frame_main.cc Outdated Show resolved Hide resolved
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 11, 2022
@deepak1556 deepak1556 added semver/minor backwards-compatible functionality and removed target/19-x-y semver/patch backwards-compatible bug fixes labels Aug 15, 2022
@electron-cation electron-cation bot added api-review/requested 🗳 new-pr 🌱 PR opened in the last 24 hours labels Aug 15, 2022
@deepak1556 deepak1556 force-pushed the robo/fix_webframemain_executejavascript branch from 3308846 to 4ff0a02 Compare August 15, 2022 06:13
@deepak1556
Copy link
Member Author

Changed from semver/patch to semver/minor since there is change in functionality that api now rejects when result is a failure.

Also removed target/19-x-y since it requires https://chromium-review.googlesource.com/c/chromium/src/+/3651751 to be backported.

Copy link
Member

@samuelmaddock samuelmaddock left a comment

Choose a reason for hiding this comment

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

API LGTM

Copy link
Contributor

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

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

API LGTM

@MarshallOfSound
Copy link
Member

since there is change in functionality that api now rejects when result is a failure.

I'd argue that is reasonably expected behavior, a promise should never be assumed to never reject 🤷

Copy link
Member

@zcbenz zcbenz left a comment

Choose a reason for hiding this comment

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

API LGTM

@deepak1556
Copy link
Member Author

@MarshallOfSound the previous API always resolved to an empty {} even when the script execution fails, given now we resurface the actual error, I was thinking a semver/minor would be appropriate for this change rather than a patch, thoughts ?

@deepak1556 deepak1556 force-pushed the robo/fix_webframemain_executejavascript branch from 4ff0a02 to 52bef14 Compare August 17, 2022 02:05
@deepak1556 deepak1556 merged commit 43182bf into main Aug 17, 2022
@deepak1556 deepak1556 deleted the robo/fix_webframemain_executejavascript branch August 17, 2022 04:08
@release-clerk
Copy link

release-clerk bot commented Aug 17, 2022

Release Notes Persisted

fix enable promise support with webFrameMain.executeJavaScript

@trop
Copy link
Contributor

trop bot commented Aug 17, 2022

I have automatically backported this PR to "20-x-y", please check out #35358

@trop
Copy link
Contributor

trop bot commented Aug 17, 2022

I have automatically backported this PR to "21-x-y", please check out #35359

@trop trop bot added in-flight/21-x-y merged/21-x-y PR was merged to the "21-x-y" branch. and removed target/21-x-y PR should also be added to the "21-x-y" branch. in-flight/21-x-y labels Aug 17, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Aug 23, 2022
schetle pushed a commit to schetle/electron that referenced this pull request Nov 3, 2022
)

* fix: promise support with webFrameMain.executeJavaScript

* chore: reject when result is an error
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
)

* fix: promise support with webFrameMain.executeJavaScript

* chore: reject when result is an error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-review/requested 🗳 merged/21-x-y PR was merged to the "21-x-y" branch. semver/minor backwards-compatible functionality
Projects
None yet
7 participants