Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

WebKit 6 min read Deep dive mediumAdept

The User Activation API

Browsers gate APIs like window.open(), navigator.share() and PaymentRequest.show() on "user activation": a per-window transient timer started by specific events (keydown, mousedown, pointerdown/up, touchend), plus sticky activation recording that one has ever occurred. Some APIs consume the activation, so calling share() then window.open() in one click handler fails. Activation propagates across same-origin iframes but not cross-origin ones. The new navigator.userActivation.isActive and hasBeenActive properties expose this state, and open problems remain around timers expiring during slow async work and third-party iframe payments.

Assumes: DOM event handlingJavaScript async/await

Related posts

  • Hopping on Firefox 91

    Mozilla Hacks mediumAdept

    Firefox 91 enables the Visual Viewport API by default, making it available in all major browsers and letting pages read the visible viewport's size, offset and scale and react to resize and scroll events, such as when zooming or an on-screen keyboard appears. Intl.DateTimeFormat gains new timeZoneName options (shortOffset, longOffset, shortGeneric, longGeneric) plus formatRange() and formatRangeToParts() for localized date ranges, all shown with code examples. The Gamepad API is now restricted to secure contexts and gated by a gamepad Feature Policy. Private browsing windows also adopt an HTTPS-first policy that falls back to HTTP when a site lacks HTTPS.

  • Global Privacy Control (GPC) WebKit API

    WebKit mediumAdept

    iOS, iPadOS, visionOS and macOS 27 add a WebKit API that lets apps embedding WKWebView or SwiftUI's WebPage opt navigations into Global Privacy Control, the emerging standard for signalling opt-out of data sharing and cross-context targeted advertising (recognized under California's CCPA). Setting `globalPrivacyControlEnabled` on the WKWebpagePreferences returned from the navigation-policy delegate, or `isGlobalPrivacyControlEnabled` on WebPage.NavigationPreferences, enables `navigator.globalPrivacyControl` and the `Sec-GPC: 1` header for the main frame, subframes and subresources. Example delegate code is given in Swift and Objective-C so apps can wire GPC to their own user setting.

  • WebKit Features in Safari 16.1

    WebKit mediumAdept

    Safari 16.1 brings Web Push to macOS Ventura using the standard Push API, Notifications API and Service Workers, delivered via Apple Push Notification service. Sites that already follow best practices work without an Apple Developer membership, but they need feature detection rather than browser sniffing, and servers must allow push.apple.com subdomains. The release extends passkeys to all Safari 16 platforms, with advice to support cross-device sign-in and conditional mediation for AutoFill. It also adds animated AVIF, Scroll to Text Fragment and window capture via getDisplayMedia, along with CSS, forms and accessibility fixes that bring its Interop 2022 score to 93.3%.

  • Web Push for Web Apps on iOS and iPadOS

    WebKit mediumAdept

    iOS and iPadOS 16.4 beta 1 adds standards-based Web Push for Home Screen web apps, using the Push API, Notifications API and Service Workers over Apple Push Notification service, with no Apple Developer Program membership required (allow *.push.apple.com). Permission must be requested in response to direct user interaction, and notifications integrate with Focus, which syncs across devices via the newly supported manifest `id` combined with the user-chosen app name. The release also adds the Badging API, lets third-party browsers offer Add to Home Screen through UIActivityViewController with a WKWebView, opens Home Screen bookmarks in the default browser, and generates monogram fallback icons. Sites already using feature detection for Web Push on Safari 16.1 for macOS should work unchanged.

  • Badging for Home Screen Web Apps

    WebKit mediumAdept

    WebKit on iOS and iPadOS 16.4 supports the W3C Badging API, but only for web apps added to the Home Screen. It is not exposed in Safari or WKWebView. Badges appear only after the user grants notification permission, and users can still hide badges in Settings without the app being told. The post shows feature detection, requesting and checking notification permission, `navigator.setAppBadge()` and `clearAppBadge()`, and updating badges from a Service Worker on push events. A badge update alone does not satisfy the user-visible notification requirement, and calls from cross-origin frames are ignored.

The quest for software engineering knowledge.

Look:
Layout: