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
8 changes: 8 additions & 0 deletions .github/workflows/BuildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ jobs:
-DREPEAT=${{ (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'workflow_dispatch' && inputs.repeat_desktop_tests)) && '3' || '1' }}
-DLABEL_EXCLUDE=${{ (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'workflow_dispatch' && inputs.repeat_desktop_tests)) && 'none' || 'portability' }}
-P test/cmake/RunTestSuite.cmake
- name: Repeat WebKitGTK pointer tests with suite display sharing enabled
if: runner.os == 'Linux'
env: ${{ matrix.test_env }}
# These tests must still get private displays when invoked from the shared-display suite runner.
run: >-
xvfb-run -a env WEBFRONT_TEST_SHARED_DISPLAY=1
ctest --test-dir build --output-on-failure --no-tests=error
-R '^WebKitGTKAdapter-(choose-file|cancel-choose|close-with-dialog)$' --repeat until-fail:5
- name: Analyze CTest timings
if: always()
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ add_library(WebFront INTERFACE)
add_library(WebFront::WebFront ALIAS WebFront)
target_link_libraries(WebFront INTERFACE Threads::Threads)
if(WIN32)
target_link_libraries(WebFront INTERFACE shell32)
target_link_libraries(WebFront INTERFACE shell32 bcrypt)
endif()

# Static linkage for CEF compatibility (a global setting: only the top-level project may choose it)
Expand Down
2 changes: 1 addition & 1 deletion cmake/Frontends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function(webfront_add_browser_tests target frontend assets_directory lifecycle_t
if(WEBFRONT_FRONTEND_${frontend}_XVFB_LINUX AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(lifecycle_command "${XVFB_RUN_EXECUTABLE}" -a ${lifecycle_command})
endif()
foreach(mode no-bridge early-close rejected-ready navigation-failure path-encoding content-policy navigation-allow-list)
foreach(mode no-bridge early-close rejected-ready navigation-failure path-encoding content-policy navigation-allow-list view-association)
set(lifecycle_name "${frontend}Lifecycle-${mode}")
add_test(NAME ${lifecycle_name} COMMAND ${lifecycle_command} ${mode})
list(APPEND shared_tests "${lifecycle_name}")
Expand Down
14 changes: 14 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

## Unreleased

- Embedded frontends: a connection proves it comes from the view (#453, ADR-020 rule 3). Each launch creates a random
256-bit secret that the adapter gives to its own view at the start of every top-level document of the application's
origin (WKWebView `WKUserScript`, WebView2 `AddScriptToExecuteOnDocumentCreated`, WebKitGTK `WebKitUserScript`, CEF
extra browser information read by the renderer); `WebFront.js` takes it when it loads, removes it from the window and presents it in the handshake
(ADR-003, ADR-008). `UI::isEmbeddedView()` is true only for that connection and `UI::isLocalClient()` is the only
criterion of a local client: it is never deduced from the address. The system browser receives no secret and is never
local, unless the application sets `WebFrontConfig::trustLoopbackClients` (off by default, unsafe on a shared machine
or behind a proxy or tunnel). A frontend receives the proof through an optional
`open(address, port, file, policy, window, ViewLaunch)` overload. The handshake is accepted once per connection and a proof is copied only at the size of a secret; the
script handed to a view is refused (no association) for an origin or a secret that would need escaping; an IPv4 loopback
seen through a dual-stack socket counts as loopback. The injection script normalizes its expected origin with the browser's
URL parser, so expanded IPv6 and IPv6 with embedded IPv4 notation match `location.origin`. The association does not protect
against a script admitted into the view. WebView2, WebKitGTK and CEF code is covered by their own CI jobs; WKWebView is also tested here.

- HTTP server: dynamic routes (#454, ADR-020 prerequisite). `addRoute(prefix, handler)` on the application answers `GET` and
`HEAD` under an absolute prefix with a reply produced at run time (`http::RouteReply`: status, headers, exact or unknown
length, and a body read chunk by chunk). The handler and the reads run on a worker thread of the server, one chunk of
Expand Down
40 changes: 38 additions & 2 deletions docs/FRONTENDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ A frontend is a type with:
| `static void initialize()` | Called once successfully per frontend type, before the first `BasicWF` listener is created. A thrown exception aborts construction; the next construction retries. |
| `static void open(std::string_view port, std::string_view file)` | Called by `show()` / `openAndRun()` on the calling thread, while the HTTP server runs on its own thread. |
| `static void open(address, port, page, const ContentPolicy&)` (optional) | Preferred overload receiving the per-application [content policy](CONTENT_POLICY.md). |
| `static void open(address, port, page, const ContentPolicy&, const WindowOptions&, const ViewLaunch&)` (optional) | Richest overload: also receives the [view association](#view-association) proof of this launch. |
| `static constexpr Action action` | What `BasicWF` does once `open()` returns. |

- **Blocking.** With `Action::closeServerAfterOpen` (embedded windows), `open()` blocks until the window is closed, releases its session resources, and returns; `BasicWF` then stops the server and joins its thread, so `show()` returns after a clean shutdown. With `Action::keepServerRunning` (the system browser), the server keeps running after `open()` returns, until `stop()` or application destruction. The action determines server lifetime, not whether opening returns immediately: the built-in system-browser adapter waits for Enter in the console after launching the page and cannot observe when the external browser closes.
Expand All @@ -22,6 +23,40 @@ A frontend is a type with:
- **URL.** Built-in frontends also provide `open(address, port, file)`, which `BasicWF` prefers when available. Build the URL with `frontend::detail::applicationUrl(address, port, file)` in `frontend/Url.hpp`: it uses the configured address and preserves URI query/fragment syntax and existing percent escapes. Spaces and UTF-8 bytes are encoded. For literal filename delimiters use `%23`, `%3F` and `%25`. The two-argument overload uses `127.0.0.1`; wildcard binds open their matching loopback address.
- **Selection.** `webfront::WebFront` always uses the system browser. An application opts into another frontend with `webfront::WebFrontWithFrontend<...>`; enabling an embedded engine at configuration time never changes the default.

## View association

`UI::isEmbeddedView()` tells whether a connection comes from the view of an embedded frontend of this application, and
`UI::isLocalClient()` is the only criterion of a "local client" for system services (ADR-020, rule 3). A loopback address
proves nothing: a remote browser behind a local proxy or an SSH tunnel, or another user of the machine, arrives from it too.

Each launch creates a random 256-bit secret. A frontend that implements the `open(..., const ViewLaunch&)` overload gives it
to its own view, in the process, at the start of every top-level document whose origin is the application's
(`ViewLaunch::origin`). The page receives it as the window property `__webfrontView`; `WebFront.js` takes it when it loads, removes
it from the window and presents it in the handshake of every connection of that page (a reconnection included). The server
accepts one handshake per connection and compares the secret in constant time; a proof of another size than 64 characters is
not even copied. It is never served over HTTP and never put
on a command line or in a URL.

| Engine | Injection at the start of the document |
| --- | --- |
| WKWebView | `WKUserScript`, `WKUserScriptInjectionTimeAtDocumentStart`, main frame only |
| WebView2 | `AddScriptToExecuteOnDocumentCreated`, top-level documents of the origin (the script checks `window === window.top`); the first navigation waits for successful registration in its completion handler, with the startup watchdog active during that wait; registration failure fails the opening |
| WebKitGTK | `WebKitUserScript` at document start, top frame, no URL allow list (the script compares `location.origin`, port included) |
| CEF | extra browser information given to `CefBrowserView::CreateBrowserView`, read by the renderer process's `OnBrowserCreated` and defined on the window by `OnContextCreated` through the same script as the other engines, evaluated in the new context so that the page itself answers for its origin (the render process app is the one given to `CefExecuteProcess`; a separate helper executable must give it its own `ViewSecretRenderApp`) |

- The system browser receives no secret (a command line or a history could disclose it, and a remote browser would present
it first): its connections are never local, whatever their address. An application that accepts that risk sets
`WebFrontConfig::trustLoopbackClients`, which reads the peer address and is unsafe on a shared machine or behind a proxy or tunnel.
- `NativeOrBrowserFrontend` passes the proof to the native window only.
- The association does not protect against a script admitted into the view (ADR-008): it shares the authority of the bridge
and could read the property before `WebFront.js`. An adapter that cannot inject a script simply does not implement the overload.
- A custom frontend that wants services restricted to its own view implements the overload and applies
`webfront::detail::viewSecretScript(secret, origin)` (or the engine's equivalent) at the start of the document. The helper
returns an empty script, hence no association, unless the secret is lowercase hexadecimal and the origin a plain http origin;
give it `webfront::detail::browserOrigin(address, port)` (lowercase, without port 80), which `ViewLaunch::origin` already is.
The script uses the browser's `URL` parser to serialize that origin before comparing it with `location.origin`, including
IPv6 compression and embedded IPv4 notation (`::ffff:127.0.0.1` becomes `[::ffff:7f00:1]` as a URL host).

## Window title and size

`WebFrontConfig::window` (`webfront::WindowOptions`: `title`, `width`, `height`) sets the initial window of the
Expand Down Expand Up @@ -135,7 +170,7 @@ engines show it only after a user gesture on the page); its wiring is implemente

1. Implement the type in `include/webfront/frontend/` following the contract above and include it from `Frontend.hpp`. Keep platform headers behind the option's macro.
2. Add its support module and one `webfront_register_frontend(...)` entry in `cmake/Frontends.cmake`, using the fields below.
3. Extend `FrontendSelection` coverage and run the shared Jasmine and lifecycle suites. Enabling the engine on a `TEST_PLATFORMS` platform automatically registers the seven shared lifecycle cases; `WEBFRONT_TEST_FRONTEND` selects its C++ type in both runners.
3. Extend `FrontendSelection` coverage and run the shared Jasmine and lifecycle suites. Enabling the engine on a `TEST_PLATFORMS` platform automatically registers the eight shared lifecycle cases; `WEBFRONT_TEST_FRONTEND` selects its C++ type in both runners.

| Field | Meaning |
| --- | --- |
Expand All @@ -157,7 +192,7 @@ Registry order determines the initial cache default: the first enabled embedded

## Lifecycle tests

`test/web/FrontendLifecycle.cpp` runs the same seven cases under the selected embedded engine:
`test/web/FrontendLifecycle.cpp` runs the same eight cases under the selected embedded engine:

- `no-bridge`: close a page that never connects to the bridge and return from `show()`.
- `early-close`: close immediately from the page's first script, before any bridge connection.
Expand All @@ -166,6 +201,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.
- `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.

Each runs in a separate process as `<Frontend>Lifecycle-<case>`, with the registry's timeout, the
`web-integration` label and the same port lock as Jasmine. Linux CEF and WebKitGTK cases use Xvfb. On Linux CEF, run
Expand Down
12 changes: 12 additions & 0 deletions docs/adr/ADR-003-protocole-binaire-et-bornes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
| 1.12 | 2026-10-27 | Acceptée | Ambroise Leclerc | Identifiant de lot non nul, plafond d’opérations, codec canonique et nettoyage limité aux sous-arbres concernés (#380). | — |
| 1.13 | 2026-10-27 | Acceptée | Ambroise Leclerc | Rejet de PROPERTY value sur output pour préserver les identifiants de ses enfants (#380). | — |
| 1.14 | 2026-10-27 | Proposée | Ambroise Leclerc | Notifications de document et lectures groupées par les appels existants (#381). | [PR #394](https://github.com/ambroise-leclerc/WebFront/pull/394) |
| 1.15 | 2026-11-04 | Proposée | Ambroise Leclerc | La poignée de main peut porter, après ses deux octets, le secret de lancement d'une vue intégrée (#453, ADR-020). | À renseigner après intégration. |

## État et chronologie

Expand Down Expand Up @@ -65,6 +66,17 @@ La politique borne chaque message à 64 MiB par défaut ; que tout dépassement
refusé dès l’en-tête, fragments compris. Les trames de contrôle ont leur propre plafond de
125 octets.

## Poignée de main (`handshake`, code 0)

Le message compte deux octets : le code 0 et l'indicateur d'endianness de la page. Il peut être suivi du **secret de
lancement** d'une vue intégrée (ADR-020, règle 3) : 64 octets ASCII, les caractères hexadécimaux minuscules lus tels
quels. Sans secret, le message est celui des versions antérieures ; le serveur l'accepte (le pont reste réglé par
l'`Origin`, ADR-008) et la connexion n'est simplement pas associée à une vue. Le serveur compare le secret en temps
constant à celui de son lancement ; toute autre longueur ou valeur est ignorée sans fermer la connexion. `WebFront.js` ne
transmet que 64 caractères hexadécimaux ; il retire la propriété qui le porte de la fenêtre dès son chargement et le garde
pour les poignées de main de la page. Le serveur n'accepte qu'une poignée de main par connexion (la suivante est ignorée
et ne modifie pas l'association) et ne copie une preuve que si elle compte exactement 64 octets.

## Commande DOM (`domBatch`, code 5, version 1)

Cette section remplace le transport `wfDom.apply` des prototypes de l'[ADR-018](ADR-018-acces-au-dom.md) ;
Expand Down
7 changes: 7 additions & 0 deletions docs/adr/ADR-008-contenu-de-confiance-et-origines.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
| Version | Date | État | Auteur | Évolution | Révision Git |
| --- | --- | --- | --- | --- | --- |
| 1.0 | 2026-10-18 | Acceptée | Ambroise Leclerc | Décision initiale : politique commune des origines du pont, de la navigation et des fenêtres surgissantes. | [d59db71](https://github.com/ambroise-leclerc/WebFront/commit/d59db712f1d390abe1457a5046b904bd330b85cc) |
| 1.1 | 2026-11-04 | Proposée | Ambroise Leclerc | Le contrôle d'origine reste seul juge de l'accès au pont ; un secret de lancement, présenté à la poignée de main, distingue la vue d'un frontend intégré sans l'autoriser davantage (#453, ADR-020). | À renseigner après intégration. |

## État et chronologie

Expand Down Expand Up @@ -36,6 +37,12 @@ par défaut. Le navigateur système contrôle sa propre navigation ; le serveur
le contrôle du bridge. Les capacités des moteurs diffèrent, notamment les popups WKWebView.
WebFront cible du contenu de confiance, sans TLS ni authentification intégrés.

Que le secret de lancement d'une vue intégrée (#453) ne s'ajoute pas au contrôle d'origine : il ne donne aucun accès
au pont, que le contrôle d'`Origin` règle seul. Il ne sert qu'à savoir si la connexion vient de la vue de
l'application (`UI::isEmbeddedView()`), critère de « client local » des services (ADR-020, règle 3). Il ne protège pas
d'un script admis dans la vue, qui partage l'autorité du pont et pourrait le lire avant `WebFront.js`, ou le rejouer depuis une autre connexion tant que la page vit ; le navigateur
système n'en reçoit aucun.

## Options écartées et motifs

- Accepter toute origine par défaut : remplacé par le contrôle d’origine commun.
Expand Down
4 changes: 2 additions & 2 deletions docs/adr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ verification evidence remain in [PROJECT_STATUS](../PROJECT_STATUS.md).
| --- | --- | --- | --- | --- |
| [ADR-001](ADR-001-coeur-cpp23-header-only.md) | A header-only C++23 core embedded in the application | Accepted | 2020-04-19 | 1.5 — 2026-10-13 |
| [ADR-002](ADR-002-systemes-de-fichiers-composables.md) | An abstract, composable filesystem as the foundation for portability | Accepted | 2023-03-16 | 2.5 — 2026-11-03 |
| [ADR-003](ADR-003-protocole-binaire-et-bornes.md) | A shared, typed and bounded binary protocol | Accepted through 1.13; 1.14 proposed | 2022-02-06 | 1.14 — 2026-10-27 |
| [ADR-003](ADR-003-protocole-binaire-et-bornes.md) | A shared, typed and bounded binary protocol | Accepted through 1.13; 1.14 and 1.15 proposed | 2022-02-06 | 1.15 — 2026-11-04 |
| [ADR-004](ADR-004-appels-asynchrones-et-erreurs.md) | Asynchronous calls with deliberately asymmetric contracts | Accepted | 2022-02-06 | 2.4 — 2026-10-18 |
| [ADR-005](ADR-005-evolution-reseau-asio-stdnet.md) | From standalone ASIO to stdnet: anticipating standard networking without blocking progress | Accepted through 3.1; 3.2 proposed | 2022-01-21 | 3.2 — 2026-10-26 |
| [ADR-006](ADR-006-taches-structurees-et-arret.md) | Owning, cancelling and joining every task | Accepted | 2026-10-13 | 2.1 — 2026-10-25 |
| [ADR-007](ADR-007-frontends-explicites.md) | Explicit frontend selection and a shared lifecycle contract | Accepted | 2026-05-31 | 1.10 — 2026-10-20 |
| [ADR-008](ADR-008-contenu-de-confiance-et-origines.md) | Restricting bridge origins without promising a sandbox | Accepted | 2026-10-18 | 1.0 — 2026-10-18 |
| [ADR-008](ADR-008-contenu-de-confiance-et-origines.md) | Restricting bridge origins without promising a sandbox | Accepted through 1.0; 1.1 proposed | 2026-10-18 | 1.1 — 2026-11-04 |
| [ADR-009](ADR-009-modules-et-assets-reproductibles.md) | Serving modules locally and regenerating assets reproducibly | Accepted | 2023-03-16 | 2.5 — 2026-10-25 |
| [ADR-010](ADR-010-composants-et-outils-optionnels.md) | Extending WebFront through optional components and development tools | Accepted | 2026-10-14 | 1.7 — 2026-10-23 |
| [ADR-011](ADR-011-diagnostics-optionnels.md) | Confining mddlog behind an optional diagnostics façade | Accepted | 2026-10-01 | 1.2 — 2026-10-02 |
Expand Down
Loading
Loading