From 1d290c33a1062690ef4161b632ae36ac44658d11 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 21:58:57 +0100 Subject: [PATCH 01/10] Hide the windows of the developer integration (#544) Its six parts opened a visible WebView2 or WKWebView window each. They now use the quiet test frontend, as the driver does; WEBFRONT_TEST_VISIBLE=1 shows them again. --- docs/TEST_PERFORMANCE.md | 10 ++++++---- test/web/DeveloperTest.cpp | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index de57d04b..d95d3777 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -88,10 +88,12 @@ create a native window, real engine/controller and native event loop. Window vis lifecycle tests. Failed navigation, close, startup failures, watchdogs and cancellation remain real process tests. The two macOS executable/dylib registration orders remain separate images and processes, with hidden native windows. -The developer integration keeps its visible interactive terminal and Life preview. The macOS agent-application case -keeps one visible window because its contract asserts visibility and the absence of a Dock icon. The automated direct -transport contract harness retains one native window on each desktop. Linux's real windows are confined to Xvfb. This -budgets **two visible openings on Windows and three on macOS** in the standard configuration; engine-specific manual +The six parts of the developer integration hide their window like the driver does: their terminal and Life preview +are driven by the specs, not watched. The macOS agent-application case keeps one visible window because its contract +asserts visibility and the absence of a Dock icon. The automated direct transport contract harness retains one native +window on each desktop, and `webfront-agent` shows the window it automates in the `Automation*` cases: automation +stays visible to the person at the machine. Linux's real windows are confined to Xvfb. Apart from the agent's windows, +this budgets **one visible opening on Windows and two on macOS** in the standard configuration; engine-specific manual benchmarks and diagnostic runs are outside this budget. Restore all diagnostic windows with `WEBFRONT_TEST_VISIBLE=1`. A hidden WKWebView requires macOS 14+ (public inactive scheduling preference) and a WindowServer session; this is not a headless-engine substitute. diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 345f4b49..4911c851 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -1,5 +1,6 @@ #include "../../examples/life/Life.hpp" #include "../unit/TemporaryDirectory.hpp" +#include "../driver/TestFrontend.hpp" #include #include @@ -258,7 +259,8 @@ int main(int argc, char** argv) { webfront::test::TemporaryDirectory project; std::filesystem::copy(argv[1], project.path() / "fixtures", std::filesystem::copy_options::recursive); const auto integrity = readIntegrity(project.path() / "fixtures/provision.json"); - using App = webfront::BasicDeveloperApp; + // Hidden like the windows of the other suites; WEBFRONT_TEST_VISIBLE=1 shows them to follow a run. + using App = webfront::BasicDeveloperApp, FixturesFS>; // A part has no port of its own to keep: the parts run at the same time, each on the port the system gives it. webfront::WebFrontConfig config; if (mode.part != "all") From 91c569417a84cc6d73b5d3d7abc841307d41caeb Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 22:21:11 +0100 Subject: [PATCH 02/10] Keep the window of the workspace part of the developer integration visible (#544) The part measures the layout of the page and waits for rendering frames, which a hidden WKWebView does not deliver: it timed out after 180 s on macOS. The other five parts stay hidden. --- docs/TEST_PERFORMANCE.md | 7 ++++--- test/web/CMakeLists.txt | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index d95d3777..f2eca13b 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -88,12 +88,13 @@ create a native window, real engine/controller and native event loop. Window vis lifecycle tests. Failed navigation, close, startup failures, watchdogs and cancellation remain real process tests. The two macOS executable/dylib registration orders remain separate images and processes, with hidden native windows. -The six parts of the developer integration hide their window like the driver does: their terminal and Life preview -are driven by the specs, not watched. The macOS agent-application case keeps one visible window because its contract +Five of the six parts of the developer integration hide their window like the driver does: their terminal and Life +preview are driven by the specs, not watched. The `workspace` part measures the layout of the page and needs the +rendering frames of a displayed window (hidden, it timed out on macOS), so it shows its own. The macOS agent-application case keeps one visible window because its contract asserts visibility and the absence of a Dock icon. The automated direct transport contract harness retains one native window on each desktop, and `webfront-agent` shows the window it automates in the `Automation*` cases: automation stays visible to the person at the machine. Linux's real windows are confined to Xvfb. Apart from the agent's windows, -this budgets **one visible opening on Windows and two on macOS** in the standard configuration; engine-specific manual +this budgets **two visible openings on Windows and three on macOS** in the standard configuration; engine-specific manual benchmarks and diagnostic runs are outside this budget. Restore all diagnostic windows with `WEBFRONT_TEST_VISIBLE=1`. A hidden WKWebView requires macOS 14+ (public inactive scheduling preference) and a WindowServer session; this is not a headless-engine substitute. diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index a73358be..f262a46b 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -318,6 +318,11 @@ if(_browser_tests_available) set_tests_properties(${_name} PROPERTIES LABELS "web-integration" TIMEOUT 180 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures) webfront_use_own_profile(${_name} developer-${_part}) + if(_part STREQUAL "workspace") + # The part measures the layout of the page and waits for rendering frames, which a hidden WKWebView does not + # deliver (it timed out on macOS): its window is shown, the only one of the developer integration. + set_property(TEST ${_name} APPEND PROPERTY ENVIRONMENT "WEBFRONT_TEST_VISIBLE=1") + endif() # DeveloperTest uses CEFFrontend's default profile beside the executable, as do the other native browser # tests holding this lock. CEF forwards concurrent launches with that profile to an existing process. if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") From 8cc7400308cabf8e68b3a8eb646bbe31fe80a414 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Wed, 11 Nov 2026 23:41:15 +0100 Subject: [PATCH 03/10] Reuse visible windows for developer integration and compatible wf commands (#544) --- docs/CHANGELOG.md | 1 + docs/TEST_PERFORMANCE.md | 41 ++-- docs/TEST_TIERS.md | 9 +- docs/WEBVIEW2.md | 6 +- docs/WKWEBVIEW.md | 7 +- test/cmake/CheckDeveloperSessionFailure.cmake | 30 +++ test/cmake/DriverSessions.cmake | 2 +- test/driver/TestFrontend.hpp | 23 +- test/driver/WfDriver.hpp | 2 +- test/web/CMakeLists.txt | 85 ++++++- test/web/DeveloperTest.cpp | 222 ++++++++++++++---- test/web/FrontendLifecycle.cpp | 6 +- test/web/LifeEmbeddedTest.cpp | 2 +- test/web/WKWebViewLifecycle.cpp | 2 +- test/web/WebView2Lifecycle.cpp | 10 +- test/web/developer-specs.mjs | 5 +- 16 files changed, 344 insertions(+), 109 deletions(-) create mode 100644 test/cmake/CheckDeveloperSessionFailure.cmake diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 2db31faa..75a09cdf 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -12,6 +12,7 @@ these entries stays in the GitHub releases and the Git history. ### Changed +- Keep automated browser windows visible and reuse one window for the six developer integration parts and additional compatible wf commands (#544, #556, `docs/TEST_PERFORMANCE.md`). - Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind a tab on the right edge that shows the session's state, and keeps its session when collapsed. Its shortcut is F9, or the manifest's new optional `developer.terminalShortcut`. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). ### Fixed diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index f2eca13b..41356132 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -21,6 +21,9 @@ shared within each group, in this order: | JourneyBuildSession | check, test, build, embed | | JourneyRestoreSession | missing offline cache, restore, verified offline cache | | SelfBuildSession | install, build, developer specs, repeat build, permissions refusal | +| WebSuiteSession | install the browser suite, React adapter check and build | +| PublicationSession | React package, services package, site build and repeat | +| WfDriverManifestSession | initialize and install with the manifest in a subdirectory | The Journey file preparation and cache deletion remain CTest fixtures between sessions. Self-build reproducibility, refresh, publication and tampering checks retain their own dependencies. The driver writes a JSON result per command; @@ -83,20 +86,30 @@ the functional owned/shared-window scenario. ## Visible windows and retained lifecycle contracts -Driver, embedded-distribution and compatible lifecycle windows use `visible=false` on WebView2/WKWebView. They still -create a native window, real engine/controller and native event loop. Window visibility is asserted in the native -lifecycle tests. Failed navigation, close, startup failures, watchdogs and cancellation remain real process tests. -The two macOS executable/dylib registration orders remain separate images and processes, with hidden native windows. - -Five of the six parts of the developer integration hide their window like the driver does: their terminal and Life -preview are driven by the specs, not watched. The `workspace` part measures the layout of the page and needs the -rendering frames of a displayed window (hidden, it timed out on macOS), so it shows its own. The macOS agent-application case keeps one visible window because its contract -asserts visibility and the absence of a Dock icon. The automated direct transport contract harness retains one native -window on each desktop, and `webfront-agent` shows the window it automates in the `Automation*` cases: automation -stays visible to the person at the machine. Linux's real windows are confined to Xvfb. Apart from the agent's windows, -this budgets **two visible openings on Windows and three on macOS** in the standard configuration; engine-specific manual -benchmarks and diagnostic runs are outside this budget. Restore all diagnostic windows with -`WEBFRONT_TEST_VISIBLE=1`. A hidden WKWebView requires macOS 14+ (public inactive scheduling preference) and a WindowServer session; this is not a headless-engine substitute. +Browser tests keep their windows visible by default on Windows and macOS. Their rendering is a daily visual check; +`WEBFRONT_TEST_VISIBLE=1` is no longer needed. Reduce repeated openings by reusing a window, rather than hiding it. +Linux's real windows remain on the suite's Xvfb display. Explicit tests of hidden-window behavior still use that option. + +`DeveloperBrowserSession` opens **one visible native window for all six developer integration parts**, instead of six. +It displays each part in a fresh, full-size iframe, with its own native application, temporary project, assigned loopback +port and origin. The previous frame is removed before the next part loads; its Workers, listeners and bridge go away. +All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. +The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. Closing the window early, +a missing result or an expired per-part native deadline fails the session. A small fault-injection session verifies +that an unsuccessful first part does not skip the later reports. Life's generated header and the terminal's cancellation +check still come from their respective parts. + +The driver groups above each use one visible window. This change reduces the three WebSuite/React commands from three +openings to one, publication's four commands from four to one, and manifest-directory init/install from two to one. +With sessions disabled, the original individual commands and the six separate developer windows remain available. +Developer parts now run sequentially within their window; this saves native startup/teardown and concurrent engine +memory, but can take longer than six parallel windows. Compare full-suite wall time as well as openings before claiming +a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. + +Failed navigation, native close, startup failures, watchdogs and cancellation remain real process tests. The two macOS +executable/dylib registration orders remain separate images and processes. `ConsumerJasmine` modes and `Automation*` +retain their own visible windows where they have not yet been grouped; no whole-suite budget of two or three visible +openings is claimed. Hidden WKWebView tests require macOS 14+ and a WindowServer session. ## Profiling and interpreting the numbers diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index 47fbfb0f..0961397e 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -31,8 +31,13 @@ ctest --test-dir build -R DeveloperBrowserIntegration -V # CTest prints t ctest --test-dir build -R DeveloperBrowserIntegration -N -V # prints the command to run `developer_integration` directly ``` -Run `developer_integration` with a fixtures directory and an output directory but no `--part=` to play every part in one -session, as the test did before it was cut; `--part=app|scripts|typescript|jasmine|terminal` plays one. +`DeveloperBrowserSession` displays all six parts in one visible native window, with a fresh page, project and origin per +part. `DeveloperBrowserIntegration*` keep their original names and check its independent reports. Run +`developer_integration --session` directly to follow the shared window. Configure +`-DWEBFRONT_TEST_SESSIONS=OFF` to compare the separate-process path. + +Run `developer_integration` with a fixtures directory and an output directory but no `--part=` for the older mode in +which all parts share one project; `--part=app|scripts|typescript|jasmine|terminal|workspace` plays one in its own visible window. ```bash ``` diff --git a/docs/WEBVIEW2.md b/docs/WEBVIEW2.md index f771aa6d..0cabab01 100644 --- a/docs/WEBVIEW2.md +++ b/docs/WEBVIEW2.md @@ -58,6 +58,6 @@ The shared `path-encoding` lifecycle case opens `encoded path %23.html` under ev The per-opening options include `visible` (default `true`). Setting it to `false` creates the real native window and engine without presenting or focusing the window. This retains the native event loop and startup/navigation deadlines; -it does not provide a sandbox or a headless engine. On macOS a WindowServer session is still required. The test driver -uses this option and supports `WEBFRONT_TEST_VISIBLE=1` for interactive diagnostics. -See [TEST_PERFORMANCE](TEST_PERFORMANCE.md) for the visible-window budget and retained lifecycle cases. +it does not provide a sandbox or a headless engine. Automated tests keep their windows visible by default and share +compatible sessions to reduce repeated openings. Explicit tests of hidden-window behavior still use this option. +See [TEST_PERFORMANCE](TEST_PERFORMANCE.md) for the shared sessions and retained lifecycle cases. diff --git a/docs/WKWEBVIEW.md b/docs/WKWEBVIEW.md index 8a4af013..5749eb81 100644 --- a/docs/WKWEBVIEW.md +++ b/docs/WKWEBVIEW.md @@ -194,9 +194,10 @@ Foundation type boundary, handler lifetime, origins and custom resource schemes. The per-opening options include `visible` (default `true`). Setting it to `false` creates the real native window and engine without presenting or focusing the window. This retains the native event loop and startup/navigation deadlines; -it does not provide a sandbox or a headless engine. On macOS a WindowServer session is still required. The test driver -uses this option and supports `WEBFRONT_TEST_VISIBLE=1` for interactive diagnostics. -See [TEST_PERFORMANCE](TEST_PERFORMANCE.md) for the visible-window budget and retained lifecycle cases. +it does not provide a sandbox or a headless engine. On macOS a WindowServer session is still required. Automated tests +keep their windows visible by default and share compatible sessions to reduce repeated openings. Explicit tests of +hidden-window behavior still use this option. See [TEST_PERFORMANCE](TEST_PERFORMANCE.md) for the shared sessions and +retained lifecycle cases. Hidden sessions require macOS 14+ and use the public `WKPreferences::inactiveSchedulingPolicy` value `None` so asynchronous bridge and Worker work continues after the load event. Visible sessions retain macOS 13.3 support. diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake new file mode 100644 index 00000000..afe35273 --- /dev/null +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -0,0 +1,30 @@ +# Exercise the session coordinator's failure paths without compiling the application six times. +file(MAKE_DIRECTORY "${WORK}/fixtures") +file(WRITE "${WORK}/fixtures/provision.json" "{\"integrity\":\"sha512-unused-by-the-coordinator-spec\"}") +file(WRITE "${WORK}/fixtures/run.mjs" [=[ +await webFront.ready; +const part = await webFront.cppFunction('test.part')(); +// The first case fails. Later cases must still run; terminal deliberately reports failure too, without starting a command. +await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', `session-failure ${part}`); +parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); +]=]) +execute_process(COMMAND ${PREFIX} "${PROGRAM}" "${WORK}/fixtures" "${WORK}/output" --session + RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 45) +message(STATUS "${output}${errors}") +if(NOT status STREQUAL "1") + message(FATAL_ERROR "A session with a failed first part must exit with 1, got ${status}") +endif() +foreach(part app scripts typescript jasmine terminal workspace) + file(READ "${WORK}/output/results/${part}.json" report) + string(JSON code GET "${report}" exitCode) + set(expected 0) + if(part STREQUAL "app" OR part STREQUAL "terminal") + set(expected 1) + endif() + if(NOT code EQUAL expected OR NOT output MATCHES "session-failure ${part}") + message(FATAL_ERROR "Lost or incorrect result for ${part}: ${report}") + endif() +endforeach() +if(NOT output MATCHES "nativeWindows=1 parts=6") + message(FATAL_ERROR "The session did not reach its final summary") +endif() diff --git a/test/cmake/DriverSessions.cmake b/test/cmake/DriverSessions.cmake index 76acb0d5..d8f1dd80 100644 --- a/test/cmake/DriverSessions.cmake +++ b/test/cmake/DriverSessions.cmake @@ -55,7 +55,7 @@ function(webfront_add_driver_suite group) add_test(NAME ${group} COMMAND ${_wf_run} ${options} -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) webfront_set_browser_test_properties(${group} "${CMAKE_CURRENT_SOURCE_DIR}" ${ctest_timeout}) set(lock "${ARG_PROJECT}") - if(group STREQUAL "SelfBuildSession") + if(group STREQUAL "SelfBuildSession" OR group STREQUAL "PublicationSession") set(lock self-build-project) endif() set_tests_properties(${group} PROPERTIES FIXTURES_REQUIRED "${ARG_REQUIRES}" FIXTURES_SETUP ${group} diff --git a/test/driver/TestFrontend.hpp b/test/driver/TestFrontend.hpp index 27cdbd93..605e1fae 100644 --- a/test/driver/TestFrontend.hpp +++ b/test/driver/TestFrontend.hpp @@ -6,21 +6,12 @@ namespace webfront::testdriver { inline bool diagnosticWindows() { -#ifdef _MSC_VER - char* raw = nullptr; - std::size_t size = 0; - if (_dupenv_s(&raw, &size, "WEBFRONT_TEST_VISIBLE") != 0) - throw std::runtime_error("Cannot read WEBFRONT_TEST_VISIBLE"); - const std::unique_ptr value(raw, std::free); - return value && std::string_view(value.get()) == "1"; -#else - const auto* value = std::getenv("WEBFRONT_TEST_VISIBLE"); - return value && std::string_view(value) == "1"; -#endif + // Rendering remains visible during daily runs. Reduce window openings by sharing sessions. + return true; } template -struct QuietFrontend : Frontend { +struct TestFrontend : Frontend { using Frontend::open; static void open(std::string_view port, std::string_view page) { open("127.0.0.1", port, page, ContentPolicy{}); @@ -32,8 +23,12 @@ struct QuietFrontend : Frontend { open(address, port, page, policy, window, ViewLaunch{}); } // The launch proof reaches the engine as it does in an application: the suite runs the same association. - static void open(std::string_view address, std::string_view port, std::string_view page, const ContentPolicy& policy, const WindowOptions& window, - const ViewLaunch& launch) { + static void open(std::string_view address, + std::string_view port, + std::string_view page, + const ContentPolicy& policy, + const WindowOptions& window, + const ViewLaunch& launch) { if constexpr (std::is_same_v) { frontend::WKWebViewOptions options; options.contentPolicy = policy; diff --git a/test/driver/WfDriver.hpp b/test/driver/WfDriver.hpp index e8df264f..990cf868 100644 --- a/test/driver/WfDriver.hpp +++ b/test/driver/WfDriver.hpp @@ -84,7 +84,7 @@ template using DriverFrontend = std::conditional_t, frontend::WebView2FrontendWithOptions, std::conditional_t, - QuietFrontend, + TestFrontend, std::conditional_t, DriverCEFFrontend, Frontend>>>; using namespace std::chrono_literals; diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index f262a46b..d3b29af2 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -305,23 +305,49 @@ if(_browser_tests_available) endif() set(_developer_command "${_developer_xvfb}" -a ${_developer_command}) endif() - # One long script (developer-specs.mjs) would run for two minutes on its own: it is cut into parts that start from their - # own project and run in parallel (#435). `app` also generates the header that LifeEmbeddedBuild compiles. Each part - # listens on a port the system picks, so none of them holds webfront_port_9002. + # One visible native window hosts fresh pages/projects/origins for all six parts. The original CTest names check + # independent reports; sessions OFF retains the separate-process path for diagnosis and timing comparisons. + if(WEBFRONT_TEST_SESSIONS) + add_test(NAME DeveloperBrowserSession COMMAND ${_developer_command} + "${_fixtures}" "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" --session) + set_tests_properties(DeveloperBrowserSession PROPERTIES LABELS "web-integration" TIMEOUT 1110 + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures + FIXTURES_SETUP DeveloperBrowserSession) + webfront_use_own_profile(DeveloperBrowserSession developer-session) + set(_developer_session_prefix "") + if(_developer_xvfb) + set(_developer_session_prefix "${_developer_xvfb};-a") + endif() + add_test(NAME DeveloperBrowserSessionFailure COMMAND ${CMAKE_COMMAND} + -DPROGRAM=$ "-DPREFIX=${_developer_session_prefix}" + -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-session-failure + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperSessionFailure.cmake) + set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES LABELS "web-integration" TIMEOUT 60) + webfront_use_own_profile(DeveloperBrowserSessionFailure developer-session-failure) + if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") + set_tests_properties(DeveloperBrowserSession PROPERTIES RESOURCE_LOCK webfront_port_9002) + set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES RESOURCE_LOCK webfront_port_9002) + endif() + endif() foreach(_part app scripts typescript jasmine terminal workspace) set(_name DeveloperBrowserIntegration) if(NOT _part STREQUAL "app") set(_name DeveloperBrowserIntegration-${_part}) endif() - add_test(NAME ${_name} COMMAND ${_developer_command} - "${_fixtures}" "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" --part=${_part}) + if(WEBFRONT_TEST_SESSIONS) + add_test(NAME ${_name} COMMAND "${CMAKE_COMMAND}" + "-DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/developer-generated/results/${_part}.json" + -DEXPECT_STATUS=0 -P "${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake") + else() + add_test(NAME ${_name} COMMAND ${_developer_command} + "${_fixtures}" "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" --part=${_part}) + endif() set_tests_properties(${_name} PROPERTIES LABELS "web-integration" TIMEOUT 180 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures) - webfront_use_own_profile(${_name} developer-${_part}) - if(_part STREQUAL "workspace") - # The part measures the layout of the page and waits for rendering frames, which a hidden WKWebView does not - # deliver (it timed out on macOS): its window is shown, the only one of the developer integration. - set_property(TEST ${_name} APPEND PROPERTY ENVIRONMENT "WEBFRONT_TEST_VISIBLE=1") + if(WEBFRONT_TEST_SESSIONS) + set_property(TEST ${_name} APPEND PROPERTY FIXTURES_REQUIRED DeveloperBrowserSession) + else() + webfront_use_own_profile(${_name} developer-${_part}) endif() # DeveloperTest uses CEFFrontend's default profile beside the executable, as do the other native browser # tests holding this lock. CEF forwards concurrent launches with that profile to an existing process. @@ -387,6 +413,8 @@ if(_browser_tests_available) set(group JourneyBuildSession) elseif(name MATCHES "^Journey(OfflineMissing|Restore|OfflineVerified)$") set(group JourneyRestoreSession) + elseif(name MATCHES "^WfDriverManifestDirectory(Install)?$") + set(group WfDriverManifestSession) endif() endif() if(group) @@ -396,6 +424,9 @@ if(_browser_tests_available) endif() webfront_record_suite_case(${group} ${name} ${status} "${command}" ${case_timeout}) list(APPEND options -DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/driver-sessions/${group}/${name}.json) + if(ARG_FRESH_PROJECT) + list(APPEND options -DPROJECT=${ARG_FRESH_PROJECT}) + endif() endif() add_test(NAME ${name} COMMAND ${_wf_run} ${options} -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) webfront_set_browser_test_properties(${name} "${CMAKE_CURRENT_SOURCE_DIR}" 120) @@ -548,24 +579,41 @@ if(_browser_tests_available) -DLIFE_REACT=${PROJECT_SOURCE_DIR}/examples/life/react/main.tsx -P ${PROJECT_SOURCE_DIR}/test/cmake/PrepareWfProject.cmake) set_tests_properties(WebSuiteProject PROPERTIES FIXTURES_SETUP WebSuiteProject LABELS "web-integration" TIMEOUT 30) + set(_suite_install_report) + if(WEBFRONT_TEST_SESSIONS) + webfront_record_suite_case(WebSuiteSession WebSuiteInstall 0 install 100) + set(_suite_install_report -DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/driver-sessions/WebSuiteSession/WebSuiteInstall.json) + endif() add_test(NAME WebSuiteInstall COMMAND ${_developer_xvfb_prefix} ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DDRIVER=$ -DPROJECT=${_suite_project} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/wf-driver-work -DENVIRONMENT= -DINTEGRITY= -DREGISTRY=${_registry} -DPROFILE=${CMAKE_CURRENT_BINARY_DIR}/wf-profiles/WebSuiteInstall -DEXPECT_STATUS=0 -DCOMMAND=install "-DEXPECT_OUTPUT=Installed [0-9]+ packages" - -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) + ${_suite_install_report} -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) webfront_set_browser_test_properties(WebSuiteInstall "${CMAKE_CURRENT_SOURCE_DIR}" 120) set_tests_properties(WebSuiteInstall PROPERTIES FIXTURES_REQUIRED "WebSuiteProject;TestRegistry" FIXTURES_SETUP WebSuiteInstalled RESOURCE_LOCK "${_suite_project}") foreach(action Check Build) string(TOLOWER "${action}" command) + set(_suite_action_report) + if(WEBFRONT_TEST_SESSIONS) + webfront_record_suite_case(WebSuiteSession ReactAdapter${action} 0 "${command}" 100) + set(_suite_action_report -DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/driver-sessions/WebSuiteSession/ReactAdapter${action}.json) + endif() add_test(NAME ReactAdapter${action} COMMAND ${_developer_xvfb_prefix} ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -DDRIVER=$ -DPROJECT=${_suite_project} -DWORK=${CMAKE_CURRENT_BINARY_DIR}/wf-driver-work -DENVIRONMENT= -DINTEGRITY= -DREGISTRY=${_registry} -DPROFILE=${CMAKE_CURRENT_BINARY_DIR}/wf-profiles/ReactAdapter${action} - -DEXPECT_STATUS=0 -DCOMMAND=${command} -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) + -DEXPECT_STATUS=0 -DCOMMAND=${command} ${_suite_action_report} -P ${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake) webfront_set_browser_test_properties(ReactAdapter${action} "${CMAKE_CURRENT_SOURCE_DIR}" 120) set_tests_properties(ReactAdapter${action} PROPERTIES FIXTURES_REQUIRED WebSuiteInstalled RESOURCE_LOCK "${_suite_project}") endforeach() + if(WEBFRONT_TEST_SESSIONS) + foreach(name WebSuiteInstall ReactAdapterCheck ReactAdapterBuild) + set_property(TEST ${name} APPEND PROPERTY FIXTURES_REQUIRED WebSuiteSession) + endforeach() + webfront_add_driver_suite(WebSuiteSession PROJECT "${_suite_project}" PINNED + REQUIRES WebSuiteProject TestRegistry) + endif() set_tests_properties(ReactAdapterBuild PROPERTIES FIXTURES_SETUP ReactAdapterBuilt) add_test(NAME ReactAdapterPages COMMAND ${CMAKE_COMMAND} -DBUILD=${_suite_project}/.webfront/developer/build -DOUTPUT=${_suite_project}/pages/react-example @@ -603,6 +651,10 @@ if(_browser_tests_available) set(group "") if(WEBFRONT_TEST_SESSIONS AND name MATCHES "^(SelfBuildInstall|SelfBuild|DeveloperSpecs|SelfBuildRepeat|SelfBuildOutsidePermissions)$") set(group SelfBuildSession) + elseif(WEBFRONT_TEST_SESSIONS AND name MATCHES "^(ReactAdapterPackage|ServicesPackage|SelfBuildSite|SelfBuildSiteRepeat)$") + set(group PublicationSession) + endif() + if(group) webfront_record_suite_case(${group} ${name} ${status} "${command}" ${driver_timeout}) list(APPEND options -DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/driver-sessions/${group}/${name}.json) endif() @@ -700,6 +752,15 @@ if(_browser_tests_available) webfront_add_driver_suite(JourneyRestoreSession PROJECT "${_journey}" REQUIRES JourneyCacheEmptied DeveloperFixtures) webfront_add_driver_suite(SelfBuildSession PROJECT "${_self_project}" MANIFEST_DIR js/developer PINNED REQUIRES SelfBuildProject TestRegistry) + webfront_add_driver_suite(PublicationSession PROJECT "${_self_project}" MANIFEST_DIR js/developer PINNED + REQUIRES SelfBuilt) + add_test(NAME WfDriverManifestSessionProject COMMAND ${CMAKE_COMMAND} + -DPROJECT=${CMAKE_CURRENT_BINARY_DIR}/wf-driver-manifest-dir + -P ${PROJECT_SOURCE_DIR}/test/cmake/PrepareEmptyProject.cmake) + set_tests_properties(WfDriverManifestSessionProject PROPERTIES FIXTURES_SETUP WfDriverManifestSessionProject + LABELS "web-integration" TIMEOUT 30) + webfront_add_driver_suite(WfDriverManifestSession PROJECT "${CMAKE_CURRENT_BINARY_DIR}/wf-driver-manifest-dir" + MANIFEST_DIR config/wf REQUIRES WfDriverManifestSessionProject DeveloperFixtures) endif() # Compile the maintained application's actual browser-generated header, then run it without a project root. add_executable(life_embedded EXCLUDE_FROM_ALL LifeEmbeddedTest.cpp) diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 4911c851..5cfdade4 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -1,6 +1,6 @@ #include "../../examples/life/Life.hpp" +#include "../driver/DriverSuite.hpp" #include "../unit/TemporaryDirectory.hpp" -#include "../driver/TestFrontend.hpp" #include #include @@ -11,6 +11,7 @@ #include #include #include +#include #include namespace { @@ -29,7 +30,7 @@ std::string readFixtureText(const std::filesystem::path& path) { class FixturesFS { public: - explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) {} + explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) { } std::optional open(std::filesystem::path path) const { const auto relative = path.relative_path().generic_string(); if (!relative.starts_with("fixtures/")) @@ -58,7 +59,7 @@ std::string readIntegrity(const std::filesystem::path& config) { } template -void registerCallbacks(App& app, const std::filesystem::path& project, std::atomic& passed) { +void registerCallbacks(App& app, const std::filesystem::path& project, std::atomic& passed, std::function reported = {}) { app.cppFunction("life.step", &webfront::demo::nextLife); app.cppFunction("test.header", [project](std::string name) { if (name != "LifeUI") @@ -84,9 +85,11 @@ void registerCallbacks(App& app, const std::filesystem::path& project, std::atom app.cppFunction("test.progress", [](std::string message) { std::cout << "Developer integration: " << message << std::endl; }); - app.cppFunction("test.report", [&passed](bool success, std::string message) { + app.cppFunction("test.report", [&passed, reported = std::move(reported)](bool success, std::string message) { std::cout << message << std::endl; passed.store(success); + if (reported) + reported(); }); } @@ -223,8 +226,8 @@ Mode parseMode(std::string_view argument) { mode.part = "app"; } else if (argument.starts_with("--part=")) { mode.part = std::string(argument.substr(7)); - if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal" && - mode.part != "workspace") + if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal" + && mode.part != "workspace") throw std::invalid_argument("Unknown part of the developer test: " + mode.part); } else { throw std::invalid_argument("Unknown smoke-test mode"); @@ -246,67 +249,188 @@ void copyHeaders(const std::filesystem::path& project, const std::filesystem::pa } constexpr auto runScript = - "import('/fixtures/run.mjs').catch(async e => { await webFront.cppFunction('test.report')(false, String(e.stack || e)); window.close(); });"; -} // namespace + "import('/fixtures/run.mjs').catch(async e => { await webFront.cppFunction('test.report')(false, String(e.stack || e));" + " if (location.search === '?developer-session' && parent !== self) parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin);" + " else window.close(); });"; -int main(int argc, char** argv) { - try { - // CEF child processes must dispatch before interpreting application arguments or creating files. - webfront::detail::ensureFrontendInitialized(); - if (argc != 3 && argc != 4) - throw std::invalid_argument("Expected fixture directory, header output directory and optional --public or --part="); - const Mode mode = parseMode(argc == 4 ? std::string_view(argv[3]) : std::string_view{}); - webfront::test::TemporaryDirectory project; - std::filesystem::copy(argv[1], project.path() / "fixtures", std::filesystem::copy_options::recursive); - const auto integrity = readIntegrity(project.path() / "fixtures/provision.json"); - // Hidden like the windows of the other suites; WEBFRONT_TEST_VISIBLE=1 shows them to follow a run. - using App = webfront::BasicDeveloperApp, FixturesFS>; - // A part has no port of its own to keep: the parts run at the same time, each on the port the system gives it. - webfront::WebFrontConfig config; - if (mode.part != "all") - config.port = "0"; - App app{project.path(), config}; - std::atomic passed{false}; - registerCallbacks(app, project.path(), passed); - auto states = std::make_shared(); - webfront::Commands commands{app}; +// A part keeps its original project, origin, bridge and command ownership. Only the native window is shared. +class Part { + using App = webfront::BasicDeveloperApp; + +public: + Part(const std::filesystem::path& fixtures, Mode selected, webfront::testdriver::DriverDeadline* deadline = nullptr) + : app(project.path(), {.port = "0"}), mode(std::move(selected)), states(std::make_shared()), commands(app) { + std::filesystem::copy(fixtures, project.path() / "fixtures", std::filesystem::copy_options::recursive); + registerCallbacks(app, project.path(), passed, [this, deadline] { + if (reported.exchange(true)) + throw std::runtime_error("A developer part reported twice"); + if (deadline) + deadline->beginCase(180s); + }); registerCommands(commands, states); - app.cppFunction("test.command", [states](std::string tag) { - return states->get(tag); + app.cppFunction("test.command", [owned = states](std::string tag) { + return owned->get(tag); }); - app.cppFunction("test.release", [states](std::string tag) { - states->release(tag); + app.cppFunction("test.release", [owned = states](std::string tag) { + owned->release(tag); }); app.cppFunction("test.part", [part = mode.part] { return part; }); - app.cppFunction("test.browsers", [&app] { + app.cppFunction("test.browsers", [this] { return static_cast(app.connectedBrowsers()); }); - bootstrapApp(app, mode, integrity); - auto subscription = app.subscribeUIStarted([injected = false](App::UI ui) mutable { + bootstrapApp(app, mode, readIntegrity(project.path() / "fixtures/provision.json")); + subscription = app.subscribeUIStarted([injected = false](App::UI ui) mutable { if (!std::exchange(injected, true)) ui.addScript(runScript); }); + } + + ~Part() { + states->releaseAll(); + app.stop(); + if (server.joinable()) + server.join(); + // Drain while the commands, callback state and project are still alive. try { - app.show(); - } catch (...) { - states->releaseAll(); - throw; + app.shutdown(); + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; } - // The test ends while the "final" command runs: shutdown drains it. + } + + void start() { + server = std::jthread([this] { + app.run(); + }); + } + void show() { + app.show(); + } + std::string origin() const { + return "http://127.0.0.1:" + std::string(app.port()); + } + std::string_view port() const { + return app.port(); + } + const std::filesystem::path& directory() const { + return project.path(); + } + + bool finish(const std::filesystem::path& output) { states->releaseAll(); + app.stop(); + if (server.joinable()) + server.join(); app.shutdown(); - if (!passed.load()) - return 1; - // The command running at shutdown belongs to the terminal part; the generated header, to the application part. - if (mode.runs("terminal") && !mode.publicDistribution && states->get("final") != "cancelled") { + bool success = reported.load() && passed.load(); + if (success && mode.runs("terminal") && !mode.publicDistribution && states->get("final") != "cancelled") { std::cerr << "The command running at shutdown was not drained: " << states->get("final") << '\n'; - return 1; + success = false; + } + if (success && mode.runs("app")) + copyHeaders(project.path(), output); + return success; + } + +private: + webfront::test::TemporaryDirectory project; + App app; + Mode mode; + std::atomic passed{false}, reported{false}; + std::shared_ptr states; + webfront::Commands commands; + webfront::UISubscription subscription; + std::jthread server; +}; + +int runSession(const std::filesystem::path& fixtures, const std::filesystem::path& output) { + const auto started = std::chrono::steady_clock::now(); + constexpr std::string_view names[]{"app", "scripts", "typescript", "jasmine", "terminal", "workspace"}; + std::filesystem::create_directories(output / "results"); + // Remove only this invocation's own reports, so a crash cannot leave a previous success behind. + for (const auto name : names) + std::filesystem::remove(output / "results" / (std::string(name) + ".json")); + webfront::testdriver::DriverDeadline deadlines(1080s); + deadlines.beginCase(180s); + std::vector> parts; + webfront::ContentPolicy policy; + std::string urls = "["; + for (const auto name : names) { + auto part = std::make_unique(fixtures, Mode{false, std::string(name)}, &deadlines); + policy.navigationAllowedOrigins.push_back(part->origin()); + urls += (urls.size() > 1 ? "," : "") + webfront::json::quote(part->origin() + "/webfront-bootstrap.html?developer-session"); + parts.push_back(std::move(part)); + } + urls += "]"; + const auto page = parts.front()->directory() / "fixtures/developer-suite.html"; + std::ofstream html(page, std::ios::binary); + html << R"HTML(Developer integration + +
)HTML"; + html.close(); + if (!html) + throw std::runtime_error("Cannot write developer session page"); + for (auto& part : parts) + part->start(); + // The native bound applies even when a renderer blocks its JavaScript timers. + std::jthread watchdog([&](std::stop_token stop) { + if (deadlines.expired(stop)) { + std::cerr << "Developer session exceeded its per-part deadline\n"; + std::cerr.flush(); + std::_Exit(1); } - if (mode.runs("app")) - copyHeaders(project.path(), argv[2]); - return 0; + }); + std::cout << "Developer session: one visible native window, six isolated pages\n"; + webfront::frontend::detail::openWith("127.0.0.1", parts.front()->port(), "fixtures/developer-suite.html", policy, {}); + watchdog.request_stop(); + bool passed = true; + for (std::size_t i = 0; i < parts.size(); ++i) { + const bool success = parts[i]->finish(output); + std::ofstream report(output / "results" / (std::string(names[i]) + ".json")); + report << "{\"exitCode\":" << (success ? 0 : 1) << ",\"output\":\"Developer part " << names[i] << "\"}"; + report.close(); + if (!report) + throw std::runtime_error("Cannot write developer part report"); + passed = success && passed; + } + std::cout << "Developer session: nativeWindows=1 parts=6 durationMs=" + << std::chrono::duration_cast(std::chrono::steady_clock::now() - started).count() << '\n'; + return passed ? 0 : 1; +} +} // namespace + +int main(int argc, char** argv) { + try { + // CEF child processes must dispatch before interpreting application arguments or creating files. + webfront::detail::ensureFrontendInitialized(); + if (argc != 3 && argc != 4) + throw std::invalid_argument("Expected fixture directory, header output directory and optional --session, --public or --part="); + if (argc == 4 && std::string_view(argv[3]) == "--session") + return runSession(argv[1], argv[2]); + const Mode mode = parseMode(argc == 4 ? std::string_view(argv[3]) : std::string_view{}); + Part part(argv[1], mode); + part.show(); + return part.finish(argv[2]) ? 0 : 1; } catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 1; diff --git a/test/web/FrontendLifecycle.cpp b/test/web/FrontendLifecycle.cpp index 93b9e8ea..e387ccf9 100644 --- a/test/web/FrontendLifecycle.cpp +++ b/test/web/FrontendLifecycle.cpp @@ -25,7 +25,7 @@ namespace { using Frontend = WEBFRONT_TEST_FRONTEND; using TestFS = webfront::fs::Multi; -using App = webfront::BasicWFWithFrontend>; +using App = webfront::BasicWFWithFrontend>; static_assert(Frontend::action == webfront::frontend::Action::closeServerAfterOpen); // Values reported by the lifecycle pages; keep their named constants in sync with this enum. @@ -347,7 +347,7 @@ struct SecondOpener { void set_value() && noexcept { SecondOpenOutcome outcome; try { - webfront::testdriver::QuietFrontend::open("0", "no-bridge.html"); + webfront::testdriver::TestFrontend::open("0", "no-bridge.html"); } catch (const std::exception&) { outcome.refused = true; } catch (...) { @@ -421,7 +421,7 @@ int checkSecondOpen() { int expectNavigationFailure() { try { - webfront::testdriver::QuietFrontend::open("0", "index.html"); + webfront::testdriver::TestFrontend::open("0", "index.html"); } catch (const std::exception& error) { std::cerr << error.what() << '\n'; return 0; // The contract requires an exception, without prescribing its wording. diff --git a/test/web/LifeEmbeddedTest.cpp b/test/web/LifeEmbeddedTest.cpp index 0f66a327..8edf6c06 100644 --- a/test/web/LifeEmbeddedTest.cpp +++ b/test/web/LifeEmbeddedTest.cpp @@ -61,7 +61,7 @@ int main() { using App = webfront::BasicWF, webfront::http::DefaultBuffersPolicy, - webfront::testdriver::QuietFrontend>; + webfront::testdriver::TestFrontend>; App app; std::atomic passed{false}; app.cppFunction("life.step", &webfront::demo::nextLife); diff --git a/test/web/WKWebViewLifecycle.cpp b/test/web/WKWebViewLifecycle.cpp index bfb9ca8e..612a8498 100644 --- a/test/web/WKWebViewLifecycle.cpp +++ b/test/web/WKWebViewLifecycle.cpp @@ -20,7 +20,7 @@ void checkWKWebViewHeader(); namespace { using namespace webfront::frontend::detail::wkwebview; -using Frontend = webfront::testdriver::QuietFrontend; +using Frontend = webfront::testdriver::TestFrontend; using App = webfront::WebFrontWithFrontend; void require(bool condition, const char* message) { diff --git a/test/web/WebView2Lifecycle.cpp b/test/web/WebView2Lifecycle.cpp index db0b8be3..5b808f7a 100644 --- a/test/web/WebView2Lifecycle.cpp +++ b/test/web/WebView2Lifecycle.cpp @@ -113,8 +113,10 @@ int startupCompletion(bool failed) { using namespace webfront::frontend::detail::webview2; Apartment apartment; auto session = std::make_shared(); - session->createWindow(webfront::testdriver::diagnosticWindows()); - require(static_cast(IsWindowVisible(session->window)) == webfront::testdriver::diagnosticWindows(), "Window visibility option was ignored"); + // Cover the explicit hidden-window option on this startup-failure probe; ordinary rendered sessions stay visible. + const bool visible = !failed; + session->createWindow(visible); + require(static_cast(IsWindowVisible(session->window)) == visible, "Window visibility option was ignored"); session->start(L"unused-profile", DeferredEnvironment::create); require(DeferredEnvironment::completion.Get() != nullptr, "Creation request was not started"); const auto timer = session->startupTimer; @@ -409,7 +411,7 @@ int rejectMta() { return 1; bool rejected = false; try { - webfront::testdriver::QuietFrontend::open("9002", "index.html"); + webfront::testdriver::TestFrontend::open("9002", "index.html"); } catch (const std::exception& error) { rejected = std::string_view(error.what()).find("STA") != std::string_view::npos; } @@ -490,7 +492,7 @@ int runtimeReadyBeforePageLoad() { int expectOpenFailure(std::string_view port, std::string_view diagnostic) { try { - webfront::testdriver::QuietFrontend::open(port, "index.html"); + webfront::testdriver::TestFrontend::open(port, "index.html"); } catch (const std::exception& error) { return std::string_view(error.what()).find(diagnostic) != std::string_view::npos ? 0 : 1; } diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index d49ead35..df8031af 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -1475,5 +1475,8 @@ try { } finally { if (lastPhase) await webFront.cppFunction('test.progress')( `${profileNow().toFixed(3)}ms end ${lastPhase.name} durationMs=${(profileNow() - lastPhase.time).toFixed(3)}`); - setTimeout(() => globalThis.close(), 0); + if (location.search === '?developer-session' && parent !== self) + parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); + else + setTimeout(() => globalThis.close(), 0); } From b13fcb41a11f75b6bdb750d724f4fce00a7c2f28 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 00:02:42 +0100 Subject: [PATCH 04/10] Keep developer parts parallel in visible panes and focus their pages (#544) --- docs/TEST_PERFORMANCE.md | 16 ++-- docs/TEST_TIERS.md | 4 +- docs/WEBVIEW2.md | 2 +- docs/WKWEBVIEW.md | 2 +- test/cmake/CheckDeveloperSessionFailure.cmake | 2 + test/web/CMakeLists.txt | 4 +- test/web/DeveloperTest.cpp | 76 +++++++++++++------ 7 files changed, 71 insertions(+), 35 deletions(-) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 41356132..12c62a09 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -91,8 +91,9 @@ Browser tests keep their windows visible by default on Windows and macOS. Their Linux's real windows remain on the suite's Xvfb display. Explicit tests of hidden-window behavior still use that option. `DeveloperBrowserSession` opens **one visible native window for all six developer integration parts**, instead of six. -It displays each part in a fresh, full-size iframe, with its own native application, temporary project, assigned loopback -port and origin. The previous frame is removed before the next part loads; its Workers, listeners and bridge go away. +It displays up to four parts concurrently in visible iframe panes, each with its own native application, temporary +project, assigned loopback port and origin. A completed frame is removed and its slot reused; its Workers, listeners +and bridge go away. Workspace then gets the entire window for its layout/rendering checks. No active pane is hidden. All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. Closing the window early, a missing result or an expired per-part native deadline fails the session. A small fault-injection session verifies @@ -102,9 +103,14 @@ check still come from their respective parts. The driver groups above each use one visible window. This change reduces the three WebSuite/React commands from three openings to one, publication's four commands from four to one, and manifest-directory init/install from two to one. With sessions disabled, the original individual commands and the six separate developer windows remain available. -Developer parts now run sequentially within their window; this saves native startup/teardown and concurrent engine -memory, but can take longer than six parallel windows. Compare full-suite wall time as well as openings before claiming -a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. +The session reserves four CTest processors to account for its bounded internal parallelism. Each part retains its own +native 180-second deadline, even while other parts finish. Compare full-suite wall time as well as openings before +claiming a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. + +A local Windows/MSVC Release/WebView2 comparison used the same executable and fixtures, with four workers and no +concurrent compiler: six separate visible windows took 28.83 s; the shared visible window took 27.85 s (27.38 s inside +the native session). All six parts passed in both runs. This single pair demonstrates comparable elapsed time and five +fewer native openings; it does not establish a whole-suite speedup. Failed navigation, native close, startup failures, watchdogs and cancellation remain real process tests. The two macOS executable/dylib registration orders remain separate images and processes. `ConsumerJasmine` modes and `Automation*` diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index 8bd0d0c3..e28e204c 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -30,8 +30,8 @@ share a process: `test/unit/ScenarioIsolation.cpp` restores the process-wide sta ## Following a browser test live -`DeveloperBrowserIntegration` and its siblings `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine` and `-terminal` -(the parts of `test/web/developer-specs.mjs`, which run in parallel on a port the system picks), the `Automation*` cases and the `WfDriver*` cases run `wf` commands (`create`, `install`, +`DeveloperBrowserIntegration` and its siblings `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine`, `-terminal` +and `-workspace` (the parts of `test/web/developer-specs.mjs`), the `Automation*` cases and the `WfDriver*` cases run `wf` commands (`create`, `install`, `build`, `dev`, `preview`, `embed`, ...) that can take several seconds each. CTest hides the output of a passing test, so to watch one: diff --git a/docs/WEBVIEW2.md b/docs/WEBVIEW2.md index 0cabab01..463c466b 100644 --- a/docs/WEBVIEW2.md +++ b/docs/WEBVIEW2.md @@ -54,7 +54,7 @@ A literal `+` in the path is automatically encoded as `%2B`: `show("a+b.html")` The shared `path-encoding` lifecycle case opens `encoded path %23.html` under every frontend and checks the query and fragment (reaching the page proves the decoded filename); the Jasmine suite, which runs in a frame of the developer environment, serves `a+b.html` through the C++ URL builder. Catch2 also checks this path at the system-browser launcher boundary and verifies shell quoting. On Windows the system browser is opened directly with `ShellExecute`, without a command shell; POSIX launches quote the URL as one argument. -## Quiet automated sessions +## Window visibility The per-opening options include `visible` (default `true`). Setting it to `false` creates the real native window and engine without presenting or focusing the window. This retains the native event loop and startup/navigation deadlines; diff --git a/docs/WKWEBVIEW.md b/docs/WKWEBVIEW.md index 5749eb81..ef89f76d 100644 --- a/docs/WKWEBVIEW.md +++ b/docs/WKWEBVIEW.md @@ -190,7 +190,7 @@ Timed measurements are excluded from CTest and CI. [ADR-017](adr/ADR-017-acces-d their measurements and the consequences of Apple's public APIs for a future direct transport, including the Foundation type boundary, handler lifetime, origins and custom resource schemes. iOS remains unverified. -## Quiet automated sessions +## Window visibility The per-opening options include `visible` (default `true`). Setting it to `false` creates the real native window and engine without presenting or focusing the window. This retains the native event loop and startup/navigation deadlines; diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake index afe35273..5eef5ca8 100644 --- a/test/cmake/CheckDeveloperSessionFailure.cmake +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -4,6 +4,8 @@ file(WRITE "${WORK}/fixtures/provision.json" "{\"integrity\":\"sha512-unused-by- file(WRITE "${WORK}/fixtures/run.mjs" [=[ await webFront.ready; const part = await webFront.cppFunction('test.part')(); +// Every concurrent pane must receive rendering frames; a hidden iframe must not stand in for a shared visible window. +await new Promise(requestAnimationFrame); // The first case fails. Later cases must still run; terminal deliberately reports failure too, without starting a command. await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', `session-failure ${part}`); parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 8d78abc2..1f39756f 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -311,7 +311,7 @@ if(_browser_tests_available) if(WEBFRONT_TEST_SESSIONS) add_test(NAME DeveloperBrowserSession COMMAND ${_developer_command} "${_fixtures}" "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" --session) - set_tests_properties(DeveloperBrowserSession PROPERTIES LABELS "web-integration" TIMEOUT 1110 + set_tests_properties(DeveloperBrowserSession PROPERTIES LABELS "web-integration" TIMEOUT 570 PROCESSORS 4 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures FIXTURES_SETUP DeveloperBrowserSession) webfront_use_own_profile(DeveloperBrowserSession developer-session) @@ -323,7 +323,7 @@ if(_browser_tests_available) -DPROGRAM=$ "-DPREFIX=${_developer_session_prefix}" -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-session-failure -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperSessionFailure.cmake) - set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES LABELS "web-integration" TIMEOUT 60) + set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES LABELS "web-integration" TIMEOUT 60 PROCESSORS 4) webfront_use_own_profile(DeveloperBrowserSessionFailure developer-session-failure) if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") set_tests_properties(DeveloperBrowserSession PROPERTIES RESOURCE_LOCK webfront_port_9002) diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 7011a281..2961b424 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -266,6 +266,7 @@ class Part { throw std::runtime_error("A developer part reported twice"); if (deadline) deadline->beginCase(180s); + caseDeadline.endCase(); }); registerCommands(commands, states); app.cppFunction("test.command", [owned = states](std::string tag) { @@ -281,13 +282,16 @@ class Part { return static_cast(app.connectedBrowsers()); }); bootstrapApp(app, mode, readIntegrity(project.path() / "fixtures/provision.json")); - subscription = app.subscribeUIStarted([injected = false](App::UI ui) mutable { - if (!std::exchange(injected, true)) + subscription = app.subscribeUIStarted([this, injected = false](App::UI ui) mutable { + if (!std::exchange(injected, true)) { + caseDeadline.beginCase(180s); ui.addScript(runScript); + } }); } ~Part() { + watchdog.request_stop(); states->releaseAll(); app.stop(); if (server.joinable()) @@ -301,7 +305,14 @@ class Part { } void start() { - server = std::jthread([this] { + watchdog = std::jthread([this](std::stop_token stop) { + if (caseDeadline.expired(stop)) { + std::cerr << "Developer part exceeded its native deadline: " << mode.part << '\n'; + std::cerr.flush(); + std::_Exit(1); + } + }); + server = std::jthread([this] { app.run(); }); } @@ -319,6 +330,7 @@ class Part { } bool finish(const std::filesystem::path& output) { + watchdog.request_stop(); states->releaseAll(); app.stop(); if (server.joinable()) @@ -335,14 +347,16 @@ class Part { } private: - webfront::test::TemporaryDirectory project; - App app; - Mode mode; - std::atomic passed{false}, reported{false}; - std::shared_ptr states; - webfront::Commands commands; - webfront::UISubscription subscription; - std::jthread server; + webfront::test::TemporaryDirectory project; + App app; + Mode mode; + std::atomic passed{false}, reported{false}; + std::shared_ptr states; + webfront::Commands commands; + webfront::UISubscription subscription; + webfront::testdriver::DriverDeadline caseDeadline{540s}; + std::jthread watchdog; + std::jthread server; }; int runSession(const std::filesystem::path& fixtures, const std::filesystem::path& output) { @@ -352,7 +366,7 @@ int runSession(const std::filesystem::path& fixtures, const std::filesystem::pat // Remove only this invocation's own reports, so a crash cannot leave a previous success behind. for (const auto name : names) std::filesystem::remove(output / "results" / (std::string(name) + ".json")); - webfront::testdriver::DriverDeadline deadlines(1080s); + webfront::testdriver::DriverDeadline deadlines(540s); deadlines.beginCase(180s); std::vector> parts; webfront::ContentPolicy policy; @@ -368,24 +382,38 @@ int runSession(const std::filesystem::path& fixtures, const std::filesystem::pat std::ofstream html(page, std::ios::binary); html << R"HTML(Developer integration -
)HTML"; html.close(); if (!html) From 5991eb8d9610790a597cbc258419256517f2c4f9 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 00:13:40 +0100 Subject: [PATCH 05/10] Reuse the native view for workspace focus and keep capture unobscured (#544) --- docs/TEST_PERFORMANCE.md | 7 +++++-- test/cmake/CheckDeveloperSessionFailure.cmake | 3 ++- test/web/CMakeLists.txt | 2 ++ test/web/DeveloperTest.cpp | 7 ++++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 12c62a09..0bf37219 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -93,7 +93,8 @@ Linux's real windows remain on the suite's Xvfb display. Explicit tests of hidde `DeveloperBrowserSession` opens **one visible native window for all six developer integration parts**, instead of six. It displays up to four parts concurrently in visible iframe panes, each with its own native application, temporary project, assigned loopback port and origin. A completed frame is removed and its slot reused; its Workers, listeners -and bridge go away. Workspace then gets the entire window for its layout/rendering checks. No active pane is hidden. +and bridge go away. The same native view then navigates to workspace as a top-level page for its layout/rendering and +keyboard-focus checks; this retains WebKit's original focus ancestry. No active pane is hidden. All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. Closing the window early, a missing result or an expired per-part native deadline fails the session. A small fault-injection session verifies @@ -108,7 +109,7 @@ native 180-second deadline, even while other parts finish. Compare full-suite wa claiming a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. A local Windows/MSVC Release/WebView2 comparison used the same executable and fixtures, with four workers and no -concurrent compiler: six separate visible windows took 28.83 s; the shared visible window took 27.85 s (27.38 s inside +concurrent compiler: six separate visible windows took 27.38 s; the shared visible window took 27.26 s (26.91 s inside the native session). All six parts passed in both runs. This single pair demonstrates comparable elapsed time and five fewer native openings; it does not establish a whole-suite speedup. @@ -116,6 +117,8 @@ Failed navigation, native close, startup failures, watchdogs and cancellation re executable/dylib registration orders remain separate images and processes. `ConsumerJasmine` modes and `Automation*` retain their own visible windows where they have not yet been grouped; no whole-suite budget of two or three visible openings is claimed. Hidden WKWebView tests require macOS 14+ and a WindowServer session. +The timed `ConsumerJasmine-capture` sequence reserves four CTest processors too, so another test cannot cover its +visible window and throttle WebKit's rendering while it records. ## Profiling and interpreting the numbers diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake index 5eef5ca8..d586261d 100644 --- a/test/cmake/CheckDeveloperSessionFailure.cmake +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -8,7 +8,8 @@ const part = await webFront.cppFunction('test.part')(); await new Promise(requestAnimationFrame); // The first case fails. Later cases must still run; terminal deliberately reports failure too, without starting a command. await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', `session-failure ${part}`); -parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); +if (parent === self) window.close(); +else parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); ]=]) execute_process(COMMAND ${PREFIX} "${PROGRAM}" "${WORK}/fixtures" "${WORK}/output" --session RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 45) diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 1f39756f..3eca61a1 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -224,6 +224,8 @@ if(_browser_tests_available) FRONTEND "${WEBFRONT_WEBTEST_FRONTEND}" TIMEOUT 30 SPECS "${CMAKE_CURRENT_SOURCE_DIR}/jasmine-consumer/capture.spec.js" ARGS "${CMAKE_CURRENT_SOURCE_DIR}/jasmine-consumer") + # With visible windows, another test can occlude this view and throttle its timed image sequence on WebKit. + set_tests_properties(ConsumerJasmine-capture PROPERTIES PROCESSORS 4) # File services of the engine (issue #451), shared by every embedded frontend. webfront_add_jasmine_test(NAME ConsumerJasmine-file-services TARGET jasmine_consumer FRONTEND "${WEBFRONT_WEBTEST_FRONTEND}" TIMEOUT 60 diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 2961b424..129726a5 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -402,10 +402,11 @@ function advance() { // All running pages remain displayed. Workspace's layout/rendering checks get the entire window afterwards. while (cursor < 5 && frames.size < 4) launch(cursor++); if (completed === 5 && !frames.size) { - document.body.style.gridTemplateColumns = '1fr'; - launch(cursor++); + // Keep the same native view, but give workspace its original top-level focus chain on WebKit. + const workspace = new URL(urls[5]); + workspace.search = ''; + location.replace(workspace); } - if (completed === urls.length) window.close(); } addEventListener('message', event => { for (const [index, {pane, frame}] of frames) { From 2b4fe2235b4b868921b814ebcd164758bf1d8488 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 00:29:54 +0100 Subject: [PATCH 06/10] Stagger bootstrap work before running developer commands in parallel (#544) --- docs/TEST_PERFORMANCE.md | 6 ++++-- test/cmake/CheckDeveloperSessionFailure.cmake | 4 ++++ test/web/DeveloperTest.cpp | 13 ++++++++++--- test/web/developer-specs.mjs | 4 ++++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 0bf37219..ec662628 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -92,7 +92,9 @@ Linux's real windows remain on the suite's Xvfb display. Explicit tests of hidde `DeveloperBrowserSession` opens **one visible native window for all six developer integration parts**, instead of six. It displays up to four parts concurrently in visible iframe panes, each with its own native application, temporary -project, assigned loopback port and origin. A completed frame is removed and its slot reused; its Workers, listeners +project, assigned loopback port and origin. Bootstraps are staggered until their environment is ready so four archive +unpackers do not compete on WebKit's shared JavaScript thread; the ready pages' commands run in parallel. +A completed frame is removed and its slot reused; its Workers, listeners and bridge go away. The same native view then navigates to workspace as a top-level page for its layout/rendering and keyboard-focus checks; this retains WebKit's original focus ancestry. No active pane is hidden. All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. @@ -109,7 +111,7 @@ native 180-second deadline, even while other parts finish. Compare full-suite wa claiming a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. A local Windows/MSVC Release/WebView2 comparison used the same executable and fixtures, with four workers and no -concurrent compiler: six separate visible windows took 27.38 s; the shared visible window took 27.26 s (26.91 s inside +concurrent compiler: six separate visible windows took 26.89 s; the shared visible window took 28.69 s (28.34 s inside the native session). All six parts passed in both runs. This single pair demonstrates comparable elapsed time and five fewer native openings; it does not establish a whole-suite speedup. diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake index d586261d..6c0f320e 100644 --- a/test/cmake/CheckDeveloperSessionFailure.cmake +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -6,6 +6,10 @@ await webFront.ready; const part = await webFront.cppFunction('test.part')(); // Every concurrent pane must receive rendering frames; a hidden iframe must not stand in for a shared visible window. await new Promise(requestAnimationFrame); +if (parent !== self) { + parent.postMessage('webfront-developer-ready', new URL(document.referrer).origin); + await new Promise(resolve => setTimeout(resolve, 100)); +} // The first case fails. Later cases must still run; terminal deliberately reports failure too, without starting a command. await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', `session-failure ${part}`); if (parent === self) window.close(); diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 129726a5..cddd47b5 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -388,9 +388,10 @@ iframe{display:block;border:0;width:100%;height:calc(100% - 28px)} const urls = )HTML" << urls << R"HTML(; const names = ['application', 'scripts', 'TypeScript', 'Jasmine', 'terminal', 'workspace']; -let cursor = 0, completed = 0; +let cursor = 0, completed = 0, booting = null; const frames = new Map(); function launch(index) { + booting = index; const pane = document.createElement('section'), title = document.createElement('header'), frame = document.createElement('iframe'); title.textContent = `Developer integration: ${names[index]}`; // Give the embedded page the focus a standalone native page had, before its asynchronous bootstrap mounts the preview. @@ -400,7 +401,7 @@ function launch(index) { } function advance() { // All running pages remain displayed. Workspace's layout/rendering checks get the entire window afterwards. - while (cursor < 5 && frames.size < 4) launch(cursor++); + if (cursor < 5 && frames.size < 4 && booting === null) launch(cursor++); if (completed === 5 && !frames.size) { // Keep the same native view, but give workspace its original top-level focus chain on WebKit. const workspace = new URL(urls[5]); @@ -410,7 +411,13 @@ function advance() { } addEventListener('message', event => { for (const [index, {pane, frame}] of frames) { - if (event.source !== frame.contentWindow || event.origin !== new URL(urls[index]).origin || event.data !== 'webfront-developer-finished') continue; + if (event.source !== frame.contentWindow || event.origin !== new URL(urls[index]).origin) continue; + if (event.data === 'webfront-developer-ready') { + if (booting === index) { booting = null; advance(); } + break; + } + if (event.data !== 'webfront-developer-finished') continue; + if (booting === index) booting = null; pane.remove(); frames.delete(index); ++completed; advance(); break; } }); diff --git a/test/web/developer-specs.mjs b/test/web/developer-specs.mjs index df8031af..f9e24fdd 100644 --- a/test/web/developer-specs.mjs +++ b/test/web/developer-specs.mjs @@ -90,6 +90,10 @@ try { await delay(100); } await progress('bootstrap ready'); + // Unpacking four environments on one WebKit JavaScript thread can exhaust the unchanged readiness budget. + // Start the next bootstrap now; this part's commands can still run alongside it in their own visible pane. + if (location.search === '?developer-session' && parent !== self) + parent.postMessage('webfront-developer-ready', new URL(document.referrer).origin); // `all` (no part given) runs every part in one session; a part starts from a fresh project and runs alone, in parallel // with the others. const part = await webFront.cppFunction('test.part')(); From b923024a98b11e643bd161349e96cc9ad88fb414 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 06:23:58 +0100 Subject: [PATCH 07/10] Keep developer report readers independent of failed parts (#556) --- cmake/WKWebViewSupport.cmake | 2 +- docs/CHANGELOG.md | 1 + docs/TEST_PERFORMANCE.md | 12 ++- test/cmake/CheckDeveloperSessionFailure.cmake | 74 +++++++++++++--- test/cmake/DeveloperSessionTests.cmake | 25 ++++++ test/cmake/RunDeveloperSession.cmake | 34 ++++++++ test/web/CMakeLists.txt | 49 +++++------ test/web/DeveloperTest.cpp | 85 ++++++++++++------- test/web/WKWebViewLifecycle.cpp | 18 ++-- 9 files changed, 217 insertions(+), 83 deletions(-) create mode 100644 test/cmake/DeveloperSessionTests.cmake create mode 100644 test/cmake/RunDeveloperSession.cmake diff --git a/cmake/WKWebViewSupport.cmake b/cmake/WKWebViewSupport.cmake index 51d9e147..6efe1c01 100644 --- a/cmake/WKWebViewSupport.cmake +++ b/cmake/WKWebViewSupport.cmake @@ -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 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) + foreach(mode repeated-show main-thread native-close quit navigation-diagnostic startup-timeout settings 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) add_test(NAME WKWebViewLifecycle-${mode} COMMAND wkwebview_lifecycle ${mode}) webfront_set_browser_test_properties("WKWebViewLifecycle-${mode}" "${webtest_source_dir}" 90) endforeach() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3fd03d70..cec4bcee 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -25,6 +25,7 @@ these entries stays in the GitHub releases and the Git history. ### Fixed +- Read all six developer integration reports in CTest after a part fails, and keep the successful parts' dependent tests runnable (#556). - On Windows, `wf install`, `wf build` and `wf test` no longer fail with `rename: Access is denied` while another process, such as an antivirus scan, still reads the files just written: the developer store tries the rename again for up to 635 ms; `wf test` also empties the directory of an interrupted run (#542). - Run the commit attribution regression checks with older Git versions by dropping the unsupported `git log --no-graph` option (#525). diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index ec662628..4707b575 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -98,10 +98,14 @@ A completed frame is removed and its slot reused; its Workers, listeners and bridge go away. The same native view then navigates to workspace as a top-level page for its layout/rendering and keyboard-focus checks; this retains WebKit's original focus ancestry. No active pane is hidden. All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. -The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. Closing the window early, -a missing result or an expired per-part native deadline fails the session. A small fault-injection session verifies -that an unsuccessful first part does not skip the later reports. Life's generated header and the terminal's cancellation -check still come from their respective parts. +The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. The producer fixture succeeds +when all six reports are complete and agree with the process status, even if some parts failed; each report reader +decides its own result and unlocks only its own dependent tests. A crash, missing/invalid report, inconsistent process +status or expired native deadline fails the producer. The `--session` command itself still exits with 1 when any part fails. +A nested CTest regression verifies failed and successful readers as well as their downstream fixtures, using the same +registration helper as the real suite. Each report retains the part's diagnostic. Life's generated header and the terminal's +cancellation check still come from their respective parts. Browser deadlines start after file preparation. An explicit hidden WKWebView +case checks both native invisibility and `inactiveSchedulingPolicy == None`; ordinary windows remain visible. The driver groups above each use one visible window. This change reduces the three WebSuite/React commands from three openings to one, publication's four commands from four to one, and manifest-directory init/install from two to one. diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake index 6c0f320e..9b87af76 100644 --- a/test/cmake/CheckDeveloperSessionFailure.cmake +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -15,23 +15,75 @@ await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', if (parent === self) window.close(); else parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); ]=]) -execute_process(COMMAND ${PREFIX} "${PROGRAM}" "${WORK}/fixtures" "${WORK}/output" --session +# Run the production fixture graph through CTest: an aggregate failure must not skip report readers. +set(helper "${CMAKE_CURRENT_LIST_DIR}/DeveloperSessionTests.cmake") +file(MAKE_DIRECTORY "${WORK}/source") +set(project [=[ +cmake_minimum_required(VERSION 3.31) +project(DeveloperSessionFailure LANGUAGES NONE) +enable_testing() +include([==[@helper@]==]) +set(prefix [==[@PREFIX@]==]) +webfront_add_developer_session_tests(PROGRAM [==[@PROGRAM@]==] FIXTURES [==[@WORK@/fixtures]==] + OUTPUT [==[@WORK@/output]==] PREFIX ${prefix}) +set_tests_properties(DeveloperBrowserIntegration-scripts PROPERTIES FIXTURES_SETUP SuccessfulPart) +add_test(NAME SuccessfulConsumer COMMAND "${CMAKE_COMMAND}" -E echo "successful-dependent-ran") +set_tests_properties(SuccessfulConsumer PROPERTIES FIXTURES_REQUIRED SuccessfulPart) +add_test(NAME FailedConsumer COMMAND "${CMAKE_COMMAND}" -E echo "failed-dependent-must-not-run") +set_tests_properties(FailedConsumer PROPERTIES FIXTURES_REQUIRED DeveloperGenerated) +]=]) +string(CONFIGURE "${project}" project @ONLY) +file(WRITE "${WORK}/source/CMakeLists.txt" "${project}") +execute_process(COMMAND "${CMAKE_COMMAND}" -S "${WORK}/source" -B "${WORK}/build" + RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 10) +if(NOT status EQUAL 0) + message(FATAL_ERROR "Cannot configure the CTest failure graph: ${output}${errors}") +endif() +get_filename_component(cmake_bin "${CMAKE_COMMAND}" DIRECTORY) +find_program(CTEST_EXECUTABLE ctest HINTS "${cmake_bin}" REQUIRED) +execute_process(COMMAND "${CTEST_EXECUTABLE}" --test-dir "${WORK}/build" -C Release --parallel 4 -V + --output-junit "${WORK}/results.xml" -R "DeveloperBrowserIntegration|SuccessfulConsumer|FailedConsumer" RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 45) -message(STATUS "${output}${errors}") -if(NOT status STREQUAL "1") - message(FATAL_ERROR "A session with a failed first part must exit with 1, got ${status}") +if(NOT status STREQUAL "8") + message(FATAL_ERROR "The CTest graph must fail only for its failed cases, got ${status}: ${output}${errors}") endif() +file(READ "${WORK}/results.xml" results) +function(expect_case name expected) + string(FIND "${results}" "" end) + string(SUBSTRING "${item}" 0 ${end} item) + set(actual passed) + if(item MATCHES "" + FIXTURES "${_fixtures}" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" + PREFIX ${_developer_session_prefix} REQUIRES DeveloperFixtures WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + webfront_use_own_profile(DeveloperBrowserSession developer-session) add_test(NAME DeveloperBrowserSessionFailure COMMAND ${CMAKE_COMMAND} -DPROGRAM=$ "-DPREFIX=${_developer_session_prefix}" -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-session-failure @@ -332,33 +331,23 @@ if(_browser_tests_available) set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES RESOURCE_LOCK webfront_port_9002) endif() endif() - foreach(_part app scripts typescript jasmine terminal workspace) - set(_name DeveloperBrowserIntegration) - if(NOT _part STREQUAL "app") - set(_name DeveloperBrowserIntegration-${_part}) - endif() - if(WEBFRONT_TEST_SESSIONS) - add_test(NAME ${_name} COMMAND "${CMAKE_COMMAND}" - "-DCASE_REPORT=${CMAKE_CURRENT_BINARY_DIR}/developer-generated/results/${_part}.json" - -DEXPECT_STATUS=0 -P "${PROJECT_SOURCE_DIR}/test/cmake/RunWfDriver.cmake") - else() + if(NOT WEBFRONT_TEST_SESSIONS) + foreach(_part app scripts typescript jasmine terminal workspace) + set(_name DeveloperBrowserIntegration) + if(NOT _part STREQUAL "app") + set(_name DeveloperBrowserIntegration-${_part}) + endif() add_test(NAME ${_name} COMMAND ${_developer_command} "${_fixtures}" "${CMAKE_CURRENT_BINARY_DIR}/developer-generated" --part=${_part}) - endif() - set_tests_properties(${_name} PROPERTIES LABELS "web-integration" TIMEOUT 180 - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures) - if(WEBFRONT_TEST_SESSIONS) - set_property(TEST ${_name} APPEND PROPERTY FIXTURES_REQUIRED DeveloperBrowserSession) - else() + set_tests_properties(${_name} PROPERTIES LABELS "web-integration" TIMEOUT 180 + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" FIXTURES_REQUIRED DeveloperFixtures) webfront_use_own_profile(${_name} developer-${_part}) - endif() - # DeveloperTest uses CEFFrontend's default profile beside the executable, as do the other native browser - # tests holding this lock. CEF forwards concurrent launches with that profile to an existing process. - if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") - set_tests_properties(${_name} PROPERTIES RESOURCE_LOCK webfront_port_9002) - endif() - endforeach() - set_tests_properties(DeveloperBrowserIntegration PROPERTIES FIXTURES_SETUP DeveloperGenerated) + if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") + set_tests_properties(${_name} PROPERTIES RESOURCE_LOCK webfront_port_9002) + endif() + endforeach() + set_tests_properties(DeveloperBrowserIntegration PROPERTIES FIXTURES_SETUP DeveloperGenerated) + endif() # The driver on the environment built from the current sources: statuses, output and reports reach CTest. if(TARGET webfront-wf) set(_wf_project "${CMAKE_CURRENT_BINARY_DIR}/wf-driver-project") diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index cddd47b5..72344e5f 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -59,7 +60,7 @@ std::string readIntegrity(const std::filesystem::path& config) { } template -void registerCallbacks(App& app, const std::filesystem::path& project, std::atomic& passed, std::function reported = {}) { +void registerCallbacks(App& app, const std::filesystem::path& project, std::atomic& passed, std::function reported = {}) { app.cppFunction("life.step", &webfront::demo::nextLife); app.cppFunction("test.header", [project](std::string name) { if (name != "LifeUI") @@ -87,9 +88,9 @@ void registerCallbacks(App& app, const std::filesystem::path& project, std::atom }); app.cppFunction("test.report", [&passed, reported = std::move(reported)](bool success, std::string message) { std::cout << message << std::endl; - passed.store(success); if (reported) - reported(); + reported(std::move(message)); + passed.store(success); }); } @@ -258,15 +259,17 @@ class Part { using App = webfront::BasicDeveloperApp; public: - Part(const std::filesystem::path& fixtures, Mode selected, webfront::testdriver::DriverDeadline* deadline = nullptr) + Part(const std::filesystem::path& fixtures, Mode selected, std::function onReported = {}) : app(project.path(), {.port = "0"}), mode(std::move(selected)), states(std::make_shared()), commands(app) { std::filesystem::copy(fixtures, project.path() / "fixtures", std::filesystem::copy_options::recursive); - registerCallbacks(app, project.path(), passed, [this, deadline] { + registerCallbacks(app, project.path(), passed, [this, onReported = std::move(onReported)](std::string message) { if (reported.exchange(true)) throw std::runtime_error("A developer part reported twice"); - if (deadline) - deadline->beginCase(180s); - caseDeadline.endCase(); + reportMessage = std::move(message); + if (onReported) + onReported(); + if (caseDeadline) + caseDeadline->endCase(); }); registerCommands(commands, states); app.cppFunction("test.command", [owned = states](std::string tag) { @@ -284,7 +287,8 @@ class Part { bootstrapApp(app, mode, readIntegrity(project.path() / "fixtures/provision.json")); subscription = app.subscribeUIStarted([this, injected = false](App::UI ui) mutable { if (!std::exchange(injected, true)) { - caseDeadline.beginCase(180s); + if (caseDeadline) + caseDeadline->beginCase(180s); ui.addScript(runScript); } }); @@ -305,8 +309,10 @@ class Part { } void start() { + // Fixture copies and page preparation must not consume a browser's deadline. + caseDeadline.emplace(540s); watchdog = std::jthread([this](std::stop_token stop) { - if (caseDeadline.expired(stop)) { + if (caseDeadline->expired(stop)) { std::cerr << "Developer part exceeded its native deadline: " << mode.part << '\n'; std::cerr.flush(); std::_Exit(1); @@ -328,6 +334,9 @@ class Part { const std::filesystem::path& directory() const { return project.path(); } + std::string_view message() const { + return reportMessage; + } bool finish(const std::filesystem::path& output) { watchdog.request_stop(); @@ -337,26 +346,37 @@ class Part { server.join(); app.shutdown(); bool success = reported.load() && passed.load(); + if (!reported.load()) + reportMessage = "Developer part " + mode.part + " closed without reporting a result"; if (success && mode.runs("terminal") && !mode.publicDistribution && states->get("final") != "cancelled") { - std::cerr << "The command running at shutdown was not drained: " << states->get("final") << '\n'; + reportMessage = "The command running at shutdown was not drained: " + states->get("final"); + std::cerr << reportMessage << '\n'; success = false; } - if (success && mode.runs("app")) - copyHeaders(project.path(), output); + if (success && mode.runs("app")) { + try { + copyHeaders(project.path(), output); + } catch (const std::exception& error) { + reportMessage = error.what(); + std::cerr << reportMessage << '\n'; + success = false; + } + } return success; } private: - webfront::test::TemporaryDirectory project; - App app; - Mode mode; - std::atomic passed{false}, reported{false}; - std::shared_ptr states; - webfront::Commands commands; - webfront::UISubscription subscription; - webfront::testdriver::DriverDeadline caseDeadline{540s}; - std::jthread watchdog; - std::jthread server; + webfront::test::TemporaryDirectory project; + App app; + Mode mode; + std::atomic passed{false}, reported{false}; + std::shared_ptr states; + webfront::Commands commands; + webfront::UISubscription subscription; + std::string reportMessage; + std::optional caseDeadline; + std::jthread watchdog; + std::jthread server; }; int runSession(const std::filesystem::path& fixtures, const std::filesystem::path& output) { @@ -366,13 +386,14 @@ int runSession(const std::filesystem::path& fixtures, const std::filesystem::pat // Remove only this invocation's own reports, so a crash cannot leave a previous success behind. for (const auto name : names) std::filesystem::remove(output / "results" / (std::string(name) + ".json")); - webfront::testdriver::DriverDeadline deadlines(540s); - deadlines.beginCase(180s); - std::vector> parts; - webfront::ContentPolicy policy; - std::string urls = "["; + std::optional deadlines; + std::vector> parts; + webfront::ContentPolicy policy; + std::string urls = "["; for (const auto name : names) { - auto part = std::make_unique(fixtures, Mode{false, std::string(name)}, &deadlines); + auto part = std::make_unique(fixtures, Mode{false, std::string(name)}, [&deadlines] { + deadlines->beginCase(180s); + }); policy.navigationAllowedOrigins.push_back(part->origin()); urls += (urls.size() > 1 ? "," : "") + webfront::json::quote(part->origin() + "/webfront-bootstrap.html?developer-session"); parts.push_back(std::move(part)); @@ -426,11 +447,13 @@ advance(); html.close(); if (!html) throw std::runtime_error("Cannot write developer session page"); + deadlines.emplace(540s); + deadlines->beginCase(180s); for (auto& part : parts) part->start(); // The native bound applies even when a renderer blocks its JavaScript timers. std::jthread watchdog([&](std::stop_token stop) { - if (deadlines.expired(stop)) { + if (deadlines->expired(stop)) { std::cerr << "Developer session exceeded its per-part deadline\n"; std::cerr.flush(); std::_Exit(1); @@ -443,7 +466,7 @@ advance(); for (std::size_t i = 0; i < parts.size(); ++i) { const bool success = parts[i]->finish(output); std::ofstream report(output / "results" / (std::string(names[i]) + ".json")); - report << "{\"exitCode\":" << (success ? 0 : 1) << ",\"output\":\"Developer part " << names[i] << "\"}"; + report << "{\"exitCode\":" << (success ? 0 : 1) << ",\"output\":" << webfront::json::quote(parts[i]->message()) << "}"; report.close(); if (!report) throw std::runtime_error("Cannot write developer part report"); diff --git a/test/web/WKWebViewLifecycle.cpp b/test/web/WKWebViewLifecycle.cpp index 612a8498..f2f7ccff 100644 --- a/test/web/WKWebViewLifecycle.cpp +++ b/test/web/WKWebViewLifecycle.cpp @@ -84,9 +84,6 @@ void nativeClose(bool quit) { session.create(); require(static_cast(send(session.window, "isVisible")) == webfront::testdriver::diagnosticWindows(), "Window visibility option was ignored"); - if (!webfront::testdriver::diagnosticWindows()) - require(send(send(send(session.view, "configuration"), "preferences"), "inactiveSchedulingPolicy") == 2L, - "Hidden web content would suspend before asynchronous work finishes"); // Exercise the real native entry points before any WebKit/bridge callback. if (quit) send(app, "terminate:", static_cast(nullptr)); @@ -212,9 +209,6 @@ void settings() { session.create(); require(static_cast(send(session.window, "isVisible")) == webfront::testdriver::diagnosticWindows(), "Window visibility option was ignored"); - if (!webfront::testdriver::diagnosticWindows()) - require(send(send(send(session.view, "configuration"), "preferences"), "inactiveSchedulingPolicy") == 2L, - "Hidden web content would suspend before asynchronous work finishes"); require(static_cast(send(session.view, "isInspectable")) == enabled, "Inspector policy was ignored"); require(!send(send(send(session.view, "configuration"), "websiteDataStore"), "isPersistent"), "Website data was persistent"); Object menu(send(type("NSMenu"), "new")); @@ -225,6 +219,17 @@ void settings() { require(utf8(send(send(send(session.app, "mainMenu"), "itemAtIndex:", 1L), "title")) == "Edit", "Edit menu has no visible title"); } } +void hiddenScheduling() { + Object pool(send(type("NSAutoreleasePool"), "new")); + Session session("http://127.0.0.1:0/", {.visible = false}); + session.create(); + require(!send(session.window, "isVisible"), "An explicitly hidden window was shown"); + require(send(send(send(session.view, "configuration"), "preferences"), "inactiveSchedulingPolicy") == 2L, + "Hidden web content would suspend before asynchronous work finishes"); + session.close(); + session.run(); +} + void missingResponse() { Object pool(send(type("NSAutoreleasePool"), "new")); Session session("http://127.0.0.1:0/", {.visible = webfront::testdriver::diagnosticWindows()}); @@ -596,6 +601,7 @@ int main(int argc, char** argv) { { "startup-timeout", startupTimeout}, { "redirect-policy", redirectPolicy}, { "settings", settings}, + { "hidden-scheduling", hiddenScheduling}, {"navigation-diagnostic", navigationDiagnostic}, { "missing-response", missingResponse}, { "committed-navigation", committedNavigation}, From 3337b35b6c778a39fa16ff74b9748bcba8986311 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 06:33:58 +0100 Subject: [PATCH 08/10] Check hidden WKWebView support on the runtime OS (#556) --- docs/TEST_PERFORMANCE.md | 1 + test/web/WKWebViewLifecycle.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 4707b575..fc06e246 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -106,6 +106,7 @@ A nested CTest regression verifies failed and successful readers as well as thei registration helper as the real suite. Each report retains the part's diagnostic. Life's generated header and the terminal's cancellation check still come from their respective parts. Browser deadlines start after file preparation. An explicit hidden WKWebView case checks both native invisibility and `inactiveSchedulingPolicy == None`; ordinary windows remain visible. +When the runtime lacks this preference (macOS 13.3), that case checks the documented rejection of hidden sessions. The driver groups above each use one visible window. This change reduces the three WebSuite/React commands from three openings to one, publication's four commands from four to one, and manifest-directory init/install from two to one. diff --git a/test/web/WKWebViewLifecycle.cpp b/test/web/WKWebViewLifecycle.cpp index f2f7ccff..d36bac33 100644 --- a/test/web/WKWebViewLifecycle.cpp +++ b/test/web/WKWebViewLifecycle.cpp @@ -221,7 +221,14 @@ void settings() { } void hiddenScheduling() { Object pool(send(type("NSAutoreleasePool"), "new")); + Object configuration(send(type("WKWebViewConfiguration"), "new")); + const auto preferences = send(configuration.get(), "preferences"); Session session("http://127.0.0.1:0/", {.visible = false}); + // Check the runtime capability: a test binary built on macOS 14 can also run on macOS 13.3. + if (!send(preferences, "respondsToSelector:", sel_registerName("setInactiveSchedulingPolicy:"))) { + expectFailure([&] { session.create(); }, "hidden sessions require macOS 14 or later"); + return; + } session.create(); require(!send(session.window, "isVisible"), "An explicitly hidden window was shown"); require(send(send(send(session.view, "configuration"), "preferences"), "inactiveSchedulingPolicy") == 2L, From c8c98bef957b82af9f6edc6f9a4449b8fb0c8b57 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Thu, 12 Nov 2026 18:00:37 +0100 Subject: [PATCH 09/10] Keep session reports on deadline expiry and start the developer panes sooner (#556) An expired native deadline now writes the reports of every part before the session exits, so the parts that finished keep their results. A nested CTest scenario shortens the deadline (WEBFRONT_TEST_DEVELOPER_DEADLINE) to cover it. Pages learn their host's origin from the developer-session query instead of the referrer. TypeScript starts first and a fifth pane is admitted. The session prints each part's connected and reported times. diagnosticWindows() becomes the constant visibleWindows, the nested test gets longer timeouts and the configuration of the generator, the legacy all mode keeps its port, and formatting-only hunks are reverted. --- docs/CHANGELOG.md | 2 +- docs/TEST_PERFORMANCE.md | 30 +++- test/cmake/CheckDeveloperSessionFailure.cmake | 158 ++++++++++------- test/driver/TestFrontend.hpp | 20 +-- test/driver/WfDriver.hpp | 2 +- test/web/CMakeLists.txt | 4 +- test/web/DeveloperTest.cpp | 163 ++++++++++++++---- test/web/FrontendLifecycle.cpp | 4 +- test/web/WKWebViewLifecycle.cpp | 16 +- test/web/WebView2Lifecycle.cpp | 14 +- test/web/developer-specs.mjs | 10 +- 11 files changed, 287 insertions(+), 136 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cec4bcee..b411c95f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -25,7 +25,7 @@ these entries stays in the GitHub releases and the Git history. ### Fixed -- Read all six developer integration reports in CTest after a part fails, and keep the successful parts' dependent tests runnable (#556). +- Read all six developer integration reports in CTest after a part fails, and keep the successful parts' dependent tests runnable, also when the session's native deadline ends it (#556). - On Windows, `wf install`, `wf build` and `wf test` no longer fail with `rename: Access is denied` while another process, such as an antivirus scan, still reads the files just written: the developer store tries the rename again for up to 635 ms; `wf test` also empties the directory of an interrupted run (#542). - Run the commit attribution regression checks with older Git versions by dropping the unsupported `git log --no-graph` option (#525). diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index fc06e246..eea2fc23 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -91,19 +91,24 @@ Browser tests keep their windows visible by default on Windows and macOS. Their Linux's real windows remain on the suite's Xvfb display. Explicit tests of hidden-window behavior still use that option. `DeveloperBrowserSession` opens **one visible native window for all six developer integration parts**, instead of six. -It displays up to four parts concurrently in visible iframe panes, each with its own native application, temporary -project, assigned loopback port and origin. Bootstraps are staggered until their environment is ready so four archive -unpackers do not compete on WebKit's shared JavaScript thread; the ready pages' commands run in parallel. +It displays up to five parts concurrently in visible iframe panes (all but workspace), each with its own native +application, temporary project, assigned loopback port and origin, the longest part (TypeScript) first. Bootstraps are +staggered until their environment is ready so the archive unpackers do not compete on WebKit's shared JavaScript thread; +the ready pages' commands run in parallel. Each page learns its host's origin from its `?developer-session=` +query, not from its referrer. A completed frame is removed and its slot reused; its Workers, listeners and bridge go away. The same native view then navigates to workspace as a top-level page for its layout/rendering and keyboard-focus checks; this retains WebKit's original focus ancestry. No active pane is hidden. All assertions run in their original single-part mode, including workspace's first-launch/failed-first-build checks. The familiar `DeveloperBrowserIntegration*` CTest names validate separate native reports. The producer fixture succeeds when all six reports are complete and agree with the process status, even if some parts failed; each report reader -decides its own result and unlocks only its own dependent tests. A crash, missing/invalid report, inconsistent process -status or expired native deadline fails the producer. The `--session` command itself still exits with 1 when any part fails. -A nested CTest regression verifies failed and successful readers as well as their downstream fixtures, using the same -registration helper as the real suite. Each report retains the part's diagnostic. Life's generated header and the terminal's +decides its own result and unlocks only its own dependent tests. A crash, missing/invalid report or inconsistent +process status fails the producer. An expired native deadline writes the reports of the parts first (a part that never +reported fails with the deadline as its diagnostic; the application and terminal parts, whose shutdown checks cannot +have run, are reported failed) and then exits with 1, so the parts that finished keep their results. The `--session` +command itself still exits with 1 when any part fails. A nested CTest regression verifies failed and successful readers +as well as their downstream fixtures, and a session ended by a shortened deadline (`WEBFRONT_TEST_DEVELOPER_DEADLINE`, +in seconds, 180 by default), using the same registration helper as the real suite. Each report retains the part's diagnostic. Life's generated header and the terminal's cancellation check still come from their respective parts. Browser deadlines start after file preparation. An explicit hidden WKWebView case checks both native invisibility and `inactiveSchedulingPolicy == None`; ordinary windows remain visible. When the runtime lacks this preference (macOS 13.3), that case checks the documented rejection of hidden sessions. @@ -113,7 +118,16 @@ openings to one, publication's four commands from four to one, and manifest-dire With sessions disabled, the original individual commands and the six separate developer windows remain available. The session reserves four CTest processors to account for its bounded internal parallelism. Each part retains its own native 180-second deadline, even while other parts finish. Compare full-suite wall time as well as openings before -claiming a speedup. The session prints `nativeWindows=1 parts=6 durationMs=...` for timing comparisons. +claiming a speedup. The session prints each part's `connectedMs` and `reportedMs` and the final +`nativeWindows=1 parts=6 durationMs=...` for timing comparisons. + +Where the time goes, on macOS 27 with WKWebView (warm caches, 8 cores): the parts take 1.9 to 4.7 s alone, 19.5 s in all, +and 10.8 to 11.4 s run as six separate processes with four workers or as the shared window. In the shared window the five +concurrent parts end after 7 to 9 s (TypeScript, slowed from 4.7 s by the others, is last) and workspace then needs its own +1.9 s at the top level: it is the sequential tail, of the order of the 1.8 s gap of the Windows comparison below (not measured on Windows). Starting TypeScript first and +admitting the fifth pane moved the total from 11.1 s to 10.8 s on this machine; the five parts' total is bound by the shared +page's JavaScript and Worker work, not by the number of windows. A part's environment is unpacked on every page load, +so a pane cannot warm workspace's bootstrap for its later top-level page. A local Windows/MSVC Release/WebView2 comparison used the same executable and fixtures, with four workers and no concurrent compiler: six separate visible windows took 26.89 s; the shared visible window took 28.69 s (28.34 s inside diff --git a/test/cmake/CheckDeveloperSessionFailure.cmake b/test/cmake/CheckDeveloperSessionFailure.cmake index 9b87af76..a8fc0a3b 100644 --- a/test/cmake/CheckDeveloperSessionFailure.cmake +++ b/test/cmake/CheckDeveloperSessionFailure.cmake @@ -1,89 +1,123 @@ # Exercise the session coordinator's failure paths without compiling the application six times. -file(MAKE_DIRECTORY "${WORK}/fixtures") -file(WRITE "${WORK}/fixtures/provision.json" "{\"integrity\":\"sha512-unused-by-the-coordinator-spec\"}") -file(WRITE "${WORK}/fixtures/run.mjs" [=[ +# Scenario "failed": parts report, some failing. Scenario "expired": the workspace part never reports and the native +# deadline (shortened for the test) ends the session, which must still leave the reports of the parts that finished. +get_filename_component(cmake_bin "${CMAKE_COMMAND}" DIRECTORY) +find_program(CTEST_EXECUTABLE ctest HINTS "${cmake_bin}" REQUIRED) +set(helper "${CMAKE_CURRENT_LIST_DIR}/DeveloperSessionTests.cmake") + +function(run_scenario scenario) + set(dir "${WORK}/${scenario}") + file(MAKE_DIRECTORY "${dir}/fixtures") + file(WRITE "${dir}/fixtures/provision.json" "{\"integrity\":\"sha512-unused-by-the-coordinator-spec\"}") + set(hang "false") + if(scenario STREQUAL "expired") + set(hang "true") + endif() + file(WRITE "${dir}/fixtures/run.mjs" "const hang = ${hang};\n" [=[ await webFront.ready; const part = await webFront.cppFunction('test.part')(); // Every concurrent pane must receive rendering frames; a hidden iframe must not stand in for a shared visible window. await new Promise(requestAnimationFrame); -if (parent !== self) { - parent.postMessage('webfront-developer-ready', new URL(document.referrer).origin); +const host = new URLSearchParams(location.search).get('developer-session'); +if (host && parent !== self) { + parent.postMessage('webfront-developer-ready', host); await new Promise(resolve => setTimeout(resolve, 100)); } +if (hang && part === 'workspace') await new Promise(() => {}); // The first case fails. Later cases must still run; terminal deliberately reports failure too, without starting a command. await webFront.cppFunction('test.report')(part !== 'app' && part !== 'terminal', `session-failure ${part}`); -if (parent === self) window.close(); -else parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin); +if (host && parent !== self) parent.postMessage('webfront-developer-finished', host); +else window.close(); ]=]) -# Run the production fixture graph through CTest: an aggregate failure must not skip report readers. -set(helper "${CMAKE_CURRENT_LIST_DIR}/DeveloperSessionTests.cmake") -file(MAKE_DIRECTORY "${WORK}/source") -set(project [=[ + # Run the production fixture graph through CTest: an aggregate failure must not skip report readers. + file(MAKE_DIRECTORY "${dir}/source") + set(project [=[ cmake_minimum_required(VERSION 3.31) project(DeveloperSessionFailure LANGUAGES NONE) enable_testing() include([==[@helper@]==]) set(prefix [==[@PREFIX@]==]) -webfront_add_developer_session_tests(PROGRAM [==[@PROGRAM@]==] FIXTURES [==[@WORK@/fixtures]==] - OUTPUT [==[@WORK@/output]==] PREFIX ${prefix}) +webfront_add_developer_session_tests(PROGRAM [==[@PROGRAM@]==] FIXTURES [==[@dir@/fixtures]==] + OUTPUT [==[@dir@/output]==] PREFIX ${prefix}) set_tests_properties(DeveloperBrowserIntegration-scripts PROPERTIES FIXTURES_SETUP SuccessfulPart) add_test(NAME SuccessfulConsumer COMMAND "${CMAKE_COMMAND}" -E echo "successful-dependent-ran") set_tests_properties(SuccessfulConsumer PROPERTIES FIXTURES_REQUIRED SuccessfulPart) add_test(NAME FailedConsumer COMMAND "${CMAKE_COMMAND}" -E echo "failed-dependent-must-not-run") set_tests_properties(FailedConsumer PROPERTIES FIXTURES_REQUIRED DeveloperGenerated) ]=]) -string(CONFIGURE "${project}" project @ONLY) -file(WRITE "${WORK}/source/CMakeLists.txt" "${project}") -execute_process(COMMAND "${CMAKE_COMMAND}" -S "${WORK}/source" -B "${WORK}/build" - RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 10) -if(NOT status EQUAL 0) - message(FATAL_ERROR "Cannot configure the CTest failure graph: ${output}${errors}") -endif() -get_filename_component(cmake_bin "${CMAKE_COMMAND}" DIRECTORY) -find_program(CTEST_EXECUTABLE ctest HINTS "${cmake_bin}" REQUIRED) -execute_process(COMMAND "${CTEST_EXECUTABLE}" --test-dir "${WORK}/build" -C Release --parallel 4 -V - --output-junit "${WORK}/results.xml" -R "DeveloperBrowserIntegration|SuccessfulConsumer|FailedConsumer" - RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE errors TIMEOUT 45) -if(NOT status STREQUAL "8") - message(FATAL_ERROR "The CTest graph must fail only for its failed cases, got ${status}: ${output}${errors}") -endif() -file(READ "${WORK}/results.xml" results) -function(expect_case name expected) - string(FIND "${results}" "" end) - string(SUBSTRING "${item}" 0 ${end} item) - set(actual passed) - if(item MATCHES "" end) + string(SUBSTRING "${item}" 0 ${end} item) + set(actual passed) + if(item MATCHES " #include +#include +#include namespace webfront::testdriver { -inline bool diagnosticWindows() { - // Rendering remains visible during daily runs. Reduce window openings by sharing sessions. - return true; -} +// Rendering stays visible in daily runs; repeated openings are reduced by sharing sessions, not by hiding windows. +inline constexpr bool visibleWindows = true; template struct TestFrontend : Frontend { @@ -23,24 +23,20 @@ struct TestFrontend : Frontend { open(address, port, page, policy, window, ViewLaunch{}); } // The launch proof reaches the engine as it does in an application: the suite runs the same association. - static void open(std::string_view address, - std::string_view port, - std::string_view page, - const ContentPolicy& policy, - const WindowOptions& window, - const ViewLaunch& launch) { + static void open(std::string_view address, std::string_view port, std::string_view page, const ContentPolicy& policy, const WindowOptions& window, + const ViewLaunch& launch) { if constexpr (std::is_same_v) { frontend::WKWebViewOptions options; options.contentPolicy = policy; options.window = window; options.launch = launch; - options.visible = diagnosticWindows(); + options.visible = visibleWindows; Frontend::open(address, port, page, options); } else if constexpr (std::is_same_v) { frontend::WebView2Options options; options.contentPolicy = policy; options.window = window; - options.visible = diagnosticWindows(); + options.visible = visibleWindows; options.launch = launch; Frontend::open(address, port, page, options); } else { diff --git a/test/driver/WfDriver.hpp b/test/driver/WfDriver.hpp index 990cf868..2217f78c 100644 --- a/test/driver/WfDriver.hpp +++ b/test/driver/WfDriver.hpp @@ -49,7 +49,7 @@ struct DriverWebView2Options { } static frontend::WebView2Options get(const char* profile) { frontend::WebView2Options options; - options.visible = diagnosticWindows(); + options.visible = visibleWindows; if (profile && *profile) options.userDataFolder = std::filesystem::path(profile); return options; diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 0e999f45..b02fcd18 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -321,10 +321,10 @@ if(_browser_tests_available) PREFIX ${_developer_session_prefix} REQUIRES DeveloperFixtures WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") webfront_use_own_profile(DeveloperBrowserSession developer-session) add_test(NAME DeveloperBrowserSessionFailure COMMAND ${CMAKE_COMMAND} - -DPROGRAM=$ "-DPREFIX=${_developer_session_prefix}" + -DPROGRAM=$ "-DPREFIX=${_developer_session_prefix}" -DCONFIG=$ -DWORK=${CMAKE_CURRENT_BINARY_DIR}/developer-session-failure -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckDeveloperSessionFailure.cmake) - set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES LABELS "web-integration" TIMEOUT 60 PROCESSORS 4) + set_tests_properties(DeveloperBrowserSessionFailure PROPERTIES LABELS "web-integration" TIMEOUT 240 PROCESSORS 4) webfront_use_own_profile(DeveloperBrowserSessionFailure developer-session-failure) if(WEBFRONT_WEBTEST_FRONTEND STREQUAL "CEF") set_tests_properties(DeveloperBrowserSession PROPERTIES RESOURCE_LOCK webfront_port_9002) diff --git a/test/web/DeveloperTest.cpp b/test/web/DeveloperTest.cpp index 72344e5f..0d5569cc 100644 --- a/test/web/DeveloperTest.cpp +++ b/test/web/DeveloperTest.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,7 @@ std::string readFixtureText(const std::filesystem::path& path) { class FixturesFS { public: - explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) { } + explicit FixturesFS(std::filesystem::path projectRoot) : root(std::filesystem::canonical(projectRoot)) {} std::optional open(std::filesystem::path path) const { const auto relative = path.relative_path().generic_string(); if (!relative.starts_with("fixtures/")) @@ -88,9 +89,9 @@ void registerCallbacks(App& app, const std::filesystem::path& project, std::atom }); app.cppFunction("test.report", [&passed, reported = std::move(reported)](bool success, std::string message) { std::cout << message << std::endl; + passed.store(success); if (reported) reported(std::move(message)); - passed.store(success); }); } @@ -227,8 +228,8 @@ Mode parseMode(std::string_view argument) { mode.part = "app"; } else if (argument.starts_with("--part=")) { mode.part = std::string(argument.substr(7)); - if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal" - && mode.part != "workspace") + if (mode.part != "app" && mode.part != "scripts" && mode.part != "typescript" && mode.part != "jasmine" && mode.part != "terminal" && + mode.part != "workspace") throw std::invalid_argument("Unknown part of the developer test: " + mode.part); } else { throw std::invalid_argument("Unknown smoke-test mode"); @@ -249,9 +250,30 @@ void copyHeaders(const std::filesystem::path& project, const std::filesystem::pa std::filesystem::copy_file(project / "generated/LifeUI.hpp", output / "LifeUI.hpp", std::filesystem::copy_options::overwrite_existing); } +// The native bound of a part. The nested failure regression shortens it to exercise the expiry path in seconds. +std::chrono::seconds partDeadline() { + static const auto value = [] { + std::string text; +#ifdef _MSC_VER + char* raw = nullptr; + std::size_t size = 0; + if (_dupenv_s(&raw, &size, "WEBFRONT_TEST_DEVELOPER_DEADLINE") == 0 && raw) { + text = raw; + std::free(raw); + } +#else + if (const auto* raw = std::getenv("WEBFRONT_TEST_DEVELOPER_DEADLINE")) + text = raw; +#endif + return text.empty() ? 180s : std::chrono::seconds{std::stoi(text)}; + }(); + return value; +} + constexpr auto runScript = "import('/fixtures/run.mjs').catch(async e => { await webFront.cppFunction('test.report')(false, String(e.stack || e));" - " if (location.search === '?developer-session' && parent !== self) parent.postMessage('webfront-developer-finished', new URL(document.referrer).origin);" + " const host = new URLSearchParams(location.search).get('developer-session');" + " if (host && parent !== self) parent.postMessage('webfront-developer-finished', host);" " else window.close(); });"; // A part keeps its original project, origin, bridge and command ownership. Only the native window is shared. @@ -259,13 +281,23 @@ class Part { using App = webfront::BasicDeveloperApp; public: - Part(const std::filesystem::path& fixtures, Mode selected, std::function onReported = {}) - : app(project.path(), {.port = "0"}), mode(std::move(selected)), states(std::make_shared()), commands(app) { + // `onExpired` runs on the watchdog thread, just before the process leaves for an expired native deadline. + Part(const std::filesystem::path& fixtures, Mode selected, std::function onReported = {}, std::function onExpired = {}) + : app(project.path(), configFor(selected)), + mode(std::move(selected)), + states(std::make_shared()), + commands(app), + expired(std::move(onExpired)) { std::filesystem::copy(fixtures, project.path() / "fixtures", std::filesystem::copy_options::recursive); registerCallbacks(app, project.path(), passed, [this, onReported = std::move(onReported)](std::string message) { - if (reported.exchange(true)) - throw std::runtime_error("A developer part reported twice"); - reportMessage = std::move(message); + { + std::scoped_lock lock{reportMutex}; + if (reported) + throw std::runtime_error("A developer part reported twice"); + reportMessage = std::move(message); + reported = true; + reportedAt = std::chrono::steady_clock::now(); + } if (onReported) onReported(); if (caseDeadline) @@ -287,8 +319,9 @@ class Part { bootstrapApp(app, mode, readIntegrity(project.path() / "fixtures/provision.json")); subscription = app.subscribeUIStarted([this, injected = false](App::UI ui) mutable { if (!std::exchange(injected, true)) { + connectedAt = std::chrono::steady_clock::now(); if (caseDeadline) - caseDeadline->beginCase(180s); + caseDeadline->beginCase(partDeadline()); ui.addScript(runScript); } }); @@ -315,6 +348,8 @@ class Part { if (caseDeadline->expired(stop)) { std::cerr << "Developer part exceeded its native deadline: " << mode.part << '\n'; std::cerr.flush(); + if (expired) + expired(); std::_Exit(1); } }); @@ -334,8 +369,25 @@ class Part { const std::filesystem::path& directory() const { return project.path(); } - std::string_view message() const { - return reportMessage; + // What the part has reported so far, readable from any thread. + struct Outcome { + bool reported; + bool passed; + std::string message; + }; + Outcome outcome() const { + std::scoped_lock lock{reportMutex}; + return {reported, passed.load(), reportMessage}; + } + const std::string& name() const { + return mode.part; + } + // When the part's page connected and when it reported, for the session's timeline (read after shutdown). + std::chrono::steady_clock::time_point connected() const { + return connectedAt; + } + std::chrono::steady_clock::time_point reportedTime() const { + return reportedAt; } bool finish(const std::filesystem::path& output) { @@ -345,8 +397,9 @@ class Part { if (server.joinable()) server.join(); app.shutdown(); - bool success = reported.load() && passed.load(); - if (!reported.load()) + const bool wasReported = outcome().reported; + bool success = wasReported && passed.load(); + if (!wasReported) reportMessage = "Developer part " + mode.part + " closed without reporting a result"; if (success && mode.runs("terminal") && !mode.publicDistribution && states->get("final") != "cancelled") { reportMessage = "The command running at shutdown was not drained: " + states->get("final"); @@ -369,19 +422,39 @@ class Part { webfront::test::TemporaryDirectory project; App app; Mode mode; - std::atomic passed{false}, reported{false}; + static webfront::WebFrontConfig configFor(const Mode& selected) { + webfront::WebFrontConfig config; + // A part has no port of its own to keep: the parts run at the same time, each on the port the system gives it. + if (selected.part != "all") + config.port = "0"; + return config; + } + + std::atomic passed{false}; + bool reported = false; + mutable std::mutex reportMutex; std::shared_ptr states; webfront::Commands commands; + std::function expired; webfront::UISubscription subscription; std::string reportMessage; + std::chrono::steady_clock::time_point connectedAt{}, reportedAt{}; std::optional caseDeadline; std::jthread watchdog; std::jthread server; }; +void writeReport(const std::filesystem::path& output, std::string_view name, bool success, std::string_view message) { + std::ofstream report(output / "results" / (std::string(name) + ".json")); + report << "{\"exitCode\":" << (success ? 0 : 1) << ",\"output\":" << webfront::json::quote(message) << "}"; + report.close(); + if (!report) + throw std::runtime_error("Cannot write developer part report"); +} + int runSession(const std::filesystem::path& fixtures, const std::filesystem::path& output) { const auto started = std::chrono::steady_clock::now(); - constexpr std::string_view names[]{"app", "scripts", "typescript", "jasmine", "terminal", "workspace"}; + constexpr std::string_view names[]{"typescript", "app", "jasmine", "scripts", "terminal", "workspace"}; std::filesystem::create_directories(output / "results"); // Remove only this invocation's own reports, so a crash cannot leave a previous success behind. for (const auto name : names) @@ -390,14 +463,43 @@ int runSession(const std::filesystem::path& fixtures, const std::filesystem::pat std::vector> parts; webfront::ContentPolicy policy; std::string urls = "["; - for (const auto name : names) { - auto part = std::make_unique(fixtures, Mode{false, std::string(name)}, [&deadlines] { - deadlines->beginCase(180s); + // A deadline ends the process, but the parts that already reported keep their results: each reader decides for itself. + std::once_flag aborted; + const auto abortSession = [&] { + std::call_once(aborted, [&] { + for (const auto& part : parts) { + const auto outcome = part->outcome(); + // A part with shutdown checks (header copy, drained command) cannot claim them before it has shut down. + const bool complete = outcome.reported && outcome.passed && part->name() != "app" && part->name() != "terminal"; + std::string message = outcome.reported ? outcome.message : "Developer part " + part->name() + " did not report before the session deadline"; + if (outcome.reported && outcome.passed && !complete) + message += " (the session ended before this part's shutdown checks)"; + try { + writeReport(output, part->name(), complete, message); + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; + } + } + std::cout << "Developer session: nativeWindows=1 parts=6 aborted=1" << std::endl; }); + }; + for (const auto name : names) { + auto part = std::make_unique( + fixtures, + Mode{false, std::string(name)}, + [&deadlines] { + deadlines->beginCase(partDeadline()); + }, + abortSession); policy.navigationAllowedOrigins.push_back(part->origin()); - urls += (urls.size() > 1 ? "," : "") + webfront::json::quote(part->origin() + "/webfront-bootstrap.html?developer-session"); parts.push_back(std::move(part)); } + // The page names its host: a frame cannot rely on its referrer to address it. + std::string hostQuery; + for (const char c : parts.front()->origin()) + hostQuery += (std::isalnum(static_cast(c)) || c == '.') ? std::string(1, c) : "%" + std::string(c == ':' ? "3A" : "2F"); + for (const auto& part : parts) + urls += (urls.size() > 1 ? "," : "") + webfront::json::quote(part->origin() + "/webfront-bootstrap.html?developer-session=" + hostQuery); urls += "]"; const auto page = parts.front()->directory() / "fixtures/developer-suite.html"; std::ofstream html(page, std::ios::binary); @@ -408,7 +510,7 @@ section{min-width:0;min-height:0}header{height:28px;line-height:28px;padding:0 1 iframe{display:block;border:0;width:100%;height:calc(100% - 28px)}