Skip to content

feat(paywalls): web_view navigation/origin policy (3/7)#7229

Merged
ajpallares merged 14 commits into
mainfrom
webview/3-isolation-navigation
Jul 21, 2026
Merged

feat(paywalls): web_view navigation/origin policy (3/7)#7229
ajpallares merged 14 commits into
mainfrom
webview/3-isolation-navigation

Conversation

@JZDesign

@JZDesign JZDesign commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

Part 3 of 7 splitting #7183; inert until Part 7. Lands the navigation/origin policy so the later session and view can share one origin helper.

Description

Adds WebViewOriginPolicy (WebViewOrigin + WebViewNavigationPolicy) with origin normalization and navigation coverage (default port stripped, non-default kept, case-insensitive, empty host → nil; origin check enforced on sub-frames too).

Content-blocking rules are intentionally omitted: the bundle's served CSP (default-src 'self', per-bundle origin) already blocks cross-origin resource and document loads more completely. CSP has no directive covering top-level navigation, so the origin lock stays.

Independent of Parts 1–2. No render-pipeline wiring until Part 7.

PR Plan

PWENG-99

Part PR Branch Base
1/7 #7227 webview/1-public-api main
2/7 #7228 webview/2-envelope webview/1-public-api (retarget to main after I1)
3/7 #7229 webview/3-isolation-navigation main
4/7 #7230 webview/4-schema main
5/7 #7231 webview/5-session webview/deps-123 (retarget after I1–I3)
6/7 #7232 webview/6-view webview/deps-45 (retarget after I4–I5)
7/7 #7233 webview/7-activate webview/deps-6 (retarget after I6)
Open in Web Open in Cursor 

…3/7)

Extract origin normalization, main-frame navigation policy, and WK content
rule isolation as inert helpers used by later session/view PRs.

Co-authored-by: Jacob Rakidzich <Jacob@JacobZivanDesign.com>
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewOriginPolicy.swift Outdated

@ajpallares ajpallares 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.

Some more comments

Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
Comment thread Tests/RevenueCatUITests/PaywallsV2/WebViewIsolationTests.swift Outdated
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
ajpallares and others added 3 commits July 20, 2026 11:07
Merge the content-blocking rule into a single item and extend the
third-party block list (style-sheet, media, document). Make
contentBlockingRules a non-optional constant, move import WebKit inside
the platform guard, and add coverage: real WKContentRuleListStore
compilation, http:80 default-port stripping, and adversarial navigation
cases (nil URL, scheme downgrade, port mismatch).

Co-authored-by: Cursor <cursoragent@cursor.com>
…avigation

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	RevenueCat.xcodeproj/project.pbxproj
Comment thread RevenueCatUI/Templates/V2/Components/WebView/WebViewIsolation.swift Outdated
Apply the origin check to every frame so cross-origin sub-frames are
cancelled (defense-in-depth alongside the content rules), and split the
two combined navigation-policy tests into one clearly-named test per case.

Co-authored-by: Cursor <cursoragent@cursor.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b3e0f35. Configure here.

ajpallares and others added 3 commits July 20, 2026 14:13
A compile failure means the WebView runs without third-party isolation,
so surface it at error level instead of debug where it would be invisible
in production.

Co-authored-by: Cursor <cursoragent@cursor.com>
Normalize both the URL origin and expectedOrigin before comparing so a
non-canonical expectedOrigin (mixed case or explicit default port) no
longer cancels legitimate same-origin navigations. An unparseable or
host-less expectedOrigin still fails closed.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ajpallares
ajpallares requested a review from AlvaroBrey July 20, 2026 13:50
@ajpallares ajpallares added pr:other and removed pr:feat A new feature labels Jul 20, 2026

@AlvaroBrey AlvaroBrey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! no notes on this one, if we keep the rules

The bundle's served CSP (default-src 'self', per-bundle origin) already
blocks cross-origin resource and document loads more completely than the
WKContentRuleList did (it also covers stylesheets, media, WebSockets and
workers), so the SDK-side content rules were redundant. The navigation
origin-lock is kept: CSP has no directive that gates top-level navigation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ajpallares ajpallares changed the title feat(paywalls): web_view navigation policy + content-rule isolation (3/7) feat(paywalls): web_view navigation/origin policy (3/7) Jul 20, 2026
The origin check runs on every frame identically, so `isMainFrame` was
never read. Remove it, drop the now-redundant sub-frame tests, and trim
comments to current behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ajpallares
ajpallares requested a review from AlvaroBrey July 20, 2026 18:25
ajpallares and others added 2 commits July 20, 2026 21:53
Restore `isMainFrame` and align the origin policy with purchases-android
(#3783): block non-https on any frame, block cross-origin only on the main
frame, and leave cross-origin sub-frame isolation to the server-provided CSP
(`frame-src` falls back to `default-src 'self'`).

Co-authored-by: Cursor <cursoragent@cursor.com>
@ajpallares

Copy link
Copy Markdown
Member

@RCGitBot please test

…to webview/3-isolation-navigation

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	RevenueCat.xcodeproj/project.pbxproj
@ajpallares
ajpallares enabled auto-merge (squash) July 21, 2026 07:35
@ajpallares
ajpallares merged commit 9fab1d6 into main Jul 21, 2026
19 of 20 checks passed
@ajpallares
ajpallares deleted the webview/3-isolation-navigation branch July 21, 2026 07:46
ajpallares added a commit that referenced this pull request Jul 21, 2026
Retarget Part 5 onto main now that Parts 1-3 (#7227, #7228, #7229) are merged.

Resolve conflicts by keeping main's canonical Part 1-3 files (PaywallWebViewValue,
WebViewEnvelope, WebViewOriginPolicy and their tests) and dropping stale
deps-123 artifacts (PaywallWebViewAPI.swift, WebViewIsolation.swift and its test,
plus the now-unused content_rules_failed log string). Part 5's own additions
(WebViewSession + tests, log strings) are preserved.

Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants