diff --git a/cmake/WKWebViewSupport.cmake b/cmake/WKWebViewSupport.cmake index 8a49393b..51d9e147 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) + 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) add_test(NAME WKWebViewLifecycle-${mode} COMMAND wkwebview_lifecycle ${mode}) webfront_set_browser_test_properties("WKWebViewLifecycle-${mode}" "${webtest_source_dir}" 90) endforeach() diff --git a/cmake/WebKitGTKSupport.cmake b/cmake/WebKitGTKSupport.cmake index b901fd30..00a8c4f0 100644 --- a/cmake/WebKitGTKSupport.cmake +++ b/cmake/WebKitGTKSupport.cmake @@ -25,7 +25,7 @@ function(webfront_add_webkitgtk_tests) target_link_libraries(webkitgtk_lifecycle PRIVATE WebFront_test_hardening WebFront WebFront_warnings WebFront_options) add_dependencies(webtest webkitgtk_lifecycle) webfront_find_xvfb(display_runner) - foreach(mode no-display worker-thread native-close repeated-show http-error pre-run-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog) + foreach(mode no-display worker-thread native-close repeated-show http-error pre-run-failure profile-permissions window-title download download-user-dir choose-file cancel-choose close-with-dialog script-dialogs close-with-script-dialog) if(mode MATCHES "^(no-display|worker-thread|pre-run-failure|profile-permissions)$") add_test(NAME WebKitGTKAdapter-${mode} COMMAND webkitgtk_lifecycle ${mode}) elseif(display_runner) diff --git a/cmake/WebView2Support.cmake b/cmake/WebView2Support.cmake index 7725049b..5f7dd632 100644 --- a/cmake/WebView2Support.cmake +++ b/cmake/WebView2Support.cmake @@ -66,7 +66,7 @@ function(webfront_add_webview2_tests) target_link_libraries(webview2_lifecycle PRIVATE WebFront WebFront_warnings WebFront_options) foreach(mode repeated-show native-early-close navigation-diagnostic mta missing-runtime closed-startup-timeout failed-startup-timeout late-navigation-failure runtime-ready - file-choose file-cancel file-download) + file-choose file-cancel file-download script-dialogs) add_test(NAME WebView2Lifecycle-${mode} COMMAND webview2_lifecycle ${mode}) webfront_set_browser_test_properties("WebView2Lifecycle-${mode}" "${webtest_source_dir}" 45) endforeach() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ffaa02fc..fed4365a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +- Embedded frontends: `alert`, `confirm`, `prompt` and `beforeunload` (`beforeunload` is not handled under WKWebView, see `docs/FRONTENDS.md`; #452, ADR-020 rule 6). WKWebView implements the three + `WKUIDelegate` panel methods (an `NSAlert` sheet of the window; without them these calls did nothing); WebKitGTK, CEF and + WebView2 keep their engine's dialogs. A shared test injection (`frontend/ScriptDialogs.hpp`) answers the dialogs in each + frontend, and closing the window with a box open dismisses it. See `docs/FRONTENDS.md` for the engine-by-engine coverage. + - Embedded frontends: `` and downloads (#451, ADR-020 rule 6). WebKitGTK saves downloads to the user's download folder (name reduced to its last component, never overwritten); WKWebView gets `runOpenPanelWithParameters` and `WKDownload`; CEF and WebView2 use the engine's own handling. A `blob:` URL of an admitted origin diff --git a/docs/FRONTENDS.md b/docs/FRONTENDS.md index 393195a1..7885fb43 100644 --- a/docs/FRONTENDS.md +++ b/docs/FRONTENDS.md @@ -93,6 +93,44 @@ frames, which WKWebView judges by their inherited origin. events, and the bytes written by a completed Blob download. It intercepts the chooser with DevTools and suppresses the download UI, so it does not qualify the native dialogs themselves or closing the window while one is open. +## Script dialogs + +`alert`, `confirm` and `prompt` work in every embedded frontend, and `beforeunload` in all but WKWebView, without a WebFront API (ADR-020, rule 6, #452). +All four engines use the system's or the engine's own box attached to the window by default; each frontend also has a test +injection that answers without a box, with the shared types of `frontend/ScriptDialogs.hpp` (`ScriptDialog`, +`ScriptDialogAnswer`, `ScriptDialogHandler`). Closing the window with a box open never waits for an answer. Under WKWebView the sheet's completion handler answers dismissed (`false` for `confirm`, `null` for `prompt`); +under the other engines the page is gone with the window, and the value its call would have returned is not observable. + +| Frontend | Dialogs | Test injection | +| --- | --- | --- | +| WebKitGTK | `script-dialog` signal; the default handler shows WebKitGTK's dialog on the window | `Session::answerScriptDialog` (`scriptDialogOpened` reports the default dialog) | +| CEF (Chrome runtime) | `CefJSDialogHandler` (`OnJSDialog`, `OnBeforeUnloadDialog`) answered only by the injection; otherwise the runtime's own dialogs | `SimpleCEFClient::answerScriptDialog` | +| WKWebView | the three `WKUIDelegate` panel methods (alert, confirm, prompt; not `beforeunload`, see below) show an `NSAlert` sheet of the window (an accessory text field for `prompt`); only frames whose security origin is the application's, others (including a sandboxed frame without `allow-same-origin`, whose origin is opaque even at the application's URL) are dismissed | `WKWebViewOptions::answerScriptDialog` | +| WebView2 | the engine's own dialogs, until the injection turns them off and answers `ScriptDialogOpening` (kinds alert, confirm, prompt, beforeunload) | `Session::answerScriptDialog` (adapter-internal, set from a `prepare` hook) | + +Origin filtering differs: WKWebView answers dismissed for a frame outside the application's origin, because its code shows the +box itself. WebKitGTK, CEF and WebView2 leave the decision to the engine's own dialog (or to the injection), without a +WebFront origin check; the content policy that already restricts navigation to admitted origins is the guard there. + +**Limit: closing the window does not ask `beforeunload`.** Closing the window itself is not a page navigation. Under WebView2 +the window's `WM_CLOSE` ends in `ICoreWebView2Controller::Close`, which does not raise `beforeunload`; navigations and reloads +can reach the handler. Under WebKitGTK and CEF this was not verified. A page can therefore lose unsaved changes when the user +closes the window; the application must save its state itself (for example on `visibilitychange`). + +**Limit: WKWebView does not handle `beforeunload`.** The public `WKUIDelegate` has no method for it; WebKit routes it through a +private selector (`_webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:completionHandler:`), not through the confirm +method, and WebFront does not implement a private selector. A page that asks for a confirmation before leaving can therefore +lose unsaved changes under WKWebView; the application must save its state itself (for example on `visibilitychange`). This was +not verified on macOS: support through the private selector, if wanted, needs a decision and a check on a real system. The other +three engines report `ScriptDialog::Kind::beforeUnload`. + +Tests: `WebKitGTKAdapter-script-dialogs` and `CEFFileServices-dialogs` check that each dialog reaches the injection with its +message and default text, that a confirmed `confirm` returns `true`, an accepted `prompt` returns its text and a dismissed +one returns `null`. `WebKitGTKAdapter-close-with-script-dialog` and `CEFFileServices-hold` close the window under an open +alert; `WKWebViewLifecycle-script-dialogs|close-with-script-dialog|sandboxed-script-dialog` (the last: a sandboxed opaque-origin frame's `confirm` is dismissed, never shown) and `WebView2Lifecycle-script-dialogs` cover the same +on their engines (the WebView2 case has no close-under-dialog scenario). No scenario triggers a real `beforeunload` (the +engines show it only after a user gesture on the page); its wiring is implemented but not exercised end to end. + ## Adding a frontend 1. Implement the type in `include/webfront/frontend/` following the contract above and include it from `Frontend.hpp`. Keep platform headers behind the option's macro. diff --git a/docs/adr/ADR-020-services-systeme.md b/docs/adr/ADR-020-services-systeme.md index 11295d76..0e2b2413 100644 --- a/docs/adr/ADR-020-services-systeme.md +++ b/docs/adr/ADR-020-services-systeme.md @@ -6,6 +6,7 @@ | --- | --- | --- | --- | --- | --- | | 1.0 | 2026-10-31 | Proposée | Ambroise Leclerc | Décision initiale : distinction hôte/client, préalables regroupés en épiques (#446 à #450), confinement des racines pendant la résolution et hypothèse de confiance face au déplacement d'un répertoire ouvert ou de la racine, autorisation attachée à l'emplacement déclaré, propriétaires admissibles des répertoires et des ancêtres, transport du navigateur système déclaré (`loopbackAttested`) plutôt que prouvé par un secret de lancement, jetons de lecture réutilisables liés à la connexion par un cookie, exposition des jetons et transport des lectures distantes, exception de confiance explicite, liaison HTTP par profil de navigateur avec cookies nommés par client, contenu actif neutralisé, transport déclaré et association de lancement du navigateur système, racines déclarées accessibles à tout script admis, services en composants facultatifs, sélection par l'utilisateur valant autorisation (poignées plutôt que chemins), backends natif, HTML et navigateur choisis par connexion, contenu des fichiers par HTTP à jeton ; état de l'art et inventaire des autres services. | À renseigner après intégration. | | 1.1 | 2026-11-02 | Proposée, partiellement livrée | Ambroise Leclerc | Livraison partielle de l'étape 1 pour #451 (sélecteur de fichiers et téléchargements sous WebKitGTK, CEF, WKWebView et WebView2) ; #452 reste à faire. La section « État de l'étape 1 » distingue les preuves de validation par moteur et par révision ; `docs/FRONTENDS.md` précise les limites de couverture. | Branche `451-file-chooser-downloads` (PR #484), implémentation initiale `91049ab`, stockage privé WKWebView `52d8c68` | +| 1.2 | 2026-11-03 | Proposée, partiellement livrée | Ambroise Leclerc | Livraison de #452 (`alert`, `confirm`, `prompt` partout ; `beforeunload` sauf sous WKWebView, qui n'a pas de délégué public pour lui) : l'étape 1 n'est complète qu'avec cette limite. `docs/FRONTENDS.md` précise la couverture par moteur (WKWebView et WebView2 non exécutés localement ; `beforeunload` non exercé de bout en bout et jamais demandé à la fermeture de la fenêtre). | Branche `452-script-dialogs` | ## État et chronologie @@ -368,7 +369,7 @@ révisions indiquées ; ils ne qualifient pas automatiquement les changements ul À la révision `52d8c68`, le nouveau stockage privé WKWebView n'avait pas été exécuté sur macOS : la compilation CI avait échoué avant les tests. Le correctif et les validations ultérieures sont consignés dans la PR #484. La qualification des dialogues natifs reste partielle ; les injections de test ne la remplacent pas. `docs/FRONTENDS.md` détaille les -limites par moteur. #452 reste à faire et l'ADR reste proposée. +limites par moteur. #452 est livré dans la version 1.2 (`beforeunload` n'est pas pris en charge sous WKWebView ; sous WebView2, la fermeture de la fenêtre elle-même ne le déclenche pas non plus, seules les navigations et les rechargements le font ; non vérifié sous WebKitGTK et CEF, voir `docs/FRONTENDS.md`) ; l'ADR reste proposée. Après l'étape 4, le premier service (sélecteur HTML, poignées, import et export côté client) fera l'objet de sa propre épique ; les dialogues natifs suivront l'étape 5. `PUT`/`POST` ne sont pas des préalables : les écritures passent par diff --git a/docs/adr/README.md b/docs/adr/README.md index 0cbfa31a..6550f1c7 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -60,7 +60,7 @@ verification evidence remain in [PROJECT_STATUS](../PROJECT_STATUS.md). | [ADR-017](ADR-017-acces-direct-aux-frontends.md) | Direct access to embedded frontends, with HTML kept normative | Proposed | 2026-10-24 | 1.1 — 2026-10-25 | | [ADR-018](ADR-018-acces-au-dom.md) | DOM access from C++ through a bounded mutation stream, without contesting the DOM of UI libraries | Proposed, partially superseded, partially delivered | 2026-10-26 | 1.5 — 2026-10-30 | | [ADR-019](ADR-019-developpement-automatisable-et-agents.md) | Automating the developer environment through shared operations and an optional local MCP adapter | Accepted | 2026-10-28 | 1.2 — 2026-10-29 | -| [ADR-020](ADR-020-services-systeme.md) | System services (files, clipboard, shell, notifications…) through optional C++ portals with per-connection backends, granting handles rather than paths | Proposed | 2026-10-31 | 1.0 — 2026-10-31 | +| [ADR-020](ADR-020-services-systeme.md) | System services (files, clipboard, shell, notifications…) through optional C++ portals with per-connection backends, granting handles rather than paths | Proposed | 2026-10-31 | 1.2 — 2026-11-03 | | [ADR-021](ADR-021-publication-de-l-environnement-developpeur.md) | Simplifying the publication of the developer environment: automate the release, keep pinned hashes, no dedicated server | Accepted (domain delivered; phase 1 to implement) | 2026-11-02 | 1.0 — 2026-11-02 | Numbering follows the reading topics; milestones and individual file histories provide diff --git a/include/webfront/frontend/CEF.hpp b/include/webfront/frontend/CEF.hpp index 7fe95c26..445818bc 100644 --- a/include/webfront/frontend/CEF.hpp +++ b/include/webfront/frontend/CEF.hpp @@ -7,6 +7,7 @@ #include "Capture.hpp" #include "DefaultBrowser.hpp" #include "Downloads.hpp" +#include "ScriptDialogs.hpp" #include "Url.hpp" #include "Window.hpp" @@ -499,7 +500,8 @@ class SimpleCEFClient : public CefClient, public CefContextMenuHandler, public CefCommandHandler, public CefDownloadHandler, - public CefDialogHandler { + public CefDialogHandler, + public CefJSDialogHandler { public: explicit SimpleCEFClient(webfront::detail::BoundContentPolicy policy = webfront::detail::BoundContentPolicy{}, browser::Launcher launch = browser::launch) : contentPolicy(std::move(policy)), popupLauncher(launch) { } @@ -535,6 +537,33 @@ class SimpleCEFClient : public CefClient, CefRefPtr GetDialogHandler() override { return this; } + /// Test injection: answers alert, confirm, prompt and beforeunload without a dialog. Unset keeps the engine's own dialogs. + frontend::ScriptDialogHandler answerScriptDialog; + CefRefPtr GetJSDialogHandler() override { + return this; + } + bool OnJSDialog(CefRefPtr, + const CefString&, + JSDialogType type, + const CefString& message, + const CefString& defaultText, + CefRefPtr callback, + bool&) override { // suppress_message stays false: the injection is the answer. + if (!answerScriptDialog) + return false; + frontend::ScriptDialog dialog; + dialog.kind = type == JSDIALOGTYPE_CONFIRM ? frontend::ScriptDialog::Kind::confirm + : type == JSDIALOGTYPE_PROMPT ? frontend::ScriptDialog::Kind::prompt + : frontend::ScriptDialog::Kind::alert; + dialog.message = message.ToString(); + dialog.defaultText = defaultText.ToString(); + return answer(dialog, callback); + } + bool OnBeforeUnloadDialog(CefRefPtr, const CefString& message, bool, CefRefPtr callback) override { + if (!answerScriptDialog) + return false; + return answer({frontend::ScriptDialog::Kind::beforeUnload, message.ToString(), {}}, callback); + } bool OnFileDialog(CefRefPtr, FileDialogMode, const CefString&, @@ -705,6 +734,17 @@ class SimpleCEFClient : public CefClient, } private: + bool answer(const frontend::ScriptDialog& dialog, CefRefPtr callback) { + frontend::ScriptDialogAnswer reply; + try { + reply = answerScriptDialog(dialog); + } catch (...) { + reply = {}; // A failing injection dismisses the dialog; the page must not wait for it. + } + callback->Continue(reply.accepted, reply.text); + return true; + } + webfront::detail::BoundContentPolicy contentPolicy; browser::Launcher popupLauncher; bool loadingInitialPage = true; diff --git a/include/webfront/frontend/ScriptDialogs.hpp b/include/webfront/frontend/ScriptDialogs.hpp new file mode 100644 index 00000000..ddb3e969 --- /dev/null +++ b/include/webfront/frontend/ScriptDialogs.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +namespace webfront::frontend { + +/** @brief A JavaScript dialog the page asked an embedded frontend to show: `alert`, `confirm`, `prompt` or `beforeunload`. */ +struct ScriptDialog { + enum class Kind { alert, confirm, prompt, beforeUnload }; + + Kind kind{Kind::alert}; + std::string message{}; ///< The page's text; for `beforeunload`, whatever text the engine supplies (possibly empty, often a fixed phrase). + std::string defaultText{}; ///< The initial value of a `prompt`. +}; + +/** @brief The answer to a ScriptDialog. `accepted` is `confirm`'s result, `prompt`'s non-null result, and a `beforeunload` that lets the page go. */ +struct ScriptDialogAnswer { + bool accepted{false}; + std::string text{}; ///< The string a `prompt` returns when accepted. +}; + +/** + * @brief Test injection shared by the embedded frontends: answers script dialogs without showing a box. + * + * It runs on the thread of the frontend's window and must return promptly. When unset, each frontend shows the system's box + * attached to its window; closing the window with a box open answers it as dismissed, so the window never blocks on it. + */ +using ScriptDialogHandler = std::function; + +} // namespace webfront::frontend diff --git a/include/webfront/frontend/WKWebView.hpp b/include/webfront/frontend/WKWebView.hpp index c3dba55b..ca5a786c 100644 --- a/include/webfront/frontend/WKWebView.hpp +++ b/include/webfront/frontend/WKWebView.hpp @@ -4,6 +4,7 @@ #include "Action.hpp" #include "Capture.hpp" #include "Downloads.hpp" +#include "ScriptDialogs.hpp" #include "Url.hpp" #include "Window.hpp" @@ -36,6 +37,10 @@ struct WKWebViewOptions { std::filesystem::path downloadDirectory{}; /** @brief Test injection: called with the destination of each finished download. */ std::function downloadFinished{}; + /** @brief Test injection: answers `alert`, `confirm` and `prompt` without a box. Unset shows an NSAlert sheet on the window. + * `beforeunload` is not handled by WKWebView: the public WKUIDelegate has no method for it, and it does not reach the confirm + * method. A page that relies on it can lose unsaved changes on navigation or close; WebFront does not confirm it. */ + ScriptDialogHandler answerScriptDialog{}; }; } // namespace webfront::frontend @@ -554,17 +559,16 @@ struct Session { decision(policy); // Exactly once, including after a C++ exception. } - /// The address a frame is judged by. A frame the page creates without a document of its own (no `src`, or `srcdoc`) - /// is `about:blank` / `about:srcdoc` and inherits its creator's origin, which is what the policy has to see. + /// The address a frame is judged by: always its security origin, never the address of its request. A sandboxed frame + /// without allow-same-origin loads the application's own URL yet has an opaque origin (empty protocol and host, judged as + /// no address, so never the application's). A frame the page creates without a document of its own (`about:blank`, + /// `about:srcdoc`) inherits its creator's origin, which is what the policy has to see. static std::string effectiveFrameUrl(id frame) { - auto address = utf8(send(send(send(frame, "request"), "URL"), "absoluteString")); - if (!address.empty() && !address.starts_with("about:")) - return address; const auto origin = send(frame, "securityOrigin"); const auto protocol = utf8(send(origin, "protocol")); const auto host = utf8(send(origin, "host")); if (protocol.empty() || host.empty()) - return address; // An opaque origin (sandboxed frame): not the application's. + return {}; const auto port = send(origin, "port"); return protocol + "://" + host + (port > 0 ? ":" + std::to_string(port) : "") + "/"; } @@ -618,6 +622,77 @@ struct Session { completion(result); } + /// `alert`, `confirm` and `prompt` (WKUIDelegate): an NSAlert sheet of the window, or the test injection. `answer` runs exactly once, + /// with a dismissed answer when the page's origin is not the application's, when the window closes, or when the box cannot be shown. + void runScriptDialog(ScriptDialog dialog, id frame, std::function answer) noexcept { + ScriptDialogAnswer result; // Dismissed. + bool deferred = false; + guard([&] { + if (!contentPolicy.isApplicationOrigin(effectiveFrameUrl(frame))) + return; + if (options.answerScriptDialog) { + result = options.answerScriptDialog(dialog); + return; + } + const id alert = send(send(type("NSAlert"), "alloc"), "init"); // Owned until the sheet answers. + id field = nullptr; + bool retained = true; + try { + { + Object message(text(dialog.message)); + send(alert, "setMessageText:", message.get()); + } + const bool confirming = dialog.kind != ScriptDialog::Kind::alert; + { + Object accept(text("OK")); + send(alert, "addButtonWithTitle:", accept.get()); // NSAlertFirstButtonReturn (1000). + } + if (confirming) { + Object cancel(text("Cancel")); + send(alert, "addButtonWithTitle:", cancel.get()); + } + if (dialog.kind == ScriptDialog::Kind::prompt) { + field = send(send(type("NSTextField"), "alloc"), "initWithFrame:", CGRect{{0, 0}, {300, 24}}); + Object value(text(dialog.defaultText)); + send(field, "setStringValue:", value.get()); + send(alert, "setAccessoryView:", field); + send(alert, "layout"); + send(send(alert, "window"), "setInitialFirstResponder:", field); + } + auto shared = std::make_shared>(std::move(answer)); + void (^finished)(long) = ^(long response) { + ScriptDialogAnswer reply; + reply.accepted = response == 1000; // endSheet: at window close reports NSModalResponseCancel. + if (reply.accepted && field) + reply.text = utf8(send(field, "stringValue")); + (*shared)(std::move(reply)); + if (field) + send(field, "release"); + send(alert, "release"); + }; + try { + send(alert, "beginSheetModalForWindow:completionHandler:", window, finished); + } catch (...) { + // The call failed to dispatch, so the block never runs and never releases: this function still owns + // the alert and the field (released below) and answers dismissed. + answer = std::move(*shared); + throw; + } + retained = false; // The sheet started: the block owns the alert and the field until it answers. + } catch (...) { + if (retained) { + if (field) + send(field, "release"); + send(alert, "release"); + } + throw; + } + deferred = true; + }); + if (!deferred) + answer(std::move(result)); + } + /// A WKDownload needs a destination that does not exist: the test folder, or the user's choice in a save panel. void chooseDownloadDestination(id download, const std::string& suggested, void (^completion)(id)) noexcept { id result = nullptr; // NSURL*; nil cancels the download. @@ -848,6 +923,53 @@ inline void addNavigationMethods(Class cls) { completion(nullptr); }, "v@:@@@@?"); + // JavaScript dialogs (WKUIDelegate), issue #452. Without these WebKit answers nothing and the page's call does not return. + addMethod( + cls, + "webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:", + +[](id self, SEL, id, id message, id frame, void (^completion)()) { + auto handler = Block_copy(completion); + auto done = [handler](ScriptDialogAnswer) { + handler(); + Block_release(handler); + }; + if (auto s = session(self)) + s->runScriptDialog({ScriptDialog::Kind::alert, utf8(message), {}}, frame, done); + else + done({}); + }, + "v@:@@@@?"); + addMethod( + cls, + "webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:", + +[](id self, SEL, id, id message, id frame, void (^completion)(BOOL)) { + auto handler = Block_copy(completion); + auto done = [handler](ScriptDialogAnswer reply) { + handler(static_cast(reply.accepted)); + Block_release(handler); + }; + if (auto s = session(self)) + s->runScriptDialog({ScriptDialog::Kind::confirm, utf8(message), {}}, frame, done); + else + done({}); + }, + "v@:@@@@?"); + addMethod( + cls, + "webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:", + +[](id self, SEL, id, id message, id defaultText, id frame, void (^completion)(id)) { + auto handler = Block_copy(completion); + auto done = [handler](ScriptDialogAnswer reply) { + Object value(reply.accepted ? text(reply.text) : nullptr); + handler(value.get()); // nil is the prompt's null. + Block_release(handler); + }; + if (auto s = session(self)) + s->runScriptDialog({ScriptDialog::Kind::prompt, utf8(message), defaultText ? utf8(defaultText) : std::string{}}, frame, done); + else + done({}); + }, + "v@:@@@@@?"); const auto becameDownload = +[](id self, SEL, id, id, id download) { send(download, "setDelegate:", self); }; diff --git a/include/webfront/frontend/WebKitGTK.hpp b/include/webfront/frontend/WebKitGTK.hpp index 92a867c0..5f7ebb3f 100644 --- a/include/webfront/frontend/WebKitGTK.hpp +++ b/include/webfront/frontend/WebKitGTK.hpp @@ -6,6 +6,7 @@ #include "Capture.hpp" #include "DefaultBrowser.hpp" #include "Downloads.hpp" +#include "ScriptDialogs.hpp" #include "Url.hpp" #include "Window.hpp" #include "WebKitGTKPolicy.hpp" @@ -123,6 +124,12 @@ class Api { const char* (*downloadGetDestination)(Object) = symbol("webkit_download_get_destination"); void (*chooserSelect)(Object, const char* const*) = symbol("webkit_file_chooser_request_select_files"); void (*chooserCancel)(Object) = symbol("webkit_file_chooser_request_cancel"); + // WEBKIT_SCRIPT_DIALOG_ALERT = 0, CONFIRM = 1, PROMPT = 2, BEFORE_UNLOAD_CONFIRM = 3. + int (*dialogType)(Object) = symbol("webkit_script_dialog_get_dialog_type"); + const char* (*dialogMessage)(Object) = symbol("webkit_script_dialog_get_message"); + void (*dialogConfirm)(Object, int) = symbol("webkit_script_dialog_confirm_set_confirmed"); + const char* (*dialogDefault)(Object) = symbol("webkit_script_dialog_prompt_get_default_text"); + void (*dialogPromptText)(Object, const char*) = symbol("webkit_script_dialog_prompt_set_text"); }; inline Api& api() { @@ -292,6 +299,10 @@ struct Session : FailureState { std::function chooserOpened; /// Test injection: called with the destination of each finished download. std::function downloadFinished; + /// Test injection: answers alert, confirm, prompt and beforeunload without a dialog. Unset shows WebKitGTK's own dialog. + ScriptDialogHandler answerScriptDialog; + /// Test hook: called when WebKitGTK's own script dialog is about to open. + std::function scriptDialogOpened; struct Download { Api::Object object; std::vector handlers; @@ -421,6 +432,7 @@ struct Session : FailureState { on("web-process-terminated", onProcessTerminated); on("decide-policy", onDecidePolicy); on("run-file-chooser", onRunFileChooser); + on("script-dialog", onScriptDialog); } std::filesystem::path destinationFolder() const { @@ -616,6 +628,38 @@ struct Session : FailureState { } return 1; } + static int onScriptDialog(Api::Object, Api::Object dialog, Session* self) noexcept { + if (!self->answerScriptDialog) { + if (self->scriptDialogOpened) + self->scriptDialogOpened(); + return 0; // WebKitGTK's dialog, attached to the window; closing the window dismisses it. + } + auto& a = api(); + ScriptDialog description; + switch (a.dialogType(dialog)) { + case 1: description.kind = ScriptDialog::Kind::confirm; break; + case 2: description.kind = ScriptDialog::Kind::prompt; break; + case 3: description.kind = ScriptDialog::Kind::beforeUnload; break; + default: description.kind = ScriptDialog::Kind::alert; break; + } + if (const auto* message = a.dialogMessage(dialog)) + description.message = message; + if (description.kind == ScriptDialog::Kind::prompt) + if (const auto* initial = a.dialogDefault(dialog)) + description.defaultText = initial; + ScriptDialogAnswer reply; + try { + reply = self->answerScriptDialog(description); + } catch (...) { + reply = {}; // A failing injection dismisses the dialog; the page must not wait for it. + } + if (description.kind == ScriptDialog::Kind::prompt) + a.dialogPromptText(dialog, reply.accepted ? reply.text.c_str() : nullptr); // A null text is the prompt's null. + else if (description.kind != ScriptDialog::Kind::alert) { + a.dialogConfirm(dialog, reply.accepted ? 1 : 0); + } + return 1; + } static int onNavigationTimeout(void* data) noexcept { auto* self = static_cast(data); self->navigationTimer = 0; diff --git a/include/webfront/frontend/WebView2.hpp b/include/webfront/frontend/WebView2.hpp index c444103d..23f28d14 100644 --- a/include/webfront/frontend/WebView2.hpp +++ b/include/webfront/frontend/WebView2.hpp @@ -5,6 +5,7 @@ #include "Action.hpp" #include "Capture.hpp" #include "DefaultBrowser.hpp" +#include "ScriptDialogs.hpp" #include "Url.hpp" #include "Window.hpp" @@ -268,6 +269,9 @@ class Session : public std::enable_shared_from_this { // Internal adapter observer: the browser exists and nothing is loaded yet (the transport benchmark of ADR-017 registers // its message channel here). std::function viewReady; + // Internal adapter injection (issue #452): answers alert, confirm, prompt and beforeunload without a dialog. Unset keeps + // WebView2's own dialogs, which the runtime attaches to the window. + ScriptDialogHandler answerScriptDialog; bool closed = false; UINT_PTR startupTimer = 0; std::shared_ptr captureQueue = std::make_shared(); @@ -736,6 +740,53 @@ class Session : public std::enable_shared_from_this { }).Get(), &token), "registering popup policy"); + if (answerScriptDialog) { + check(settings->put_AreDefaultScriptDialogsEnabled(FALSE), "disabling the default script dialogs"); + check(view->add_ScriptDialogOpening( + Microsoft::WRL::Callback([weak](ICoreWebView2*, + ICoreWebView2ScriptDialogOpeningEventArgs* args) -> HRESULT { + if (const auto self = weak.lock()) + self->scriptDialogOpening(args); + return S_OK; + }).Get(), + &token), + "registering script dialog handler"); + } + } + + void scriptDialogOpening(ICoreWebView2ScriptDialogOpeningEventArgs* args) noexcept { + // Not accepting is the dismissed answer, so any failure below leaves the page's call returning. The injection answers + // synchronously (it must return promptly), so no deferral is taken: the event completes when this handler returns. + try { + COREWEBVIEW2_SCRIPT_DIALOG_KIND kind{}; + check(args->get_Kind(&kind), "reading the script dialog kind"); + ScriptDialog dialog; + switch (kind) { + case COREWEBVIEW2_SCRIPT_DIALOG_KIND_CONFIRM: dialog.kind = ScriptDialog::Kind::confirm; break; + case COREWEBVIEW2_SCRIPT_DIALOG_KIND_PROMPT: dialog.kind = ScriptDialog::Kind::prompt; break; + case COREWEBVIEW2_SCRIPT_DIALOG_KIND_BEFOREUNLOAD: dialog.kind = ScriptDialog::Kind::beforeUnload; break; + default: dialog.kind = ScriptDialog::Kind::alert; break; + } + LPWSTR message = nullptr; + if (SUCCEEDED(args->get_Message(&message)) && message) { + const std::unique_ptr owned(message, CoTaskMemFree); + dialog.message = utf8(owned.get()); + } + if (dialog.kind == ScriptDialog::Kind::prompt) { + LPWSTR initial = nullptr; + if (SUCCEEDED(args->get_DefaultText(&initial)) && initial) { + const std::unique_ptr owned(initial, CoTaskMemFree); + dialog.defaultText = utf8(owned.get()); + } + } + const auto reply = answerScriptDialog(dialog); + if (!reply.accepted) + return; + if (dialog.kind == ScriptDialog::Kind::prompt) + check(args->put_ResultText(utf16(reply.text).c_str()), "setting the prompt result"); + check(args->Accept(), "accepting the script dialog"); + } catch (...) { + } } void configure() { diff --git a/test/web/CEFFileServices.cpp b/test/web/CEFFileServices.cpp index 531b22d7..b8082cf5 100644 --- a/test/web/CEFFileServices.cpp +++ b/test/web/CEFFileServices.cpp @@ -18,12 +18,13 @@ void require(bool value, const char* message) { } struct Scenario { - std::string mode; // download | choose | cancel + std::string mode; // download | choose | cancel | dialogs | hold (script dialogs, issue #452) std::filesystem::path folder; std::filesystem::path fixture; std::string title; std::string downloaded; bool asked = false; + std::vector dialogs; // What the injection point saw, in order. }; Scenario scenario; @@ -34,6 +35,14 @@ class Client : public webfront::cef::SimpleCEFClient { scenario.asked = true; return scenario.mode == "choose" ? std::vector{scenario.fixture.string()} : std::vector{}; }; + if (scenario.mode == "dialogs") + answerScriptDialog = [](const webfront::frontend::ScriptDialog& dialog) { + using Kind = webfront::frontend::ScriptDialog::Kind; + scenario.dialogs.push_back(std::to_string(static_cast(dialog.kind)) + ":" + dialog.message + ":" + dialog.defaultText); + if (dialog.kind == Kind::prompt) + return dialog.message == "name?" ? webfront::frontend::ScriptDialogAnswer{true, "typed"} : webfront::frontend::ScriptDialogAnswer{}; + return webfront::frontend::ScriptDialogAnswer{true, {}}; + }; downloadDirectory = scenario.folder; downloadFinished = [this](const std::string& path) { scenario.downloaded = path; @@ -43,7 +52,11 @@ class Client : public webfront::cef::SimpleCEFClient { void OnTitleChange(CefRefPtr browser, const CefString& title) override { scenario.title = title.ToString(); window = browser; - if (scenario.title == "ready" && scenario.mode != "download") + if (scenario.title.starts_with("answers:")) + finish(); + else if (scenario.title == "holding") + CefPostDelayedTask(TID_UI, new Deadline(this), 1500); // The engine's own alert is open by then: close under it. + else if (scenario.title == "ready" && (scenario.mode == "choose" || scenario.mode == "cancel")) CefPostDelayedTask(TID_UI, new Click(this, 40), 500); else if (scenario.title.starts_with("picked:") || scenario.title == "cancelled") finish(); @@ -119,7 +132,7 @@ struct Frontend { int main(int argc, char** argv) { try { webfront::detail::ensureFrontendInitialized(); // CEF subprocesses run this program too and end here. - require(argc == 2, "usage: cef_file_services download|choose|cancel"); + require(argc == 2, "usage: cef_file_services download|choose|cancel|dialogs|hold"); scenario.mode = argv[1]; scenario.folder = std::filesystem::temp_directory_path() / ("webfront-cef-" + scenario.mode + "-" + std::to_string(getpid())); std::filesystem::remove_all(scenario.folder); @@ -128,7 +141,9 @@ int main(int argc, char** argv) { std::ofstream(scenario.fixture) << "chosen by the test"; using FS = webfront::fs::Multi; webfront::BasicWFWithFrontend app(webfront::WebFrontConfig{.documentRoot = std::filesystem::current_path()}); - app.show("file-services.html?" + (scenario.mode == "download" ? std::string("download") : std::string("choose"))); + app.show(scenario.mode == "hold" ? std::string("script-dialogs.html?hold") + : scenario.mode == "dialogs" ? std::string("script-dialogs.html") + : "file-services.html?" + (scenario.mode == "download" ? std::string("download") : std::string("choose"))); if (scenario.mode == "download") { require(!scenario.downloaded.empty(), "The download did not finish"); // The engine neutralizes the page's "../webfront-download.txt" itself (Chrome writes "_webfront-download.txt"). @@ -142,6 +157,14 @@ int main(int argc, char** argv) { stream.read(contents.data(), static_cast(contents.size())); contents.resize(static_cast(stream.gcount())); require(contents == expected, "The downloaded file has the wrong content"); + } else if (scenario.mode == "hold") { + // Reaching this point is the check: the window closed under the alert. The engine may release the page's alert + // while closing, so "released" is as valid as "holding". + require(scenario.title == "holding" || scenario.title == "released", ("The alert page did not start: " + scenario.title).c_str()); + } else if (scenario.mode == "dialogs") { + require(scenario.title == "answers:true|typed|null", ("Unexpected answers from the script dialogs: " + scenario.title).c_str()); + const std::vector expected{"0:hello:", "1:sure?:", "2:name?:default", "2:cancelled?:x"}; + require(scenario.dialogs == expected, "The injection did not see the expected dialogs"); } else { require(scenario.asked, ("The file chooser was not requested; title=" + scenario.title).c_str()); require(scenario.title == (scenario.mode == "choose" ? "picked:chosen by the test" : "cancelled"), diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 2aa56e02..7208bc8e 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -244,7 +244,7 @@ if(WEBFRONT_EMBED_CEF AND CMAKE_SYSTEM_NAME STREQUAL "Linux") webfront_setup_frontends_for_target(cef_file_services) add_dependencies(webtest cef_file_services) if(_policy_xvfb) - foreach(mode download choose cancel) + foreach(mode download choose cancel dialogs hold) add_test(NAME CEFFileServices-${mode} COMMAND "${_policy_xvfb}" -a $ ${mode}) webfront_set_browser_test_properties(CEFFileServices-${mode} "${CMAKE_CURRENT_SOURCE_DIR}" 60) endforeach() diff --git a/test/web/WKWebViewLifecycle.cpp b/test/web/WKWebViewLifecycle.cpp index 3ac1547c..bfb9ca8e 100644 --- a/test/web/WKWebViewLifecycle.cpp +++ b/test/web/WKWebViewLifecycle.cpp @@ -432,6 +432,83 @@ void closeWithSavePanel() { closeWithPanel("file-services.html?download", ""); } +/// alert, confirm and prompt reach the injection point and their answers reach the page (issue #452). +void scriptDialogs() { + Object pool(send(type("NSAutoreleasePool"), "new")); + std::vector seen; + static std::string finalTitle; + finalTitle.clear(); + ScenarioFrontend::configure = [&](webfront::frontend::WKWebViewOptions& options) { + options.answerScriptDialog = [&](const webfront::frontend::ScriptDialog& dialog) { + using Kind = webfront::frontend::ScriptDialog::Kind; + seen.push_back(std::to_string(static_cast(dialog.kind)) + ":" + dialog.message + ":" + dialog.defaultText); + if (dialog.kind == Kind::prompt) + return dialog.message == "name?" ? webfront::frontend::ScriptDialogAnswer{true, "typed"} : webfront::frontend::ScriptDialogAnswer{}; + return webfront::frontend::ScriptDialogAnswer{true, {}}; + }; + }; + ScenarioFrontend::started = [](Session& session) { + Session* live = &session; + auto tick = ^(id timer) { + const auto title = utf8(send(live->view, "title")); + if (title.starts_with("answers:")) { + finalTitle = title; + send(timer, "invalidate"); + quitApplication(); + } + }; + send(type("NSTimer"), "scheduledTimerWithTimeInterval:repeats:block:", 0.1, static_cast(true), tick); + }; + { + ScenarioApp app(webfront::WebFrontConfig{.documentRoot = std::filesystem::current_path()}); + app.show("script-dialogs.html"); + } + resetScenario(); + require(finalTitle == "answers:true|typed|null", ("Unexpected answers from the script dialogs: " + finalTitle).c_str()); + const std::vector expected{"0:hello:", "1:sure?:", "2:name?:default", "2:cancelled?:x"}; + require(seen == expected, "The injection did not see the expected dialogs"); +} + +/// A sandboxed iframe without allow-same-origin loads the application's own URL but has an opaque origin: its dialogs are +/// dismissed, never shown as the application's (issue #452). The parent's own confirm still reaches the injection. +void sandboxedScriptDialog() { + Object pool(send(type("NSAutoreleasePool"), "new")); + std::vector seen; + static std::string finalTitle; + finalTitle.clear(); + ScenarioFrontend::configure = [&](webfront::frontend::WKWebViewOptions& options) { + options.answerScriptDialog = [&](const webfront::frontend::ScriptDialog& dialog) { + seen.push_back(std::to_string(static_cast(dialog.kind)) + ":" + dialog.message + ":" + dialog.defaultText); + return webfront::frontend::ScriptDialogAnswer{true, {}}; + }; + }; + ScenarioFrontend::started = [](Session& session) { + Session* live = &session; + auto tick = ^(id timer) { + const auto title = utf8(send(live->view, "title")); + if (title.starts_with("sandboxed:")) { + finalTitle = title; + send(timer, "invalidate"); + quitApplication(); + } + }; + send(type("NSTimer"), "scheduledTimerWithTimeInterval:repeats:block:", 0.1, static_cast(true), tick); + }; + { + ScenarioApp app(webfront::WebFrontConfig{.documentRoot = std::filesystem::current_path()}); + app.show("script-dialogs.html?sandbox"); + } + resetScenario(); + require(finalTitle == "sandboxed:false|true", ("The sandboxed frame's confirm was not dismissed: " + finalTitle).c_str()); + const std::vector expected{"1:parent?:"}; + require(seen == expected, "The injection saw a dialog from the opaque-origin frame"); +} + +/// Closing the window while the NSAlert sheet is open: the sheet answers "dismissed" and the page is not left waiting. +void closeWithScriptDialog() { + closeWithPanel("script-dialogs.html?hold", ""); +} + /// The save panel's "Replace" choice: the page's bytes land beside the old file and replace it only on success. void replacedDownload() { Object pool(send(type("NSAutoreleasePool"), "new")); @@ -530,7 +607,10 @@ int main(int argc, char** argv) { { "choose-in-blank", chooseInBlankFrame}, { "choose-in-srcdoc", chooseInSrcdocFrame}, { "close-with-open-panel", closeWithOpenPanel}, - { "close-with-save-panel", closeWithSavePanel} + { "close-with-save-panel", closeWithSavePanel}, + { "script-dialogs", scriptDialogs}, + { "close-with-script-dialog", closeWithScriptDialog}, + { "sandboxed-script-dialog", sandboxedScriptDialog} }; cases.at(argc == 2 ? argv[1] : "")(); return 0; diff --git a/test/web/WebKitGTKLifecycle.cpp b/test/web/WebKitGTKLifecycle.cpp index d22fffa4..4245f468 100644 --- a/test/web/WebKitGTKLifecycle.cpp +++ b/test/web/WebKitGTKLifecycle.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -359,6 +360,53 @@ void closeWithDialog() { throw std::runtime_error("The file dialog was not opened"); } +/// alert, confirm and prompt reach the injection point and their answers reach the page (issue #452). +void scriptDialogs() { + std::vector seen; + ScenarioFrontend::configure = [&](gtk::Session& session) { + session.answerScriptDialog = [&](const webfront::frontend::ScriptDialog& dialog) { + using Kind = webfront::frontend::ScriptDialog::Kind; + seen.push_back(std::to_string(static_cast(dialog.kind)) + ":" + dialog.message + ":" + dialog.defaultText); + if (dialog.kind == Kind::prompt) + return dialog.message == "name?" ? webfront::frontend::ScriptDialogAnswer{true, "typed"} : webfront::frontend::ScriptDialogAnswer{}; + return webfront::frontend::ScriptDialogAnswer{true, {}}; + }; + }; + std::string title; + ScenarioFrontend::finished = [&](gtk::Session& session) { + const char* current = session.a.viewTitle(session.view); + title = current ? current : ""; + return title.starts_with("answers:"); + }; + ScenarioApp app(webfront::WebFrontConfig{.documentRoot = std::filesystem::current_path()}); + app.show("script-dialogs.html"); + if (title != "answers:true|typed|null") + throw std::runtime_error("Unexpected answers from the script dialogs: " + title); + const std::vector expected{"0:hello:", "1:sure?:", "2:name?:default", "2:cancelled?:x"}; + if (seen != expected) + throw std::runtime_error("The injection did not see the expected dialogs"); +} + +/// Closing the window while WebKitGTK's own script dialog is open must end cleanly, without waiting for an answer. +void closeWithScriptDialog() { + using Clock = std::chrono::steady_clock; + bool opened = false; + Clock::time_point openedAt; + ScenarioFrontend::configure = [&](gtk::Session& session) { + session.scriptDialogOpened = [&] { + opened = true; + openedAt = Clock::now(); + }; + }; + ScenarioFrontend::finished = [&](gtk::Session&) { + return opened && Clock::now() - openedAt > std::chrono::milliseconds(500); // Let the dialog map, then close under it. + }; + ScenarioApp app(webfront::WebFrontConfig{.documentRoot = std::filesystem::current_path()}); + app.show("script-dialogs.html?hold"); + if (!opened) + throw std::runtime_error("The script dialog was not opened"); +} + void windowTitle() { gtk::initialize(); const auto titleOf = [](webfront::WindowOptions window) { @@ -414,7 +462,9 @@ void run(std::string_view mode) { {"download-user-dir", downloadUserDirectory}, { "close-with-dialog", closeWithDialog}, { "choose-file", chooseOne}, - { "cancel-choose", chooseCancel} + { "cancel-choose", chooseCancel}, + { "script-dialogs", scriptDialogs}, + {"close-with-script-dialog", closeWithScriptDialog} }; const auto selected = cases.find(mode); if (selected == cases.end()) diff --git a/test/web/WebView2Lifecycle.cpp b/test/web/WebView2Lifecycle.cpp index 095d56a8..c84c2865 100644 --- a/test/web/WebView2Lifecycle.cpp +++ b/test/web/WebView2Lifecycle.cpp @@ -352,6 +352,58 @@ int fileServices(std::string_view mode) { return 0; } +// alert, confirm and prompt reach the injection point and their answers reach the page (issue #452). +int scriptDialogs() { + using namespace webfront::frontend::detail::webview2; + webfront::http::Server server("127.0.0.1", "9002", std::filesystem::current_path()); + std::jthread worker([&](std::stop_token stop) { + std::stop_callback cleanupServer(stop, [&] { + server.stop(); + }); + server.run(); + }); + Apartment apartment; + auto session = std::make_shared(); + session->url = L"http://127.0.0.1:9002/script-dialogs.html"; + session->contentPolicy = webfront::detail::BoundContentPolicy{"http://127.0.0.1:9002", {}}; + std::vector seen; + session->answerScriptDialog = [&](const webfront::frontend::ScriptDialog& dialog) { + using Kind = webfront::frontend::ScriptDialog::Kind; + seen.push_back(std::to_string(static_cast(dialog.kind)) + ":" + dialog.message + ":" + dialog.defaultText); + if (dialog.kind == Kind::prompt) + return dialog.message == "name?" ? webfront::frontend::ScriptDialogAnswer{true, "typed"} : webfront::frontend::ScriptDialogAnswer{}; + return webfront::frontend::ScriptDialogAnswer{true, {}}; + }; + session->createWindow(webfront::testdriver::diagnosticWindows()); + Actions actions; + actions.onFailure = [&] { + session->fail(); + }; + std::wstring title; + const auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds{30}; + actions.dispatch = [&](UINT) { + if (std::chrono::steady_clock::now() >= deadline) + throw std::runtime_error("Script dialog scenario timed out"); + if (!session->view) + return; + LPWSTR raw = nullptr; + check(session->view->get_DocumentTitle(&raw), "reading page result"); + const std::unique_ptr current(raw, CoTaskMemFree); + title = current.get(); + if (title.starts_with(L"answers:")) + PostMessageW(session->window, WM_CLOSE, 0, 0); + }; + require(SetTimer(actions.window, 1, 20, nullptr) != 0, "Cannot start script dialog watchdog"); + session->start(userDataFolder()); + session->run(); + if (actions.failure) + std::rethrow_exception(actions.failure); + require(title == L"answers:true|typed|null", "Unexpected answers from the script dialogs"); + const std::vector expected{"0:hello:", "1:sure?:", "2:name?:default", "2:cancelled?:x"}; + require(seen == expected, "The injection did not see the expected dialogs"); + return 0; +} + int rejectMta() { if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) return 1; @@ -514,6 +566,7 @@ int run(std::string_view mode) { [] { return fileServices("cancel"); } }, + { "script-dialogs", scriptDialogs}, { "file-download", [] { return fileServices("download"); diff --git a/test/web/script-dialogs.html b/test/web/script-dialogs.html new file mode 100644 index 00000000..7d52862f --- /dev/null +++ b/test/web/script-dialogs.html @@ -0,0 +1,39 @@ + + +Script dialogs +

waiting

+