Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/Frontends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ function(webfront_add_browser_tests target frontend assets_directory lifecycle_t
set(lifecycle_command "${XVFB_RUN_EXECUTABLE}" -a ${lifecycle_command})
endif()
set(lifecycle_modes no-bridge early-close rejected-ready navigation-failure path-encoding content-policy navigation-allow-list view-association stage-report)
list(APPEND lifecycle_modes ui-executor native-window second-open host-close)
list(APPEND lifecycle_modes ui-executor native-window second-open host-close second-window)
# CEF neither supports nor checks a secondary thread: nothing to observe there (docs/HOST_INTEGRATION.md).
if(NOT frontend STREQUAL "CEF")
list(APPEND lifecycle_modes host-thread)
Expand Down
2 changes: 1 addition & 1 deletion cmake/WKWebViewSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function(webfront_add_wkwebview_tests)
add_executable(wkwebview_lifecycle "${webtest_source_dir}/WKWebViewLifecycle.cpp"
"${webtest_source_dir}/WKWebViewHeaderConsumer.cpp")
target_link_libraries(wkwebview_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options)
foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings translucent-background hidden-scheduling redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog load-reveal present-timeout)
foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings translucent-background hidden-scheduling hidden-secondary redirect-policy missing-response committed-navigation agent-application download choose-file cancel-choose replaced-download choose-in-blank choose-in-srcdoc close-with-open-panel close-with-save-panel script-dialogs close-with-script-dialog sandboxed-script-dialog load-reveal present-timeout)
add_test(NAME WKWebViewLifecycle-${mode} COMMAND wkwebview_lifecycle ${mode})
webfront_set_browser_test_properties("WKWebViewLifecycle-${mode}" "${webtest_source_dir}" 90)
endforeach()
Expand Down
3 changes: 2 additions & 1 deletion cmake/WebView2Support.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ function(webfront_add_webview2_tests)
target_link_libraries(webview2_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options)
foreach(mode repeated-show native-early-close navigation-diagnostic mta missing-runtime
closed-startup-timeout failed-startup-timeout late-navigation-failure runtime-ready
file-choose file-cancel file-download script-dialogs first-frame present-timeout)
file-choose file-cancel file-download script-dialogs first-frame present-timeout
secondary-startup-timeout)
add_test(NAME WebView2Lifecycle-${mode} COMMAND webview2_lifecycle ${mode})
webfront_set_browser_test_properties("WebView2Lifecycle-${mode}" "${webtest_source_dir}" 45)
endforeach()
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ these entries stays in the GitHub releases and the Git history.
- The CEF profile is now `cef_cache/<executable>`, not `cef_cache`: an application starts with an empty profile (localStorage, cookies); to keep the data, move the old contents of `cef_cache` into `cef_cache/<executable>` once (#617, `docs/HOST_INTEGRATION.md`).

### Added
- Open a second native window with `app.openSecondaryWindow(page, WindowOptions)` (WebKitGTK, WKWebView, WebView2; elsewhere `std::logic_error`, which `app.canShowSecondaryWindow()` predicts): it shares the server, the `cppFunction`s, the `jsFunction` subscribers and the view proof of the first window; `app.requestClose(page)` closes it, and closing the first closes the others (#616, `docs/FRONTENDS.md`).
- Write your own scenarios with the public `webfront::bdd` framework: `<webfront/testing/Bdd.hpp>`, the `WebFront::Bdd` target, the installable `WebFrontBdd` package and `webfront_bdd_discover_tests()` (prefix, properties, shards) replace the internal `test/unit/Bdd.hpp` and `bdd_discover_tests`, and follow WebFront's versions (#647, `docs/BDD.md`).
- Configure a stable MCP port and application-supplied Bearer token, or explicitly disable authentication for trusted development (#637, ADR-026, `docs/AUTOMATION.md`).
- Connect an MCP client to the application itself: `enableAutomation(app, {.grants = {...}})` serves MCP over Streamable HTTP on a loopback port of its own, prints its URL and writes a private `mcp.json` with the URL and a session Bearer token, so several applications run side by side with no other program (#632, ADR-025, `docs/AUTOMATION.md`).
Expand Down
4 changes: 3 additions & 1 deletion docs/FRONTENDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A frontend is a type with:
| `static constexpr Action action` | What `BasicWF` does once `open()` returns. |
| `static void launch(address, port, page)` (optional) | Opens the interface and returns without waiting for it (the system browser spawns its opener command and does not wait for it to end). `BasicWF::start()` requires it; only a frontend without a window loop offers it (the system browser). A `launch(address, port, page, const ContentPolicy&)` overload is preferred when present; neither receives window options or the view-association proof. |
| `static constexpr bool endsOnRequest` (optional) | `false` when `requestClose()` cannot end every session (`NativeOrBrowserFrontend` with the plain system browser as fallback); `webfront::UIThread` then refuses the frontend. |
| `static void openSecondaryWindow(address, port, file, policy, window, launch)` and `static bool closeSecondaryWindow(file)` (optional) | A second window beside the one `open()` runs (#616), callable from any thread while it runs; `invokeOnUIThread()` (UIExecutor.hpp) hops to the interface thread. Opening a page a secondary window already shows brings it to the front (a hidden window stays hidden and does not take the focus); the first window's end closes the others. A window is identified by the `file` string as given, query included. `WebKitGTKFrontend`, `WKWebViewFrontend` and `WebView2Frontend` implement it: `BasicWF::openSecondaryWindow()` throws `std::logic_error` for a frontend without it (CEF, the system browser), never opening a browser. `BasicWF::supportsSecondaryWindow` tells it from the frontend type; an optional `static bool secondaryWindowsAvailable()` tells it at run time, and `BasicWF::canShowSecondaryWindow()` combines both. `NativeOrBrowserFrontendFor` offers the functions only when its native frontend does, and reports them unavailable once it fell back to the system browser. The call waits for the interface thread (it runs at once on that thread): a `cppFunction` callback, which runs on the server's thread, schedules it with `app.uiExecutor()` instead of holding every exchange of the application while it waits. A window that cannot start throws the failure to the caller; one that fails to load later closes and writes the failure to stderr (the call has returned: nothing can throw it). A request that runs after the first window closed is refused with `std::logic_error`. A frontend whose first window cannot host another yet throws `frontend::WindowNotReady` (a `std::logic_error`): `BasicWF` and `invokeOnUIThreadWhenReady()` try again from another thread, and pass it to a caller on the interface thread. WebKitGTK shares the first window's network session (cookies, storage; downloads are tracked by the first window) and ignores `WindowOptions::media`. WKWebView shares its nonpersistent website data store and follows the first window's visibility (a hidden application shows no window and does not take the focus). WebView2 creates the second browser from the first window's environment, so the profile (storage, cookies) and the browser process are shared; it follows the first window's visibility, and has its own startup watchdog, with the first window's delay (the one `WebView2FrontendWithOptions` configured). A call made while the first window's environment is still being created waits for it (bounded by that window's watchdog); on the interface thread it throws `std::logic_error`. Placement is left to the toolkit. |
| `static bool requestClose()` (optional) | Asks, from any thread, the session that `open()` runs to end as if the user had closed the window; false when nothing is open. `BasicWF::requestClose()` forwards it only for the application whose `show()` owns that session (its thread is the frontend's published interface thread). A frontend with an executor takes `requestClose(std::optional<UISession>)` and drops the request, on its interface thread, if another loop runs by then. |
| `static constexpr bool requiresMainThread` (optional) | `open()` belongs to the process main thread; `webfront::UIThread` refuses the frontend at compile time. Undeclared means any thread. |

Expand Down Expand Up @@ -209,6 +210,7 @@ Registry order determines the initial cache default: the first enabled embedded
- `path-encoding`: load `encoded path #.html` and verify that its query and fragment survived.
- `content-policy`: block a popup and a foreign-origin top-level navigation while keeping the original page alive.
- `navigation-allow-list`: permit the same top-level destination through the explicit navigation allow-list.
- `second-window` (#616): a second window shares storage, a `cppFunction` and a pushed `jsFunction` with the first and carries the embedded-view proof; the same page again opens nothing; closing the second leaves the first usable and it can reopen; closing the first closes the second; a window opened as soon as the loop runs, before the first page connected, opens; a request that runs in the pass where the first window closed is refused (WebKitGTK, WKWebView). Frontends without the capability must refuse with `std::logic_error`.
- `host-close`: a host thread exchanges with the page while `show()` runs, then `requestClose()` ends the session; a request before and after the window is refused.
- `host-thread` (not CEF): `webfront::UIThread` runs the application on a secondary thread where the frontend allows it; elsewhere a window opened on a secondary thread must be refused with the main-thread diagnostic.
- `view-association`: the page of the view connects with the secret of the launch and `UI::isEmbeddedView()` is true; a second connection of that page, from the same loopback address and without the secret, is not associated.
Expand Down Expand Up @@ -272,7 +274,7 @@ The handle carries `kind` (`win32`: `HWND`, `cocoa`: `NSWindow*`, `gtk`: `GtkWin

Call it inside an operation scheduled with `app.uiExecutor()` and do not keep the pointer. The window stays published until the loop ends,
including after the user closed it, so check the object with the toolkit when that matters (`IsWindow`, `-[NSWindow isVisible]`).
The connection's window is the frontend's single window, reached through the association of ADR-020 rule 3 (`ui.isEmbeddedView()`); the
The connection's window is the frontend's primary window, reached through the association of ADR-020 rule 3 (`ui.isEmbeddedView()`). For a secondary connection, `ui.nativeWindow()` also identifies the primary window; per-secondary-window native handles are not implemented. The
system browser never has one. `portalParent` is the `parent_window` of the desktop portals: under WebKitGTK `x11:<hex XID>` when the
window is on X11, `wayland:<handle>` once `gdk_wayland_toplevel_export_handle` succeeds (either is tried every 100 ms for 5 s after the window is
presented, until the surface exists and can be exported; empty until then); it is empty on Windows and macOS. A frontend author calls `nativeWindowHostOf<Frontend>().publish(...)` on the interface
Expand Down
3 changes: 3 additions & 0 deletions docs/PROJECT_STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ WebFront is a header-only C++23 HTTP/WebSocket core plus a standalone developer
system browser, `app.requestClose()` from another thread, or `webfront::UIThread` where the frontend
accepts a secondary thread (WebView2); a host loop cannot share the main thread with an embedded
window. See [host integration](HOST_INTEGRATION.md).
A second native window of the same application (`app.openSecondaryWindow()`, #616) exists on WebKitGTK, WKWebView and WebView2; CEF
and the system browser refuse it with `std::logic_error` (`app.canShowSecondaryWindow()` tells it beforehand, also after `NativeOrBrowserFrontend` fell back to the browser), and the position of the window is left to the toolkit. The call waits
for the interface thread: a `cppFunction` callback runs it on `app.uiExecutor()` rather than hold the server's thread.
- **Native pseudoterminals (opt-in).** `webfront::Pty` uses a Unix PTY on Linux and macOS or ConPTY on Windows 10 version 1809 and later. The page adapter requires a loopback bind and the application’s own browser origin. See the [PTY guide and standalone example](PTY.md).
- **Developer environment.** `NativeApp::bootstrap("developer")` loads the verified, pinned
environment selected by `DeveloperReleaseData.hpp`. Its terminal provides `wf init`, `create`,
Expand Down
Loading
Loading