Turn any website into a lightweight desktop app with one command, on macOS, Windows and Linux.
Rust chatgptclaudeclidesktopdesktop-appelectron-alternativegeminilinuxmacosnativefierno-electronrusttauriweb-to-desktopwebsite-to-appwebviewwindowsyoutube
fix: let trusted pages open the print dialog
Tw93187cabb1a2e6
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.jsonindex 6e3d9d67..685fcda9 100644--- a/src-tauri/capabilities/default.json+++ b/src-tauri/capabilities/default.json@@ -25,6 +25,7 @@"core:window:allow-minimize","core:window:allow-close","core:webview:allow-internal-toggle-devtools",+ "core:webview:allow-print","notification:allow-is-permission-granted","notification:allow-notify","notification:allow-get-active",diff --git a/src-tauri/src/app/config.rs b/src-tauri/src/app/config.rsindex 9dd42038..ed0b48e0 100644--- a/src-tauri/src/app/config.rs+++ b/src-tauri/src/app/config.rs@@ -340,6 +340,40 @@ mod tests {}}+ #[test]+ fn window_print_reaches_the_webview_only_from_trusted_contexts() {+ // On macOS Tauri replaces `window.print` with an invoke of+ // `plugin:webview|print`, so the page's own print button depends on it.+ let command = "plugin:webview|print";+ let mut local = config_for("index.html");+ local.windows[0].url_type = "local".into();+ let local = resolve(&local);+ let remote = resolve(&config_for("https://example.com/app"));+ for label in ["pake", "pake-1"] {+ assert!(allows(&local, command, label, None), "local {label}");+ assert!(allows(&remote, command, label, None), "bundled {label}");+ assert!(+ allows(&remote, command, label, Some("https://example.com/doc")),+ "configured origin {label}"+ );+ for url in [+ "https://evil.com/",+ "https://sub.example.com/",+ "http://example.com/",+ ] {+ assert!(!allows(&local, command, label, Some(url)), "{url}");+ assert!(!allows(&remote, command, label, Some(url)), "{url}");+ }+ }+ assert!(!allows(&remote, command, "unrelated", None));+ assert!(!allows(+ &remote,+ command,+ "unrelated",+ Some("https://example.com/")+ ));+ }+#[test]fn every_registered_app_command_is_gated_and_remains_available_on_the_entry_origin() {let acl = resolve(&config_for("https://example.com/"));diff --git a/tests/integration/ipc-security.mjs b/tests/integration/ipc-security.mjsindex 5059d9e2..2d8135b5 100644--- a/tests/integration/ipc-security.mjs+++ b/tests/integration/ipc-security.mjs@@ -39,6 +39,9 @@ function page(stage, origin) {results.zoom = await check("set_zoom", {percent: 100});results.closeNotification = await check("close_notification", {id: "pake-probe-not-delivered"});results.window = await check("plugin:window|is_fullscreen", {label: "pake"});+ results.printShim = String(window.print).includes("plugin:webview|print");+ // A missing label fails after the ACL check without opening a print panel.+ results.print = await check("plugin:webview|print", {label: "pake-probe-missing-webview"});${stage === "entry"? `results.traversal = await check("download_file", {params: {@@ -206,13 +209,28 @@ try {]) {assert.equal(trusted[command], "allowed", `configured origin: ${command}`);}- for (const command of ["download", "zoom", "window", "closeNotification"]) {+ for (const command of [+ "download",+ "zoom",+ "window",+ "closeNotification",+ "print",+ ]) {assert.match(untrusted[command],/^denied: .*not allowed/i,`untrusted origin: ${command}`,);}+ for (const report of [trusted, untrusted]) {+ assert.equal(report.printShim, true, "window.print is not the IPC shim");+ }+ assert.doesNotMatch(+ trusted.print,+ /not allowed/i,+ "configured origin: print",+ );+ assert.match(trusted.print, /^denied: .*webview not found/i);const downloadDeadline = Date.now() + 5000;while (Date.now() < downloadDeadline) {try {@@ -249,7 +267,7 @@ try {await assert.rejects(fs.stat(file), { code: "ENOENT" });}console.log(- "Native IPC PASS: download UA, Referer and HttpOnly cookies match the webview; entry commands work, cross-origin commands are denied, browser downloads survive denied IPC, fullscreen denial preserves layout, traversal remains inside Downloads.",+ "Native IPC PASS: download UA, Referer and HttpOnly cookies match the webview; entry commands and window.print work, cross-origin commands are denied, browser downloads survive denied IPC, fullscreen denial preserves layout, traversal remains inside Downloads.",);} finally {if (app && app.exitCode === null) {