Skip to content

[android] Add androidInjectedJavaScriptForOrigins prop - #40

Open
brad-discord wants to merge 3 commits into
11.18.1-discord-1from
brad.buchanan/document-start-script
Open

brad-discord wants to merge 3 commits into
11.18.1-discord-1from
brad.buchanan/document-start-script

Conversation

@brad-discord

@brad-discord brad-discord commented Oct 8, 2026 •

Copy link
Copy Markdown

Adds an androidInjectedJavaScriptForOrigins prop that wraps WebViewCompat.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 an evaluateJavascript call that only reaches the main frame, this registers the script once for every frame whose origin matches allowedOriginRules. The name mirrors the existing ...ForMainFrameOnly flags to make that scoping difference obvious.

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>
brad-discord and others added 2 commits October 8, 2026 11:05
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 brad-discord changed the title [android] Add androidDocumentStartScript prop [android] Add androidInjectedJavaScriptForOrigins prop Oct 8, 2026
@brad-discord
brad-discord marked this pull request as ready for review October 8, 2026 22:57

@DV8FromTheWorld DV8FromTheWorld left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

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