diff --git a/crates/ui-egui/src/plugin_runs.rs b/crates/ui-egui/src/plugin_runs.rs index 1e09267049..3c3fe647d4 100644 --- a/crates/ui-egui/src/plugin_runs.rs +++ b/crates/ui-egui/src/plugin_runs.rs @@ -593,7 +593,13 @@ fn poll_checks(app: &mut VectorcraftApp) { let dialog = app.ui.dialog.is_some() || app.session.plugin_calls_open() || app.session.script_running(); let checked = loop { if dialog { - break c.worker.watch(t).map(Err); + if let Some(e) = c.worker.watch(t) { + break Some(Err(e)); + } + // A failed check ends at once; only a checked install waits. + if !matches!(c.worker.inbox.borrow().messages.front(), Some(FromWorker::Checked(Err(_)))) { + break None; + } } match c.worker.next(t) { Err(e) => break Some(Err(e)), diff --git a/crates/ui-egui/src/tests/plugin_runs.rs b/crates/ui-egui/src/tests/plugin_runs.rs index c8a67e8b26..1a17ce97b2 100644 --- a/crates/ui-egui/src/tests/plugin_runs.rs +++ b/crates/ui-egui/src/tests/plugin_runs.rs @@ -874,6 +874,27 @@ fn on_the_web_a_checked_install_waits_for_the_run_that_holds_the_documents() { registry::remove(id); } +/// A check that fails while a run holds the documents ends at once: its worker is terminated and +/// the status bar says why, while the run goes on holding them. +#[test] +fn on_the_web_a_failed_check_ends_while_a_run_holds_the_documents() { + let (mut app, fake) = web_app(); + let (bad_id, caller) = ("test.ui.web.failswhileheld", "test.ui.web.failswhileheld.caller"); + install_caller(&mut app, caller, TRIANGLE); + let traps = wat::parse_str(tpl::module(&tpl::manifest(bad_id, "filter", "{}"), tpl::ECHO, "(start $s) (func $s unreachable)", 1)).unwrap(); + app.run("ui.installPlugin", json!({"dataBase64": vectorcraft_format::base64_encode(&traps)})).unwrap(); + app.run("plugin.dialog", json!({"id": caller})).unwrap(); + fake.ready(0); + plugin_runs::poll(&mut app); + fake.serve(0); + plugin_runs::poll(&mut app); + assert!(fake.worker(0).terminated.get(), "the check's worker ends"); + assert!(app.ui.status.contains("trapped"), "{}", app.ui.status); + assert!(app.session.plugin_calls_open(), "the run still holds the documents"); + assert!(registry::get(bad_id).is_none()); + app.run("plugin.cancelRuns", json!({})).unwrap(); +} + /// The progress window shows the run that holds the documents at once, with Cancel only, also when /// a run that started before it is running. #[test] diff --git a/packaging/web/README.md b/packaging/web/README.md index a9e23c118f..a77c346890 100644 --- a/packaging/web/README.md +++ b/packaging/web/README.md @@ -33,11 +33,20 @@ files need revalidation. `vectorcraft-web-` `.wasm` and `.js` files, and `no-cache` on `index.html` and the `vectorcraft-plugin-worker` files. The page refuses a cached worker whose messages differ from its own, and plug-ins then fail to install and run until the browser fetches the new worker. -- **Content Security Policy:** a site that sends one needs `worker-src 'self'` for the plug-in - worker. Without `worker-src`, the browser uses `child-src`, then `script-src`, then - `default-src` ([CSP Level 3](https://www.w3.org/TR/CSP3/)), so a `script-src` that allows the - site's own scripts is enough only when the policy sets neither `worker-src` nor `child-src`. - When the policy blocks the worker, the app runs, and plug-ins fail to install and run. +- **Content Security Policy:** a site that sends one must allow three things + ([CSP Level 3](https://www.w3.org/TR/CSP3/)): + - The inline `