Skip to content

fix(ios): respect isInspectable option instead of forcing inspectable webviews - #646

Merged
riderx merged 1 commit into
Cap-go:mainfrom
Swiezu:fix/ios-respect-isinspectable
Aug 4, 2026
Merged

fix(ios): respect isInspectable option instead of forcing inspectable webviews#646
riderx merged 1 commit into
Cap-go:mainfrom
Swiezu:fix/ios-respect-isinspectable

Conversation

@Swiezu

@Swiezu Swiezu commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What

Assigns the isInspectable option to webView.isInspectable in WKWebViewController.initWebview,
instead of the hardcoded true that has been there since 5bba983. When the option is omitted,
it now falls back to the app's webContentsDebuggingEnabled Capacitor config
(bridge.config.isWebDebuggable) rather than a plain false.

Why

initWebview() parses the isInspectable option (documented default: false) and passes it all
the way down, then ignores it and forces webView.isInspectable = true. On iOS 16.4+ that makes
every webview opened with openWebView inspectable via Safari Web Inspector in every build,
including production/App Store ones — so on a shipped app anyone can attach the inspector to in-app
content such as login or payment pages and read the DOM, cookies and network traffic.

The commented-out block right above it (the setInspectable: selector) used the parameter; it was
lost when that selector was swapped for the isInspectable property and replaced with a literal.

Defaulting to bridge.config.isWebDebuggable (rather than false) keeps existing behaviour in debug
builds — Capacitor sets webContentsDebuggingEnabled to true only in DEBUG by default — while
release builds stop being inspectable. This is exactly what Capacitor core does for its own webview
in CapacitorBridge.setupWebDebugging (capacitor/ios), so pages inside the InAppBrowser WebView now
behave like pages in the main Capacitor WebView. Callers passing isInspectable: true explicitly are
unaffected.

Platform parity

  • On Android the plugin's WebView already follows the app's setting: WebView.setWebContentsDebuggingEnabled
    is process-global and Capacitor's Bridge sets it from webContentsDebuggingEnabled (default: the app's
    debuggable flag). iOS was the gap, because isInspectable is a per-WKWebView property the plugin has to
    set itself.
  • Geolocation on iOS is already deferred to the OS by this class (requestGeolocationPermissionFor);
    this mirrors how the main Capacitor WebView resolves inspectability, including the log-line style.

Testing

Verified on an iOS 18 simulator in a Capacitor 8 app (via a local patch), opening a webview without the
isInspectable option and reading WKWebView.isInspectable at runtime:

build before after
debug inspectable inspectable
release inspectable (leak) not inspectable

In the release build the app's own webview was already correctly not inspectable; only the plugin's
webview stayed inspectable, which this change fixes.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Web content inspection now correctly follows the configured debuggability setting when the caller doesn’t explicitly set an option.
    • On supported iOS versions, the web view’s inspection state now respects the provided setting (including for popup/inherited web views) instead of using a fixed default.

@github-actions

Copy link
Copy Markdown
Contributor

Beta npm build

This PR comes from a fork, so beta publish is disabled for security.

If you need a beta package, move the branch into this repository first.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9d5a43e2-0e50-4291-94b0-a9579d82b25f

📥 Commits

Reviewing files that changed from the base of the PR and between d2edc68 and 8dc02b7.

📒 Files selected for processing (2)
  • ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift
  • ios/Sources/InAppBrowserPlugin/WKWebViewController.swift
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

📝 Walkthrough

Walkthrough

The iOS plugin derives WebView inspectability from bridge configuration when unspecified, stores the setting in WKWebViewController, applies it on iOS 16.4+, and propagates it to inherited popup WebViews.

Changes

WebView inspectability configuration

Layer / File(s) Summary
Propagate inspectability through WebView creation
ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift, ios/Sources/InAppBrowserPlugin/WKWebViewController.swift
openWebView uses the bridge debug configuration when isInspectable is omitted; WKWebViewController stores and applies the value, and inherited popup WebViews reuse the parent setting.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: riderx

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main iOS change: honoring the isInspectable option instead of forcing webviews inspectable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ios/Sources/InAppBrowserPlugin/WKWebViewController.swift`:
- Around line 2185-2186: Update inheritPopupPresentation and the related
initWebview flow to persist the parent web view’s resolved isInspectable value
and pass it when initializing managed popups, rather than relying on
initWebview’s default of true. Ensure popups preserve the parent’s
inspectability setting on iOS 16.4 and later.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c1a01d8a-52ad-41c1-81cb-85a0230c5029

📥 Commits

Reviewing files that changed from the base of the PR and between fc82a40 and d2edc68.

📒 Files selected for processing (2)
  • ios/Sources/InAppBrowserPlugin/InAppBrowserPlugin.swift
  • ios/Sources/InAppBrowserPlugin/WKWebViewController.swift
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • Cap-go/capacitor-updater (manual)

Comment thread ios/Sources/InAppBrowserPlugin/WKWebViewController.swift

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread ios/Sources/InAppBrowserPlugin/WKWebViewController.swift
@Swiezu
Swiezu force-pushed the fix/ios-respect-isinspectable branch from d2edc68 to 8dc02b7 Compare July 28, 2026 20:59
@sonarqubecloud

Copy link
Copy Markdown

@Swiezu

Swiezu commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review

@cubic-dev-ai

cubic-dev-ai Bot commented Jul 28, 2026

Copy link
Copy Markdown

@cubic-dev-ai review

@Swiezu I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai 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.

No issues found across 2 files

Re-trigger cubic

@riderx
riderx merged commit d491220 into Cap-go:main Aug 4, 2026
11 checks passed
@Swiezu
Swiezu deleted the fix/ios-respect-isinspectable branch August 4, 2026 13:39
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