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: Fix JavaScript handlers in InAppBrowser for Android #2428

Closed

Conversation

fuzzybinary
Copy link

Android InAppBrowserActivity would not call prepareAndAddUserScripts when WebViewFeature.DOCUMENT_START_SCRIPT, which would prevent shims like callHandler from being injected.

Fix this by calling prepareAndAddUserScripts during OnCreate.

Other injections were likely also broken but this is the one I needed.

I also added an integration test for JavaScript handlers in in_app_browser. This test fails without this change on Android emulators 33+.

Connection with issue(s)

Resolve issue #1973

Testing and Review Notes

So far as I can tell, we do not need to wrap prepareAndAddUserScripts to check if WebViewFeature.DOCUMENT_START_SCRIPT is supported to prevent a double call, as addPluginScript does this already.

Android InAppBrowserActivity would not call `prepareAndAddUserScripts` when `WebViewFeature.DOCUMENT_START_SCRIPT`, which would prevent shims like `callHandler` from being injected.

Fix this by calling `prepareAndAddUserScripts` during OnCreate.

Add an integration test for JavaScript handlers in in_app_browser.

refs: pichillilorenzo#1973
@pichillilorenzo
Copy link
Owner

pichillilorenzo commented Nov 26, 2024

This is not related to prepareAndAddUserScripts as it should be called already from InAppWebView.
I found that the issue is related to windowId of InAppBrowserActivity to be not null, actually it is -1 when coming from the Bundle as default value.
Thanks anyway for the help, I'm going to fix it now.

@pichillilorenzo
Copy link
Owner

@all-contributors please add @fuzzybinary for test

Copy link
Contributor

@pichillilorenzo

I've put up a pull request to add @fuzzybinary! 🎉

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.

2 participants