Skip to content

Latest commit

 

History

History
264 lines (253 loc) · 45.9 KB

WebKit.md

File metadata and controls

264 lines (253 loc) · 45.9 KB

WebKit

Symbols: 80.8% of Apple's iOS API (915 of 1132, exact) · Rows: 18: 13 ✅ 2 🟡 3 ❌ · iOS: 16.0+

Area: Web, network & communication · Apple: WebKit · Issues: area:web

How isim implements it

  • Passthrough: WebKitGTK 6.0 in a helper process (isim-webkit). isim draws the pixels; the Objective-C names sit over the Swift overlay.

API

API / feature Status iOS Notes
WebKit WKWebView rendering and loading (load, loadHTMLString, loadFileURL, load(_:mimeType:…), back/forward, reload, KVO title/url/isLoading/estimatedProgress/canGoBack) ✅ ≤17 real WebKit: the host's WebKitGTK 6.0 in a helper process (isim-webkit, private invisible broadway display) renders frames at the screen scale; iOS-style user agent; history includes loadHTMLString pages. Adapted: load sends GET + headers only. A page without <meta name=viewport> lays out 980 CSS px wide and is scaled to fit the view, as on iOS (isim decides as the page is parsed; tested: test_web_extras). Needs webkitgtk-6.0 + gtk4-broadwayd on the host (else a placeholder and a failed navigation). Tested (HelloWeb)
WebKit delegates (WKNavigationDelegate action/response policy, start/commit/finish/fail; WKUIDelegate alert/confirm/prompt, createWebViewWith) ✅ ≤17 completion and async forms; cancelled links; JavaScript panels through the app's UI delegate (none → dismissed like iOS). App Transport Security: a cleartext navigation or redirect the app's Info.plist does not allow (NSAllowsArbitraryLoadsInWebContent, exception domains, local networking) is cancelled after the action policy and fails provisionally with -1022 (HelloTransportSecurity); subresources inside the page are not filtered. Tested; createWebViewWith, process termination unverified
WebKit JavaScript bridge (evaluateJavaScript, callAsyncJavaScript, content worlds, WKUserScript, WKScriptMessageHandler(WithReply), WKURLSchemeHandler) ✅ ≤17 results converted like iOS (dictionaries, arrays, numbers, WKError.javaScriptExceptionOccurred, unsupported types); isolated worlds; replies to page promises, including dictionaries and arrays: adapted, because WebKitGTK cannot hand a page an object made in the UI process, so isim sends them as JSON text, which a script in the handler's world turns back into objects before the promise resolves (#828). Tested (HelloWeb: test_web)
WebKit input, selection, scrolling, zoom, menus, find, PDF, web archives, website data (WKWebsiteDataStore, WKHTTPCookieStore), snapshots ✅ ≤17 adapted input: taps, typing (system keyboard on focused fields) and scrolling become DOM events from an isolated world (isTrusted false); scrollView mirrors page scrolling. A long press selects a word (selection tint and handles, edit menu with Copy / Select All / Share…, copy: / selectAll:); a long press on a link or image opens a context menu with a live preview (WKUIDelegate contextMenuConfigurationFor, will-present, did-end, commit; else Open / Copy Link / Share…); <select> and <select multiple> become UIKit menus (option groups, disabled options, change events); pinch zoom within the viewport meta's scales (user-scalable=no honoured), scrollView.zoomScale follows; isFindInteractionEnabled / findInteraction (find navigator, highlights, n of m); createPDF (whole page or WKPDFConfiguration.rect, WebKit's print backend at CSS size, cropped with poppler) and createWebArchiveData (WebKit's MHTML as a webarchive plist: main resource and subresources). Cookies get/set/delete and data removal; takeSnapshot. Tested (test_web, test_web_interact)
SwiftUI WebView / WebPage (iOS 26) ✅ 26.0 on WKWebView: WebPage is @Observable (title, url, isLoading, estimatedProgress, currentNavigationEvent), load (request, HTML, data) returning the navigation events as an AsyncSequence, reload, callJavaScript with arguments, pdf, snapshot, webArchiveData, find, URLSchemeHandler; WebView(page) / WebView(url:) with webViewBackForwardNavigationGestures, webViewLinkPreviews, webViewMagnificationGestures, webViewContentBackground. Tested (HelloWeb -webpage, test_web_webpage)
Authentication challenges: WKNavigationDelegate.webView(_:didReceive:completionHandler:) (and respondTo async) ✅ ≤17 passthrough of WebKitGTK's authenticate signal: HTTP Basic, Digest, NTLM and Negotiate become a URLAuthenticationChallenge (URLProtectionSpace with host, port, realm, method; previousFailureCount; the proposed user); .useCredential hands WebKit the credential with its persistence, .performDefaultHandling and .rejectProtectionSpace continue without credentials (the server's 401 page, as on iOS), .cancelAuthenticationChallenge cancels the load; no delegate method: the 401 page. URLSession.AuthChallengeDisposition is now @objc (NSURLSessionAuthChallengeDisposition) so Objective-C delegates get it; apps built before keep their enum-case symbols (swift/overlays/Foundation/compat.c). Tested (HelloWeb -transfers: test_web_transfers)
Downloads: WKDownload (originalRequest, webView, delegate, progress, isUserInitiated, originatingFrame, cancel(_:)), WKDownloadDelegate (destination, redirect, challenge, finish, failure with resume data), WKWebView.startDownload(using:completionHandler:), resumeDownload(fromResumeData:completionHandler:), .download action and response policies with navigationAction / navigationResponse didBecome download ✅ ≤17 passthrough of WebKitGTK's downloads (the web view's session: cookies, credentials), saved where the delegate's destination says; progress follows the received bytes. Adapted: WebKitGTK cannot resume a partial download, so isim's resume data (the URL and destination) restarts it to the same file; cancel(_:) hands the resume data to its handler and the delegate hears only of other failures; a data: URL is suggested as "Unknown" with its type's extension, like Safari. WebKitGTK cannot download from a custom scheme (WKURLSchemeHandler). The completion-handler and async forms of the destination method are both optional (on iOS the completion form is required). Tested (HelloWeb -transfers; HelloWebObjC)
Camera and microphone: WKUIDelegate.webView(_:requestMediaCapturePermissionFor:initiatedByFrame:type:decisionHandler:) (and async), WKMediaCaptureType, WKPermissionDecision ✅ ≤17 getUserMedia asks the UI delegate: .grant, .deny, or .prompt (also without the method) shows iOS's alert, “Allow “host” to use your camera?” (Don’t Allow / Allow). Adapted: the page gets WebKit's mock camera and microphone (a test pattern), as isim's web engine has no capture devices. Tested (HelloWeb -transfers: the alert, Allow, a video track)
Content rule lists: WKContentRuleListStore (default(), init(url:), compile / look up / remove / getAvailableContentRuleListIdentifiers, completion and async forms), WKContentRuleList, WKUserContentController.add(_:) / remove(_:) / removeAllContentRuleLists() ✅ ≤17 passthrough: the web engine compiles Apple's JSON rules with WebKitGTK's content filters (WebKitUserContentFilterStore, the same WebKit rule compiler) into the store's directory (the app's Library/WebKit/ContentRuleLists by default); a list added to a controller applies to its web views at once (block, css-display-none, ignore-previous-rules, make-https, block-cookies, triggers with url-filter, if-domain, resource-type, load-type); invalid JSON fails with WKError.contentRuleListStoreCompileFailed, a missing identifier with contentRuleListStoreLookUpFailed. Tested (HelloWeb -rules, tests/ui/test_web.py::test_web_content_rules)
WebKit from Objective-C (#import <WebKit/WebKit.h>, WKWebView by its Objective-C name) ✅ ≤17 adapted: Objective-C headers over the Swift overlay's classes (Apple's class names and selectors, delegates, KVO, subclasses and categories from Objective-C, evaluateJavaScript:/callAsyncJavaScript: and the other completion-handler APIs, WKURLSchemeHandler / WKURLSchemeTask, WKDownload / WKDownloadDelegate, startDownloadUsingRequest:, the challenge, download and media capture delegate methods). Tested: test_web_objc (HelloWebObjC); runs Google Mobile Ads (#200)
WKWebView.fullscreenState (WKFullscreenState, KVO) and element fullscreen ✅ 16.0 adapted: with WKPreferences.isElementFullscreenEnabled, an element's requestFullscreen() presents the web view full screen (black, no status bar, a close button, isim-web-fullscreen-close), as iOS does; the state goes entering → in → exiting → not in. WebKitGTK's fullscreen signals; without the preference requestFullscreen() is refused. Tested (HelloWeb -extras, tests/ui/test_web.py test_web_extras, os_matrix; HelloWebObjC)
File inputs: WKOpenPanelParameters, WKUIDelegate.webView(_:runOpenPanelWith:initiatedByFrame:completionHandler:) ✅ 18.4 passthrough of WebKitGTK's file chooser request: the delegate's URLs become the <input type=file>'s files (change fires), nil cancels it (cancel fires). Without the method (and before iOS 18.4) the web view shows iOS's menu: Photo Library (isim's photo picker), Take Photo or Video (when a camera is simulated), Choose File (the document picker). Adapted: allowsDirectories is always false (WebKitGTK does not say). Tested (HelloWeb -extras: test_web_extras, os_matrix)
Web extensions: WKWebExtension (init(resourceBaseURL:), init(appExtensionBundle:), the manifest, display names and versions localised from _locales, permissions and host permissions, allRequestedMatchPatterns, the has… flags, icon(for:), actionIcon(for:), errors, Error, Permission), WKWebExtension.MatchPattern (Options, Error), WKWebExtensionController (Configuration, load(_:), unload(_:), extensionContexts, extensions, extensionContext(for:)), WKWebExtensionContext (granted and denied permissions and match patterns with expiration dates, permissionStatus(for:), setPermissionStatus(_:for:expirationDate:), hasAccess(to:), hasInjectedContent(for:), optionsPageURL, Error, PermissionStatus), WKWebViewConfiguration.webExtensionController 🟡 18.4 adapted: WebKitGTK has no browser-extension runtime. isim reads manifest versions 2 and 3, and a loaded context's content scripts and CSS (matches, exclude_matches, run_at, all_frames) run in the controller's web views, in a content world of their own, on pages the context was granted, with browser.* (the row below). Tested (HelloWeb -extras: test_web_extras; HelloWebObjC: test_web_objc)
Web extension tabs, windows and runtime: WKWebExtensionTab, WKWebExtensionWindow (completion-handler and async forms), WKWebExtension.TabConfiguration, .WindowConfiguration, .TabChangedProperties, .WindowType, .WindowState; WKWebExtensionControllerDelegate (open windows, focused window, new tabs and windows, options page, permission prompts, didUpdate action, action popups, native messages, message ports) and WKWebExtensionController.delegate; WKWebExtension.Action (label, badgeText, hasUnreadBadgeText, icon(for:), isEnabled, menuItems, presentsPopup, popupWebView, popupViewController, closePopup()), WKWebExtension.Command (id, title, activationKey, modifierFlags, menuItem, keyCommand), WKWebExtension.MessagePort (Error), WKWebExtension.DataRecord (Error), WKWebExtension.DataType; the context's and the controller's did… tab and window events, openTabs, openWindows, focusedWindow, action(for:), performAction(for:), commands, performCommand(_:), performCommand(for:), menuItems(for:), hasPermission(_:in:), hasAccess(to:in:), permissionStatus(for:in:), userGesturePerformed(in:), hasActiveUserGesture(in:), clearUserGesture(in:), loadBackgroundContent(completionHandler:), the permission notifications and NotificationUserInfoKey; allExtensionDataTypes, fetchDataRecords(ofTypes:), fetchDataRecord(ofTypes:for:), removeData(ofTypes:from:) 🟡 18.4 adapted: isim runs the extension itself. The background page, scripts or service worker run in a hidden web view on webkit-extension://<uniqueIdentifier>/, which serves the extension's files (also for popups and pages shown with the context's webViewConfiguration). browser.* / chrome.* reach the context through a script message handler. Content scripts get runtime (id, getManifest, getURL, sendMessage, onMessage), storage and i18n. Extension pages also get runtime.sendNativeMessage / connectNative / openOptionsPage / onInstalled, tabs, windows, scripting (executeScript, insertCSS, removeCSS), action, commands, menus and permissions. Tabs, windows, popups, prompts and native messaging are the app's, through the protocols and the delegate. A user gesture grants activeTab. storage.local / sync are saved under Library/WebKit/WebExtensions (in memory for a non-persistent controller) and are the extension's data records. Not on isim: declarativeNetRequest, webRequest, webNavigation, alarms, cookies, runtime.connect between extension parts, service-worker-only APIs, and extension resources in the app's own web views. Tested (HelloWeb -extension: test_web_extension_runtime; HelloWebObjC: test_web_objc)
Types not yet in isim (iOS 18) ❌ 18.2 not implemented: WKDownload.PlaceholderPolicy
WebPage.NavigationDeciding (decidePolicy(for:preferences:) with NavigationAction and NavigationPreferences, decidePolicy(for:) with NavigationResponse, decideAuthenticationChallengeDisposition(for:)), WebPage.DialogPresenting (alert, confirm, prompt and file input results), WebPage.FrameInfo, WebPage(configuration:navigationDecider:dialogPresenter:), WebPage.fullscreenState ✅ 26.0 on WKWebView's navigation and UI delegates; the protocols' default methods allow every navigation, take the default challenge handling and dismiss dialogs, as on iOS. Tested (HelloWeb -webpage -decide, tests/ui/test_web.py test_web_webpage_decider, os_matrix)
Types not yet in isim (iOS 26) ❌ 26.0 not implemented, found by the 2026-10 sweep: URLScheme, WebPage.BackForwardList.Item, WebPage.BackForwardList.Item.ID, WebPage.Configuration.MediaPlaybackBehavior, WebPage.DeviceSensorAuthorization, WebPage.DeviceSensorAuthorization.Permission, WKSecurityRestrictionMode
Types not yet in isim (iOS 27) ❌ 27.0 not implemented, found by the 2026-10 sweep: WebPage.FormInfo, WKContentWorld.Configuration, WKDOMNodeSnapshot, WKFormInfo, WKJSHandle (5 types; with their members under "Not yet in isim")

Not yet in isim

217 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List