Repository Public License
1# What WKWebView cannot do (or does differently from Safari)23ORIX Navigator renders the web with `WKWebView` and **public API only**. This page lists what that implies, the4fallback the browser uses, and how each statement was established.56Legend for the "Basis" lines:78- **Header** — read in the WebKit / AuthenticationServices headers of the Xcode 27.2 SDKs (macOS 27.2, iOS 27.2).9- **Test** — exercised by `Tests/WebRuntimeTests` on macOS 27.0 against the local fixture server.10- **Apple docs / known behaviour** — documented by Apple or long-standing WebKit behaviour; **not verified in this11 repository**. Treat it as a claim to confirm before relying on it.1213---1415## 1. Extensions1617- Safari's extensions (Safari Web Extensions, Safari App Extensions, Safari content blockers installed from the18 App Store) belong to Safari. A `WKWebView` in another app does not load them and there is no API to enumerate19 or enable them.20- Since macOS 15.4 / iOS 18.4 WebKit ships a public **`WKWebExtension` / `WKWebExtensionController`** API21 (`WKWebViewConfiguration.webExtensionController`) that lets an app load and run WebExtensions it manages22 itself: the app must implement the tabs/windows model (`WKWebExtensionTab`, `WKWebExtensionWindow`), the23 permission prompts and the toolbar UI. Nothing is inherited from Safari.24- **Fallback in ORIX Navigator:** content blocking is done with `WKContentRuleList` (compiled by25 `ContentRuleListCompiler`, attached per profile); user styles through Morph (CSS only, isolated world); user26 scripts through `WebEngine.installUserScript` (isolated worlds only). A `WKWebExtensionController` host is not27 implemented in WebRuntime.28- Basis: Header (`WKWebExtension*.h`, availability `macos(15.4), ios(18.4)`); content rule lists: Test.2930## 2. DRM / Encrypted Media Extensions3132- WebKit implements EME with **FairPlay Streaming** only. Widevine and PlayReady are not available, so services33 that offer only those key systems will not play protected video. There is no API to add a CDM.34- `WKWebsiteDataTypeMediaKeys` exists to list/remove stored media keys (exposed as `WebsiteDataKind.mediaKeys`).35- **Fallback:** none possible. The UI should surface the page's own "unsupported browser" message; do not spoof a36 Chrome user agent to hide it, playback would still fail.37- Basis: `WKWebsiteDataTypeMediaKeys` — Header. Key-system support — Apple docs / known behaviour, not verified.3839## 3. Passkeys / WebAuthn4041- A page's `navigator.credentials.create/get` inside `WKWebView` is handled by the system only when the embedding42 app is entitled for it. A general-purpose browser needs Apple's **web-browser entitlement**43 (`com.apple.developer.web-browser`, granted on request; on iOS it is also the default-browser entitlement) so44 that WebKit accepts WebAuthn for arbitrary relying parties. Without it, WebAuthn in a web view is limited to45 domains the app is associated with (`webcredentials:` Associated Domains).46- AuthenticationServices additionally offers a browser-specific API,47 `ASAuthorizationWebBrowserPublicKeyCredentialManager` and the `ASAuthorizationWebBrowser…` request types48 (macOS 13.3, iOS 17.4), for browsers that run the WebAuthn ceremony themselves; it requires its own entitlement49 (`com.apple.developer.web-browser.public-key-credential` per Apple's documentation) and a user authorisation50 (`requestAuthorizationForPublicKeyCredentials`).51- Passkeys created in Safari live in the user's credential provider (iCloud Keychain or a third-party one), so52 they are usable from an entitled browser; a non-entitled build simply gets `NotAllowedError`.53- **Fallback:** WebRuntime does nothing special: with the entitlement WebKit shows the system sheet; without it54 the page's WebAuthn calls fail and the site falls back to its password flow.55- Basis: existence and availability of the `ASAuthorizationWebBrowser…` API — Header. Entitlement names and56 WKWebView behaviour with/without them — Apple docs, **not verified** (the test host is an unsigned process).5758## 4. Default browser5960- **iOS / iPadOS:** an app can be chosen as default browser only with the managed entitlement61 `com.apple.developer.web-browser`, requested from Apple, and by declaring the `http`/`https` URL schemes.62 The entitlement comes with rules (no `UIWebView`, must open any URL, etc.).63- **macOS:** no entitlement. The app declares `http`/`https` in `CFBundleURLTypes` (and HTML document types) and64 asks the system to become the handler (`NSWorkspace.setDefaultApplication(at:toOpenURLsWithScheme:)`); the65 system shows its own confirmation.66- Related: on iOS the same entitlement is what unlocks service workers and WebAuthn for arbitrary sites (§3, §7).67- Basis: Apple docs, **not verified** here (nothing in WebRuntime depends on it).6869## 5. Geolocation7071- **OS 27 and later:** `WKUIDelegate` has `webView(_:requestGeolocationPermissionFor:initiatedBy:)`72 (`macos(27.0), ios(27.0)`). WebRuntime implements it and routes it through `PermissionProvider` /73 `WebEngineUIDelegate` like camera and microphone (`PermissionKind.location`, keyed by the top-level origin).74- **Before OS 27** (the package still deploys to macOS 15 / iOS 18): there is no public per-origin delegate.75 WebKit decides by itself: the app's own CoreLocation authorisation is required first76 (`NSLocationWhenInUseUsageDescription`), then WebKit presents its own per-site prompt. The browser can neither77 restyle that prompt, nor remember "always allow / never" in its own permission store, nor revoke it per site.78 ORIX Navigator's site-permission UI must therefore present "location" as *managed by the system* on OS 15–26.79- The decision is made by WebKit, the position by CoreLocation: the app must hold the location authorisation in80 both cases, and a ghost profile gets no special treatment from the system prompt on old systems.81- Basis: delegate method and availability — Header; the routing logic (`resolvePermission`) — Test; the WebKit →82 delegate hop and the pre-27 behaviour — **not verified** (needs a visible window and location services).8384## 6. Web Push and notifications8586- `WKWebView` exposes no API for the Push API or for Web Notifications permission. On iOS/iPadOS Web Push exists87 only for web apps added to the Home Screen; on macOS it is a Safari feature. Pages in a third-party browser's88 `WKWebView` see `Notification.permission === "denied"` / no `PushManager`.89- **Fallback:** none. `PermissionKind.notifications` exists in the core model but WebRuntime never asks for it;90 the UI should not offer it as a grantable site permission.91- Basis: no notification or push symbol in the WebKit headers (searched) — Header. Runtime behaviour — Apple92 docs, **not verified**.9394## 7. Service workers and App-Bound Domains9596- On iOS/iPadOS, service workers run in `WKWebView` only for (a) apps holding the web-browser entitlement, or97 (b) domains listed under `WKAppBoundDomains` in Info.plist with98 `WKWebViewConfiguration.limitsNavigationsToAppBoundDomains = true` — a mode meant for single-site apps, which99 restricts navigation to at most ten domains and is useless for a browser. WebRuntime leaves the flag off.100- Consequence without the entitlement on iOS: no offline web apps, no background sync, `navigator.serviceWorker`101 absent or rejecting. Service-worker registrations that do exist are listed and removed through102 `WebsiteDataKind.serviceWorkers`.103- **Fallback:** ship with the entitlement. Offline reading is covered natively by the archive feature104 (`webArchiveData()` / `pdfData()`), not by service workers.105- Basis: `limitsNavigationsToAppBoundDomains`, `WKErrorNavigationAppBoundDomain`,106 `WKWebsiteDataTypeServiceWorkerRegistrations` — Header. Entitlement gating and macOS behaviour — Apple docs,107 **not verified**.108109## 8. Downloads and resume110111- Downloads are `WKDownload` objects obtained by answering `.download` to a navigation action/response, or with112 `startDownload(using:)`. There is no pause: "pause" is `cancel` that returns **resume data**, and "resume" is113 `resumeDownload(fromResumeData:)`. Resume data exists only when the server allows it (range requests and a114 validator such as `ETag`); otherwise the download restarts from zero.115- WebKit refuses a destination that already exists and requires the directory to exist; the destination is116 chosen once, in `decideDestinationUsing`. A resumed download keeps writing to the file named in the resume117 data and does not ask again.118- Progress is an `NSProgress` (`WKDownload.progress`); there is no per-chunk delegate and no speed estimate.119- Downloads are tied to the web view/process that created them: closing the profile session cancels them120 (`WebProfileRegistry.endGhostSession`). iOS 18.2+ adds placeholder files (`decidePlaceholderPolicy`), not used.121- `blob:` and `data:` URLs can be downloaded (`<a download>`); they are never shown as top-level documents.122- **Implementation:** `DownloadCoordinator` → `DownloadSink` (NavigatorCore). Without a sink downloads are123 cancelled.124- Basis: Header; attachment, unknown MIME type, `download` attribute, progress, cancel with resume data and125 resume from byte N against a range-capable server — Test.126127## 9. Picture in Picture and fullscreen128129- iOS: `WKWebViewConfiguration.allowsPictureInPictureMediaPlayback` (default on) and130 `allowsInlineMediaPlayback`. PiP that survives leaving the app needs the app's audio background mode.131- macOS: no public switch; PiP is available from the video's own controls / the page's132 `webkitSetPresentationMode`. The browser cannot start PiP for a tab from native UI.133- Element fullscreen: `WKPreferences.isElementFullscreenEnabled` and `WKWebView.fullscreenState`. While an134 element is fullscreen WebKit moves the web view into its own window and leaves a placeholder in the app's135 hierarchy; `WebViewContainerView` does not re-parent the view in that state.136- `closeAllMediaPresentations()` leaves PiP and fullscreen programmatically.137- Basis: Header. Not exercised by tests (media does not play in an off-screen test web view, see §12).138139## 10. Web Inspector140141- `WKWebView.isInspectable` (macOS 13.3 / iOS 16.4, default off) only makes the page *appear* in Safari's142 Develop menu, on the same Mac or on a Mac connected to the device. There is no API to embed the inspector, to143 open it programmatically, or to read the console, network log or DOM tree.144- **Fallback (Dev module):** uncaught errors, unhandled rejections, failed resource loads and CSP violations are145 captured from an isolated world; `console.*` output is mirrored only on demand by the single bundled script146 that runs in the page world (`dev-console.js`), through a write-only handler that accepts display text and147 nothing else. No network panel is possible from public API.148- Basis: Header; capture, mirroring and the handler's confinement — Test.149150## 11. Printing, PDF, archives, snapshots151152- macOS: `printOperation(with:)` returns an `NSPrintOperation` whose view has an empty frame; it must be given a153 frame and run with `runModal(for:…)` on a window (`WebEngine.makePrintOperation` / `print(in:)`). Running it154 synchronously with `run()` is reported not to work for web content (known behaviour, not verified here).155- iOS: `UIPrintInteractionController` with `viewPrintFormatter()`. No headers/footers API on either platform156 beyond `WKPreferences.shouldPrintBackgrounds`.157- `createPDF` captures a rectangle of the *document as laid out on screen*, not a paginated print rendering.158- `createWebArchiveData` contains what WebKit has loaded; resources never fetched (lazy images, blocked frames)159 are missing. `takeSnapshot` only captures the visible viewport.160- Basis: Header; PDF, web archive, snapshot and creation of the print operation — Test. Actually printing —161 **not verified** (it would open a print sheet on the owner's Mac).162163## 12. Media state, mute, and visibility164165- **No public "is playing audio"** property and **no public page mute** on `WKWebView` (searched the headers:166 only `pauseAllMediaPlayback`, `setAllMediaPlaybackSuspended`, `requestMediaPlaybackState` and the camera /167 microphone capture states exist).168- **Fallback:** `media-state.js` watches `<audio>`/`<video>` elements from an isolated world and reports169 playing/audible counts; `WebEngine.setMuted` mutes those elements, keeps new ones muted, and restores only170 what it muted. **Gaps, by construction:** elements never attached to the document (`new Audio().play()`) and171 Web Audio (`AudioContext`) are invisible from an isolated world, so such a tab shows no speaker badge and is172 not silenced by tab mute. `pauseAllMedia()` (WebKit's own `pauseAllMediaPlayback`) is the tool for those.173- WebKit neither loads nor plays media in a document that is not visible, and delivers `getUserMedia` requests174 only to visible documents. A web view that is not in an on-screen window is hidden: prerendered or175 background-created tabs will not start audio until shown.176- Basis: absence of API — Header; mute plumbing — Test; hidden-document behaviour — Test (observed:177 `document.hidden === true`, `networkState` stays `NO_SOURCE`, `play()` stays pending). Detection of *playing*178 audio and the capture permission prompt end to end — **not verified** (they need a visible window).179180## 13. Find in page181182- `find(_:configuration:)` returns only `matchFound`. No match count, no index, no "highlight all", no API to183 clear the highlight. iOS has the system find bar (`findInteraction`), with its own UI.184- **Fallback:** `WebEngine.find` adds a count computed from the main document's rendered text (sub-frames not185 counted, capped at 9 999); `clearFind` removes the selection WebKit left on the last match.186- Basis: Header (`WKFindResult` has one property); behaviour — Test.187188## 14. Zoom and text size189190- `pageZoom` (whole-page, reflowing) is public on both platforms; `magnification` (pinch) on macOS.191- **Text-only zoom** has no public API. iOS honours `-webkit-text-size-adjust`, used by192 `setTextSizePercent`; that property is an iOS feature of WebKit, so on macOS the call throws instead of193 pretending, and the UI must offer page zoom only.194- Basis: absence of API — Header; the macOS call refusing — Test; the effect of the property on either platform195 — **not verified** (iOS code is compiled, not run).196197## 15. Desktop / mobile site198199- `WKWebpagePreferences.preferredContentMode` switches layout heuristics *and* the user agent on iOS/iPadOS. On200 macOS there is no mobile mode: WebRuntime sets `customUserAgent` to an iPhone Safari string for201 `UserAgentMode.mobile`. `applicationNameForUserAgent` is set to Safari's suffix (`Version/x Safari/605.1.15`)202 because many sites sniff for it.203- Basis: Header; user agents actually sent on macOS in each mode — Test.204205## 16. Popups and user gestures206207- WebKit does not tell the app whether `window.open` came from a user gesture (`WKNavigationAction` has no such208 public property). With `javaScriptCanOpenWindowsAutomatically = false` WebKit drops gesture-less popups itself209 without calling the UI delegate (known behaviour, not verified here), so they could not be counted or offered210 to the user.211- **Fallback:** the setting stays on and WebRuntime applies the policy itself: an isolated-world script reports212 *trusted* input events (`event.isTrusted`), and a `window.open` within `popupActivationWindow` (1.5 s) of one213 is treated as user-initiated. An activated `target=_blank` link always opens. The site's `popups` permission214 overrides: *allow* opens everything, *deny* blocks scripted windows even after a click.215- Limits: the heuristic is time-based, not WebKit's exact transient-activation state; a popup opened after a216 long asynchronous step following a click is blocked (and listed in `blockedPopups`, where the user can open it).217- A child created for `window.open` must use the configuration WebKit supplies. That configuration shares the218 opener's `WKUserContentController`; WebRuntime replaces it so that each tab has its own bridge.219- Basis: Header; blocked/allowed/permission cases, own controller for the child, `window.opener` preserved — Test.220 A real click (trusted event) — **not verified** (cannot be synthesised through public API).221222## 17. Context menus223224- macOS: the only hook is `NSView.willOpenMenu(_:with:)` on a `WKWebView` subclass. WebKit gives no description225 of the clicked element; item identifiers (`WKMenuItemIdentifier…`) are readable but undocumented.226 WebRuntime has the page report the element (`context-element.js`) just before the menu is built.227- iOS: `contextMenuConfigurationFor` provides only `linkURL` (`WKContextMenuElementInfo`); images and selections228 get WebKit's default menus. Returning `nil` shows no menu.229- Basis: Header; delegate plumbing — Test. A real right-click / long-press — **not verified**.230231## 18. Certificates and TLS232233- The certificate chain of a failed connection is only observable inside the authentication challenge.234 WebRuntime evaluates the trust there, **cancels** on failure, and publishes a `CertificateError`; there is no235 path to "proceed" except an explicit, in-memory, per-host, per-certificate `CertificateException`.236- `WKWebView.serverTrust` gives the chain of the committed page; no API reports the negotiated TLS version or237 cipher, certificate transparency, or per-sub-resource chains.238- HTTPS-only: `WKWebpagePreferences.preferredHTTPSNavigationPolicy` exists from macOS 15.2 / iOS 18.2 only; the239 package deploys lower, so the upgrade is done in the navigation policy (one code path on every OS).240- Basis: Header; invalid certificate end to end with a self-signed TLS fixture, exception binding, HTTPS-only241 failure and fallback — Test. Expired / wrong-host / revoked certificates on a live connection — **not242 verified** end to end (the decision function is unit-tested).243244## 19. Processes and lifecycle245246- `WKProcessPool` is deprecated and ignored since macOS 12 / iOS 15: the app cannot choose which pages share a247 web content process. Isolation between profiles comes from `WKWebsiteDataStore(forIdentifier:)`.248- A terminated web content process is reported by `webViewWebContentProcessDidTerminate`; public API cannot249 cause or simulate one, nor report its memory use. `WebEngine.processState` + `reload()` handle recovery.250- `WKWebsiteDataStore.remove(forIdentifier:)` fails with "data store is in use" while any251 `WKWebsiteDataStore` object for that identifier is alive, and for a short time after (the network process252 releases it asynchronously). `WebProfileRegistry.deleteStore` retries for a few seconds.253- A `WKContentWorld` created by name is torn down in the web process when the object is deallocated: globals254 defined by an earlier evaluation disappear. WebRuntime keeps its world objects for the life of the process.255- `WKUserContentController` can only remove *all* user scripts; `UserScriptRegistry` re-adds the others. Its256 `userScripts` array is a live view: it must be copied before clearing.257- `interactionState` is opaque `Data`; unrecognised data is ignored without error.258- Basis: Header; all of the above except real process termination — Test. Real termination — **not verified**259 (the state handling is tested by invoking the delegate callback).260261### Selections and web view lifetime (observed, unexplained)262263On macOS 27.0, a `WKWebView` that is **not in a window** and whose page holds a selection covering a whole text264node / sentence (`selection.selectAllChildren(p)`) is never deallocated after its last reference is dropped —265reproduced with a bare `WKWebView`, no WebRuntime code involved; a partial-word selection does not trigger it,266and clearing the selection, loading a blank page, resigning first responder or hosting the view briefly in an267unordered window does not release it. Consequence: the profile's data store stays "in use". Whether the same268happens for a view that has been on screen is **not verified**; if it does, a suspended tab would not free its269process. The Blink module should measure this in the running app before relying on suspension for memory.270271## 20. Smaller differences worth knowing272273Basis for this table: Apple docs / known behaviour, **not verified** in this repository unless a test is named274elsewhere on this page.275276| Area | WKWebView | Fallback |277|---|---|---|278| Reader mode | No API (Safari's Reader is private) | `reader.js` heuristic + native allow-list validation |279| Page translation, Live Text toggles, Safari AutoFill of passwords/cards | Not exposed | System AutoFill works in fields; nothing browser-controlled |280| iCloud Tabs, Safari bookmarks/history | Not accessible | Own storage and sync |281| `beforeunload` confirmation | No delegate on either platform | Tabs close without the page's prompt |282| Cookie policy per site | `WKHTTPCookieStore.setCookiePolicy` is store-wide | Per-profile only |283| Intelligent Tracking Prevention | On by default, not configurable per site | — |284| Custom schemes | `WKURLSchemeHandler` cannot override `http(s)`, `file`, `about`, `blob`, `data` | `orix://` for internal pages only |285| File uploads | macOS: `runOpenPanel` delegate; iOS: system picker, not customisable | — |286| `window.close()` | Reported only for windows the page opened | `webEngineDidRequestClose` |287