Skip to content

[Feature] Web view parity for in-app browsers: script results, downloads, headers, custom schemes #33

Closed

Description

@ayuayue

Context

WebView exists on every backend, and docs/roadmap.md already lists what is still missing around it. Taken together, the gaps rule out the most common reason a desktop tool embeds a browser at all: showing a page the app also has to understand, serve and save from.

The rows, as the roadmap has them:

  • script results from web views (Evaluate returning the script's result or its error) — Script results from web views
  • downloads (macOS saves them through WebConfig.DownloadDir; Windows and Linux save nothing) — Web view downloads elsewhere
  • request headers and cookies a load carries, Incognito keeping website data in memory, an app serving URL schemes of its own, loading a page from the app's own files on macOS, and Env reporting where the platform shows no web view — More of a web view's loads
  • trusted input (Ref.SendInput reaches the page as trusted input on macOS only) — Trusted web input elsewhere

Why these four, together

They are the same feature seen from four sides: an embedded browser the app can drive.

  • Evaluate is how an app reads a page it shows (a login that finished, a value in a local dashboard, a token the docs page exposes) without shipping a second parser.
  • Downloads are how a user gets a file out of a page the app opened; on Windows and Linux a link that downloads currently does nothing, which reads as a bug, not a missing feature.
  • Request headers and custom schemes are how an app serves its own content (app://settings/index.html) and reaches an authenticated origin without opening a local TCP port and hoping it is not exposed.
  • Trusted input is what makes a page's isTrusted handlers and its user-activation paths work, which a "click this in the page" button needs.

Proposed scope

  1. Ref.Evaluate(js string, done func(result any, err error)) on every backend with a web view, answering JSON or an error, with the same timeout the other ref commands have.
  2. WebConfig.DownloadDir honored on Windows (WebView2's DownloadStarting) and Linux (WebKitGTK's download-started), reporting start, bytes and end as Apple's do.
  3. WebConfig.Headers, WebConfig.Incognito, and a ServeScheme(scheme string, handler func(url string) []byte) the app registers, so WebConfig.Source can be app://…. Env.HasWebView reports where the platform has none (already the roadmap's 5th row).
  4. Ref.SendInput on Windows (WebView2's SendMouseInput and key messages), Linux and iOS, or an explicit Env.CanSendInput so an app hides a button it cannot honor.

Acceptance

  • Evaluate returns a number, a string, an object and nil from all three desktops and the web, and an error (not a panic) for a script that throws.
  • A page with <a download> reaches OnDownload on Windows and Linux, writes under the app's data directory, and reports its bytes.
  • A page served by app:// loads on all three desktops with its assets, and a navigation to another host is still refused as WebConfig.Navigable says.
  • Incognito leaves no entry in the platform's website data store after the view is destroyed (checked with the platform's own inspector or a second view that reads storage).
  • SendInput produces isTrusted events and user activation where it is supported, and Env.CanSendInput is false where it is not.
  • The gallery's WebView demo exercises each of these, and docs/architecture/native-views.md records the per-target matrix.

Note

If ServeScheme is too large a step, WebConfig.Headers and downloads alone already remove most of the workarounds apps write today; they are worth landing first.

Activity

  1. added
    enhancement
    on Nov 11, 2026
  2. houko commented on Nov 14, 2026

    @houko
    Collaborator

    The current tree already has Ref.Evaluate, OnDownload plumbing, Ref.SendInput, navigation restrictions and per-target web-view event bridges. The acceptance gaps remain Windows/Linux download backends, request headers, incognito storage, app-owned custom schemes, and trusted input parity on the unsupported targets; no complete implementation is claimed yet.

  3. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 adds the Linux WebKitGTK download backend: now chooses the app-owned downloads// path, reports started/finished/failed events and bytes, and cancels downloads when no handler is configured. Windows and Android downloads plus headers, custom schemes, incognito storage and trusted-input parity remain open for follow-up slices.

  4. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Correction to the previous comment: the Linux WebKitGTK backend now makes the existing OnDownload callback choose the app-owned downloads// path, reports started/finished/failed events and bytes, and cancels downloads when no handler is configured. Windows and Android downloads plus headers, custom schemes, incognito storage and trusted-input parity remain open for follow-up slices.

  5. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 now adds WebView.Incognito: Apple uses WKWebView\x27s non-persistent data store, Linux uses an ephemeral WebKitGTK network session, Windows uses WebView2 in-private controller options, and Android disables cache, form saving and DOM storage. Custom schemes and trusted-input parity remain open.

  6. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Correction: Draft PR #76 uses WKWebView non-persistent data on Apple; the other Incognito behavior is unchanged from the preceding update.

  7. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 now adds Scope.ServeScheme for app-owned app://-style content on Apple (WKURLSchemeHandler), Windows (WebView2 resource requests) and Linux (WebKitGTK URI schemes). Restricted web views allow registered schemes while still refusing unapproved network hosts; Android and web remain explicitly unsupported for this bridge. Focused tests and desktop cross-compilation pass. Trusted-input parity and gallery coverage remain open.

  8. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 now also exposes Env.CanSendInput: macOS reports true for its AppKit trusted-event bridge, while Windows, Linux and iOS report false and Ref.SendInput safely does nothing there until a native trusted-input bridge exists. Custom schemes, downloads, headers and incognito storage remain covered by the same Draft PR.

  9. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 now also exposes Env.HasWebView: desktop, Android, web and non-tvOS Apple targets report a web view host, while tvOS reports false. Env.CanSendInput continues to advertise the only trusted-input bridge currently available (macOS). App-owned schemes, downloads, headers and incognito storage remain covered.

  10. houko commented on Nov 14, 2026

    @houko
    Collaborator

    The gallery's desktop WebView demo now loads its inline page through the app-owned gallery://inline/index.html scheme (with HTML fallback on targets without the bridge), and configures headers plus incognito storage. Focused gallery checks pass; Draft PR #76 remains open.

  11. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 now also supports Apple file: pages with directory-scoped read access, so a page can load neighboring assets without exposing files outside its folder. Path boundary tests and Apple cross-compilation pass; the PR remains Draft.

  12. houko commented on Nov 14, 2026

    @houko
    Collaborator

    Draft PR #76 adds a lightweight web-scheme MIME helper and removes the desktop backends' direct net/http dependency. TestMinimalAppLinks now passes for Darwin, Windows, Linux, Android and Web; the full suite is 1798 passed, 1 failed, 12 skipped. The remaining TestSmallJSON/v2 failure is caused by the local Go 1.26 toolchain excluding encoding/json/v2. PR #76 remains Draft.

  13. self-assigned this
    on Nov 20, 2026
  14. houko commented on Nov 20, 2026

    @houko
    Collaborator

    I re-audited #33 against the latest origin/main and the merged PR #76. The requested parity work is now present across the supported targets: Ref.Evaluate and its page/error handling, request headers, Incognito storage modes, app-owned schemes, navigation restrictions, downloads on macOS/Linux/Windows/Android, and Env.HasWebView/Env.CanSendInput capability reporting. The web-view tests cover the shared command and answer paths, native download and scheme behavior, and the platform-specific storage and navigation bridges.

    Trusted input remains intentionally unavailable on Windows, Linux, and iOS, where Env.CanSendInput reports false and Ref.SendInput safely does nothing. Android's custom-scheme bridge is also outside the supported native-scheme matrix. Those limitations are recorded as separate roadmap follow-ups, so the original parity scope is complete and I am closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

coreenhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions