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

[WebView] [BUGFIX] onMessage should not break postMessage #18546

Closed
wants to merge 1 commit into from

Conversation

chrmod
Copy link

@chrmod chrmod commented Mar 24, 2018

onMessage handler, replaces original window.postMessage function, so messages being sent by the applications never arrive to their target destinations. Some application like twitter.com are simply broken in such environments.

This PR, changes the implementation of replaced window.postMessage to call the original function in order to prevent website breakage.

Those issues are probably caused by described problem:

I've tested changes on Android and I'm assuming the iOS version should work as well.

Test Plan

Create a WebView component with onMessage handler and url set to https://twitter.com/. Log in to twitter.

With changes of this PR, twitter feed will load correctly. Without changes, no tweets will be loaded.

Release Notes

[WebView] [BUGFIX] - onMessage should not break postMessage

@chrmod chrmod requested a review from shergin as a code owner March 24, 2018 20:20
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@pull-bot
Copy link

pull-bot commented Mar 24, 2018

Warnings
⚠️

📋 Release Notes - This PR may have incorrectly formatted Release Notes.

Generated by 🚫 dangerJS

@react-native-bot react-native-bot added Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted. Component: WebView Related to the WebView component. labels Mar 24, 2018
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 24, 2018
@chrmod
Copy link
Author

chrmod commented Mar 24, 2018

Would it be possible to backport this bugfix to some older releases? I'm interested in 0.53. Not sure what's react-native policy for such changes.

PS. ci/circleci: test_android fails, but I don't this it is related to changes in of this PR.

@facebook-github-bot
Copy link
Contributor

@chrmod I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@facebook-github-bot
Copy link
Contributor

@chrmod I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@andrew--r
Copy link

@shergin Could you please review and merge this PR? It has only two lines of code changed.

@hramos
Copy link
Contributor

hramos commented Aug 9, 2018

WebView PRs are on hold pending approval of the WebView proposal at react-native-community/discussions-and-proposals#3

@RSNara
Copy link
Contributor

RSNara commented Oct 12, 2018

@chrmod, I don't think we support back-porting to earlier version of React Native. 😔

Also, this change is reasonable. I'd love to review and merge this, but can't because we're trying to pull out WebViews into react-native-community/react-native-webview. Since WebViews are eventually going to be deleted from this repository, would you mind re-launching this PR there instead?

Before we exported WebViews, we also launched the new WKWebView implementation of iOS WebViews, which suffer from this exact same problem. 😅 So, you'll have to make a similar fix in RNCWKWebView.m.

@RSNara RSNara closed this Oct 12, 2018
@fungilation
Copy link

fungilation commented Oct 12, 2018

I've written this issue: react-native-webview/react-native-webview#66 for this as a roundup of issues related to 2 way communication between RN<->WebView. Please discuss there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: WebView Related to the WebView component. Missing Changelog This PR appears to be missing a changelog, or they are incorrectly formatted.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants