Repository navigation
[android] Add androidInjectedJavaScriptForOrigins prop - #40
Open
brad-discord wants to merge 3 commits into
Open
brad-discord wants to merge 3 commits into
brad-discord wants to merge 3 commits into
Conversation
Exposes androidx.webkit WebViewCompat.addDocumentStartJavaScript so a script can run at document start in every frame whose origin matches allowedOriginRules, including cross-origin iframes. The existing injectedJavaScript* props go through evaluateJavascript and only reach the main frame. The ScriptHandler and config live on the RNCWebView, so a keyed WebView reparented into a new container with an equal config keeps its registration. A changed config replaces the previous script; null removes it. Unsupported WebViews and malformed origin rules log and no-op. Bumps the default androidx.webkit to 1.5.0 (first release with the public ScriptHandler API), which requires compileSdk 32. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ScriptHandler is @RestrictTo(LIBRARY_GROUP) in androidx.webkit before 1.9.0. Its signatures are unchanged from 1.5.0 through 1.13.0, and 1.9.0 requires compileSdk 34, so suppress rather than bump. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…iptForOrigins Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
brad-discord
marked this pull request as ready for review
October 8, 2026 22:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an
androidInjectedJavaScriptForOriginsprop that wrapsWebViewCompat.addDocumentStartJavaScript, so a script can run at document start in cross-origin iframes on Android. Allows us to make Android Activity iframes behave more consistent with iOS.Unlike
injectedJavaScriptBeforeContentLoaded, which on Android is anevaluateJavascriptcall that only reaches the main frame, this registers the script once for every frame whose origin matchesallowedOriginRules. The name mirrors the existing...ForMainFrameOnlyflags to make that scoping difference obvious.