Skip to content

feat: send top frame URL with iframe events#37

Merged
jkadamczyk merged 1 commit intomasterfrom
kuba/add-top-frame-url
Mar 5, 2026
Merged

feat: send top frame URL with iframe events#37
jkadamczyk merged 1 commit intomasterfrom
kuba/add-top-frame-url

Conversation

@jkadamczyk
Copy link
Copy Markdown

@jkadamczyk jkadamczyk commented Mar 4, 2026

This pull request adds a new property that is sent with iframe events.
In the past, we already added a way to differentiate between top frame and iframe events.
This PR also adds top frame URL.

Summary by CodeRabbit

  • New Features
    • WebView message events now include top frame URL information, providing enhanced context about the origin of messages across Android, iOS, and TypeScript implementations.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5b4499f-7fa9-4543-a692-ea32f2cb06d0

📥 Commits

Reviewing files that changed from the base of the PR and between 33f960b and 766d5f2.

📒 Files selected for processing (5)
  • android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
  • apple/RNCWebView.mm
  • apple/RNCWebViewImpl.m
  • src/RNCWebViewNativeComponent.ts
  • src/WebViewTypes.ts

📝 Walkthrough

Walkthrough

The changes add a new optional topFrameUrl property to message events across Android, iOS, and TypeScript layers. This field captures the URL of the top frame when messages are handled, propagating it through the existing messaging infrastructure without altering control flow.

Changes

Cohort / File(s) Summary
Android WebView Message Handling
android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
Introduces a four-parameter onMessage overload accepting topFrameUrl, updates existing overloads to delegate to it with appropriate nulls, and includes topFrameUrl in event emissions. WebMessageListener and RNCWebViewBridge now pass the current view URL as topFrameUrl.
iOS Event Structure
apple/RNCWebView.mm, apple/RNCWebViewImpl.m
Adds topFrameUrl field to the OnMessage struct and extracts/includes the top frame URL in message event payloads from WKUserContentController handlers.
TypeScript Type Definitions
src/RNCWebViewNativeComponent.ts, src/WebViewTypes.ts
Adds optional topFrameUrl?: string property to WebViewMessageEvent and WebViewMessage interfaces to reflect the new field in the message event payload.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding topFrameUrl propagation through the webview messaging system across all platforms (Android, iOS, and TypeScript types).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kuba/add-top-frame-url

Comment @coderabbitai help to get the list of available commands and usage tips.

@jkadamczyk jkadamczyk requested review from a team and tian000 March 4, 2026 18:32
@jkadamczyk jkadamczyk merged commit fa84f40 into master Mar 5, 2026
19 checks passed
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