Skip to content

feat(webview): route page window requests to the app - #1663

Merged
houko merged 1 commit into
nsgo-dev:mainfrom
houko:feat/webview-window-requests-113
Nov 21, 2026
Merged

houko merged 1 commit into
nsgo-dev:mainfrom
houko:feat/webview-window-requests-113

Conversation

@houko

@houko houko commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

core.WebView.OnOpenWindow reports a page's requested URL and the platform's user-gesture classification. The app can load the URL, open it elsewhere, or ignore it. Apple, Linux, and Windows suppress their native popup in every case. A restricted view checks the request against its navigation policy and reports refused URLs through OnError.

WebKit's public navigation action exposes navigation type. On macOS this change enables WebKit's public popup blocker, so a script's delivered request comes from a WebKit user gesture. Apple's link and form classifications use WKNavigationType. WebKitGTK and WebView2 supply a gesture flag.

The gallery's inline WebView shows the URL requested by its new-window link. Its Change page state button updates the fragment and title through JavaScript. The demo shows the latest URL and title from OnNavigationStateChange.

Refs #113. This PR covers new-window handling. The same-document navigation changes are in #1654, #1657 and #1661.

Targets

  • Shared code (core)
  • macOS
  • iOS
  • Linux
  • Windows

Screenshots

None.

Verification

  • go tool nsgo test -target macos ./internal/testhost/testdata/websource (5 passed).
  • go tool nsgo test -target linux -run '^TestWebWindow' ./internal/testhost/testdata/websource under Xvfb with WebKitGTK (2 passed).
  • The macOS and Linux popup tests cover links, window.open from a click and from a timer, a form target, access denial, and suppression without a callback.
  • go tool nsgo test -run '^TestWeb|^TestSendInput' ./core and TestPublicAPINamesNoInternalType.
  • go tool nsgo test -run '^TestMedia$|^TestCookieStore$' ./examples/gallery. The gallery test checks the history and title script and renders the reported URL and title. go tool nsgo check ./examples/gallery passed.
  • go tool nsgo check.
  • go tool nsgo check -target macos,ios,linux,windows -jobs 2 ./internal/platform.
  • go tool nsgo test -run '^TestWebView2WindowRequests$' ./internal/platform/windows on an interactive Windows runner. Both subtests passed. WebView2 receives trusted browser clicks through DevTools without moving the desktop cursor. The test now runs in Windows CI.
  • On the rebased code, both Linux/WebKitGTK and macOS popup tests passed. The same two tests passed three repetitions on the iOS 27.0 simulator using native taps. The iOS test waits for the page to acknowledge an inert tap before exercising the link, script, form and refused-URL cases.
  • Core WebView, public API, skill and gallery regressions passed. Linux and Windows checks passed for both architectures, plus Web, both macOS architectures and iOS.

Checklist

  • The title is a Conventional Commit.
  • The public docs, architecture, roadmap, skill reference, gallery and changelog cover the new callback.

@github-actions github-actions Bot added size/M documentation Improvements or additions to documentation macOS iOS Windows Linux core enhancement New feature or request and removed size/M labels Nov 21, 2026
@houko
houko force-pushed the feat/webview-window-requests-113 branch from 5b898eb to 3e5cc20 Compare November 21, 2026 13:50
@houko
houko force-pushed the feat/webview-window-requests-113 branch 2 times, most recently from 4baf6f6 to d8bc0a9 Compare November 21, 2026 14:15
@github-actions github-actions Bot added the ci label Nov 21, 2026
@houko
houko force-pushed the feat/webview-window-requests-113 branch from d8bc0a9 to d88c2b8 Compare November 21, 2026 17:18
@github-actions github-actions Bot added the conflict Conflicts with the base branch; resolve it first label Nov 21, 2026
@houko
houko force-pushed the feat/webview-window-requests-113 branch from d88c2b8 to 51ab240 Compare November 21, 2026 17:57
@houko
houko force-pushed the feat/webview-window-requests-113 branch from 51ab240 to 605f6b4 Compare November 21, 2026 19:02
@houko
houko merged commit c69f7db into nsgo-dev:main Nov 21, 2026
5 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci conflict Conflicts with the base branch; resolve it first core documentation Improvements or additions to documentation enhancement New feature or request iOS Linux macOS size/M Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant