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: preserve Linux video rendering and fullscreen controls
Tw939d6d633a5aee
diff --git a/AGENTS.md b/AGENTS.mdindex 499b4b1f..1ef76267 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -100,7 +100,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and- Native build gates use a fresh output directory, require exit code zero and the CLI JSON's exact output path, and verify macOS executable architectures from `CFBundleExecutable`. Compare existing artifact paths with `realpath`, since macOS `/var` and `/private/var` can identify the same file; retain a negative test for genuinely different files. Old bundles, empty directories, or timeout artifacts never prove a successful build.- Platform test mocks must preserve unrelated exports with a partial mock. `defaults.ts` calls `getDefaultLinuxTargets` on Linux during import, so a mock containing only platform booleans can pass on macOS but prevent the suite from loading on Linux. See `tests/unit/linux-multi-target.test.ts`.- Shared Cargo caches are locked until artifact copying finishes; Cargo's own compilation lock alone does not protect that interval. Never reclaim a stale PID lock with read-then-delete, which can delete a new owner's lock. An abandoned lock fails with a recovery hint rather than risking concurrent artifacts. Cancellation and failed subprocesses must stop the compiler tree before releasing the lock; preserve the workspace and lock if termination cannot be confirmed. Ordinary success and failure discard the workspace, with cleanup warnings included before the JSON result. Verify with `node tests/integration/build-workspace.mjs` on macOS and the cross-platform workspace unit tests.-- Build workspaces preserve an existing root `rust-toolchain.toml` or legacy `rust-toolchain`; otherwise rustup may select a different default without the installed cross-compilation targets. Keep full stderr in real-build tests so compilation success cannot conceal a later target or bundling failure.+- Build workspaces preserve an existing root `rust-toolchain.toml` or legacy `rust-toolchain`; otherwise rustup may select a different default without the installed cross-compilation targets. Keep full stderr in real-build tests so compilation success cannot conceal a later target or bundling failure. GNU build flags must respect Cargo precedence: append required arguments to `CARGO_ENCODED_RUSTFLAGS` when present (including empty), otherwise to `RUSTFLAGS`; preserve user arguments and keep the override local to the build subprocess.- New user-visible CLI surface (a new flag, alias, subcommand, or extra help variant) needs a stated justification before implementation: name the user problem and why an existing flag, config key, or default cannot cover it, then get maintainer sign-off. Prefer quieter defaults over new options; never split help output into parallel variants.- Window/runtime options with platform-sensitive behavior include `--incognito`, `--new-window`, `--min-width`, `--min-height`, `--maximize`, multi-window behavior, notification click handling, and Linux/Wayland WebKit compositing defaults.- `--incognito` intentionally trades persistence for clean private sessions; be careful around login, cookies, local storage, and WeChat-style WebView detection.@@ -115,7 +115,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and- Find's DOM-mark fallback must not observe its own highlighter mutations. Pause observation while rescanning/updating marks, then resume only while Find is open; real page edits must still refresh results. A mock without MutationObserver cannot prove this path. Icon download deadlines likewise cover response bodies, not just response headers.- Safe clipboard shortcuts (Ctrl+C/X/V/A) on Linux/Windows are bridged in `src-tauri/src/inject/event.js`. Copy/cut/select-all stay in the trusted `handleClipboardShortcut` keydown path; Ctrl+V must leave keydown unhandled so the native WebView paste event preserves images, files, and rich formats, with text-only `navigator.clipboard.readText()` fallback allowed only from a trusted keyup when no native paste event fired. The bridge is gated on `isNonMacDesktop()` and `event.isTrusted`, only acts on editable/selected targets, and must never fire on macOS (native shortcuts already work). Locked by `event-clipboard-shortcuts.test.js` tests `lets native paste preserve non-text clipboard data` and `falls back to clipboard text only when native paste does not fire`.- Notification flows cross injected JS, Tauri invokes, capabilities, and native notification plugins. Verify the Rust capability and JS caller together.-- WebKit compositing behavior is platform-sensitive on Linux/Wayland. Runtime flag decisions live in `src-tauri/src/lib.rs`; keep the default conservative, cover compositor exceptions with unit tests, and document user-facing fallbacks in `docs/faq*.md`.+- WebKit compositing behavior is platform-sensitive on Linux/Wayland. Runtime flag decisions live in `src-tauri/src/lib.rs`; keep the default conservative, cover compositor exceptions with unit tests, and document user-facing fallbacks in `docs/faq*.md`. WebKitGTK 2.52+ X11 uses SHM instead of disabling the renderer; use the loaded library version, preserve explicit variables, and keep older WebKit/Wayland on their existing path. Keep the niri exception in both legacy gates and test the combined mode, including safe-mode overrides.- Linux AppImage reports often include harmless GTK, appindicator, or GStreamer warnings. Separate optional runtime warnings from the actual symptom before changing code; input/click failures on pure Wayland compositors are not the same class as blank-window failures.- Stable `V*` Docker publication updates both the version tag and `latest`; verify matching registry manifest digests and the image's source revision. Quality validates the actual image CLI and both DEB/AppImage artifacts before a release tag is pushed. AppImage bundling requires `xdg-open` from `xdg-utils` in the image: a successful image build or DEB alone does not cover that dependency. Require both requested artifacts because the CLI intentionally allows partial success across formats.- Release state can be split. npm Trusted Publishing can succeed before the popular-app release workflow finishes, and GitHub Release assets can exist while a workflow run still shows queued or in progress. Report each surface explicitly.@@ -123,7 +123,7 @@ Proactive latent-bug sweeps use `.agents/skills/bugs/SKILL.md`. Pick one row and- Per-app optional fields in `default_app_list.json` currently take their defaults in Actions expressions in `release.yml` (`matrix.config.x || false` and the numeric ones), which works because every field so far is default-false or numeric. The first default-true field cannot use that path and must move its default into the jq read step: GitHub expressions cast both `null` and `false` to `0`, so `matrix.config.x != false` cannot express "default true" and would silently flip every app missing the field.- Windows taskbar icons can register blank when an autostarted app launches before Explorer's icon cache is ready (#1323). Every hidden-to-visible `window.show()` path (main or secondary: tray show/click, activation shortcut, single-instance activation, startup/page-load reveal, multi-window Cmd+N reveal) must call `reapply_window_icon` from `src-tauri/src/app/window.rs` (or go through `reveal_built_window` / `reveal_startup_window`, which already do). The helper reasserts both the small window icon and the large taskbar icon; a new show path without it regresses the bug.- Multi-window home clones (`open_additional_window_safe`, labels `pake-N`) are built hidden and revealed via `reveal_built_window` on the first real page load (or a 3s fallback), matching the main-window blank-shell guard. OAuth/pop-up windows from `--new-window` stay immediately visible by design. Tray Hide/Show, tray left-click, and the activation shortcut must act on **every** webview via `hide_all_app_windows` / `show_all_app_windows` / `toggle_all_app_windows` (not only label `"pake"`). Two Windows-specific constraints hold that toggle together (#1343): the tray click handler must match `button_state == MouseButtonState::Up`, because Windows emits `TrayIconEvent::Click` twice per physical click and reacting to both runs the toggle twice; and `any_app_window_visible` must exclude minimized windows, because `hide_on_close` minimizes before hiding and Windows keeps `IsWindowVisible` true while a window is iconic. Locked by `tests/unit/tray-toggle-visibility.test.ts`.-- Windows uses WebView2 native DOM fullscreen; Tauri already synchronizes its `ContainsFullScreenElementChanged` event with the native window. Do not inject `fullscreen.js` on Windows: its media extraction separates video from player controls (#1373). F11 must exit an active DOM fullscreen session through `document.exitFullscreen()` before toggling the native window. Verify the platform gate and `node --test tests/browser/fullscreen.mjs`; macOS/Linux retain the existing polyfill.+- Windows uses WebView2 native DOM fullscreen; Tauri already synchronizes its `ContainsFullScreenElementChanged` event with the native window. Do not inject `fullscreen.js` on Windows: its media extraction separates video from player controls (#1373). F11 must exit an active DOM fullscreen session through `document.exitFullscreen()` before toggling the native window. Verify the platform gate and `node --test tests/browser/fullscreen.mjs`; macOS/Linux retain the polyfill, which must preserve the requested subtree even for `html`/`body` fullscreen. Never extract a video from its player controls; verify document/player entry and repeated exit with `node --test tests/browser/fullscreen.mjs`.- Injected Linux/Windows shortcuts (Ctrl+R / [ / ]) call the `webview_navigate` IPC so reload and history use the platform webview API on blank error pages; do not route those shortcuts only through page `history` / `location`.- Download and toast paths must not hardcode `get_webview_window("pake")` when the action originates from a secondary window: IPC commands take the calling `WebviewWindow`, and `on_download` resolves toast by the event webview's label. Authenticated downloads should attach webview session cookies when available. Link-download heuristics prefer real file extensions, the `download` attribute, and `?download` / `?attachment` query hints; Cmd/Ctrl+click is navigation, not "save as"; do not re-add broad SPA roots such as `/assets/`, `/dist/`, `/files/`, or `/releases/` (see #1337, #1339).- macOS menu navigation must keep working on blank error pages: Reload uses native `WebviewWindow::reload`, Go Home uses `navigate` + `resolve_home_url`, Back/Forward use the platform WKWebView history API rather than page `eval`. Copy URL reads `window.url()` so it does not depend on a live JS document.@@ -195,7 +195,7 @@ Before treating an npm release as shipped, verify both `gh workflow list --all |For release follow-through, keep these boundaries explicit:- `workflow_dispatch` runs on a branch. Bind npm-only publishing to the exact `main` commit with `expected_sha` and a successful Quality run for that same SHA; do not infer a release tag or source commit from the branch name, run title, or compare UI.-- For CLI/npm issue closeout, the npm registry is the decisive public surface. Install the exact public version in a temporary directory, compare its shipped files with the release tag, build an app, and verify the installed template remains unchanged. Check `rustup show` in that temporary context before a universal macOS probe: the repository's toolchain override may have both targets while the default toolchain has only the host target. GitHub app release assets and quality workflows remain separate surfaces.+- For CLI/npm issue closeout, the npm registry is the decisive public surface. Install the exact public version in a temporary directory, compare its shipped files with the intended source commit (or release tag when present), build an app, and verify the installed template remains unchanged. Check `rustup show` in that temporary context before a universal macOS probe: the repository's toolchain override may have both targets while the default toolchain has only the host target. GitHub app release assets and quality workflows remain separate surfaces.- For app-release claims, inspect the GitHub Release directly with `gh release view <tag> --json assets`. Derive the expected filenames from the tagged `default_app_list.json` and workflow formats, then require the complete name set, uploaded state, and nonzero sizes; do not hardcode a historical asset count. Download representative platform installers, inspect actual payloads, and validate a macOS DMG's stapled notarization ticket. Asset presence and workflow completion must both be reported accurately.- The contributors bot can push `chore: update contributors [skip ci]` at any moment, including between local commits and the bump push. On a rejected push, `git pull --rebase` onto it and push again before tagging. After release, fast-forward local `main`; do not move an already pushed release tag to include it. Never tag that bot commit itself: GitHub evaluates `[skip ci]` against the head commit for tag pushes too, so a `V*` tag landing on it silently produces no workflow run, no release, and no assets, with no error anywhere. Before pushing a release tag, confirm the target commit's subject has no `[skip ci]` and that the commit has its own green Quality run; point the tag at the last real commit when the bot is on top.diff --git a/docs/faq.md b/docs/faq.mdindex f16432e6..13061ada 100644--- a/docs/faq.md+++ b/docs/faq.md@@ -308,7 +308,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage```**Why This Happens:**-Pake sets two WebKitGTK variables on Linux. `WEBKIT_DISABLE_DMABUF_RENDERER` is on everywhere except niri, because the blank window it prevents also happens on X11 with the NVIDIA proprietary driver. `WEBKIT_DISABLE_COMPOSITING_MODE` is on for Wayland only, where it fixes a blank screen without a GPU. On WebKitGTK 2.52 both variables reach the same switch, so either one on its own turns hardware acceleration off, which is why `PAKE_LINUX_WEBKIT_SAFE_MODE` is the setting that matters: `1` forces both on, `0` turns both off.+On X11 with WebKitGTK 2.52 or later, Pake uses shared-memory rendering (`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`) instead of disabling the renderer, preserving the backing store needed for video. Older WebKitGTK versions and Wayland keep the existing compatibility flags; niri keeps native rendering. Explicit WebKit variables are respected. `PAKE_LINUX_WEBKIT_SAFE_MODE=1` selects the old conservative mode, while `0` removes the two disabling flags and skips automatic workarounds.---diff --git a/docs/faq_CN.md b/docs/faq_CN.mdindex ac9bd6f7..f14b5751 100644--- a/docs/faq_CN.md+++ b/docs/faq_CN.md@@ -305,7 +305,7 @@ PAKE_LINUX_WEBKIT_SAFE_MODE=1 ./MyApp.AppImage```**原因:**-Pake 在 Linux 上会设两个 WebKitGTK 变量。`WEBKIT_DISABLE_DMABUF_RENDERER` 除 niri 外都开,因为它挡住的白屏在 X11 配 NVIDIA 闭源驱动时同样会出现。`WEBKIT_DISABLE_COMPOSITING_MODE` 只在 Wayland 下开,它解决的是无 GPU 时的白屏。在 WebKitGTK 2.52 上这两个变量落到同一个开关,任意一个单独打开都会关掉硬件加速,所以真正起作用的是 `PAKE_LINUX_WEBKIT_SAFE_MODE`:`1` 全开,`0` 全关。+在 X11 和 WebKitGTK 2.52 及以上版本上,Pake 默认使用共享内存渲染(`WEBKIT_DMABUF_RENDERER_FORCE_SHM=1`),保留视频需要的渲染缓冲;旧版 WebKitGTK 和 Wayland 沿用现有兼容参数,niri 保持原生渲染,手动设置的 WebKit 参数也会保留。`PAKE_LINUX_WEBKIT_SAFE_MODE=1` 切回原来的保守模式,`0` 则移除两个禁用参数,不再自动添加兼容参数。---diff --git a/src-tauri/src/inject/fullscreen.js b/src-tauri/src/inject/fullscreen.jsindex 3e3ae996..807eae5c 100644--- a/src-tauri/src/inject/fullscreen.js+++ b/src-tauri/src/inject/fullscreen.js@@ -43,7 +43,7 @@background: #000 !important;object-fit: contain !important;}- .pake-fullscreen-element video {+ .pake-fullscreen-element:not(html):not(body) video {width: 100% !important;height: 100% !important;object-fit: contain !important;@@ -79,39 +79,12 @@monitorId = null;}- function findMediaElement() {- const videos = document.querySelectorAll("video");- if (videos.length > 0) {- let largestVideo = videos[0];- let maxArea = 0;- videos.forEach((video) => {- const rect = video.getBoundingClientRect();- const area = rect.width * rect.height;- if (area > maxArea || !video.paused) {- maxArea = area;- largestVideo = video;- }- });- return largestVideo;- }- return null;- }-function enterFullscreen(element) {fullscreenElement = element;-- let targetElement = element;- if (element === document.documentElement || element === document.body) {- const mediaElement = findMediaElement();- if (mediaElement) {- targetElement = mediaElement;- actualFullscreenElement = mediaElement;- } else {- actualFullscreenElement = element;- }- } else {- actualFullscreenElement = element;- }+ // Preserve the requested subtree. Extracting a video from a document+ // fullscreen request separates it from its controls and overlays.+ const targetElement = element;+ actualFullscreenElement = element;originalStyles = {position: targetElement.style.position,@@ -128,7 +101,10 @@objectFit: targetElement.style.objectFit,};- wasInBody = targetElement.parentNode === document.body;+ wasInBody =+ targetElement === document.documentElement ||+ targetElement === document.body ||+ targetElement.parentNode === document.body;if (!wasInBody) {originalParent = targetElement.parentNode;originalNextSibling = targetElement.nextSibling;diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 77394efe..0148e714 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -23,6 +23,8 @@ const WEBKIT_DISABLE_DMABUF_RENDERER: &str = "WEBKIT_DISABLE_DMABUF_RENDERER";#[cfg(target_os = "linux")]const WEBKIT_DISABLE_COMPOSITING_MODE: &str = "WEBKIT_DISABLE_COMPOSITING_MODE";#[cfg(target_os = "linux")]+const WEBKIT_DMABUF_RENDERER_FORCE_SHM: &str = "WEBKIT_DMABUF_RENDERER_FORCE_SHM";+#[cfg(target_os = "linux")]const GDK_BACKEND: &str = "GDK_BACKEND";use app::{@@ -122,8 +124,8 @@ fn is_niri_session(niri_socket: Option<&str>, desktop_values: &[Option<&str>]) -/// `WEBKIT_DISABLE_DMABUF_RENDERER` came from #1117 (96e57376) for Linux/// stability in general, three months before anything Wayland-specific, and/// upstream still reports the blank window it prevents on X11 with the NVIDIA-/// proprietary driver (tauri-apps/tauri#9394), so it stays on everywhere except-/// niri.+/// proprietary driver (tauri-apps/tauri#9394). This is the legacy policy;+/// apply_linux_webkit_runtime_flags substitutes SHM on WebKitGTK 2.52+ X11.////// niri is excepted because #1226 was fixed by dropping both variables, and on/// WebKitGTK 2.52 either one alone is enough to undo that: disabling the dmabuf@@ -166,10 +168,9 @@ fn should_disable_compositing_mode(}// WAYLAND_DISPLAY says a compositor is reachable, not that GTK will use it.- // An explicit GDK_BACKEND=x11 renders through XWayland, which is the X11- // path this flag crashes, and it is also the workaround recommended in- // #1117, so the two would otherwise collide. should_force_wayland_gdk_backend- // already treats an explicit backend as authoritative; so does this.+ // An explicit GDK_BACKEND=x11 selects the X11 path, so the Wayland-only+ // workaround does not apply. should_force_wayland_gdk_backend also+ // treats an explicit backend as authoritative.if gdk_backend.is_some_and(|value| value.trim().eq_ignore_ascii_case("x11")) {return false;}@@ -181,6 +182,21 @@ fn should_disable_compositing_mode(!is_niri_session(niri_socket, desktop_values)}+// Limit the replacement to the reported WebKitGTK generation and X11 path.+// Older WebKit and Wayland keep their existing workarounds; niri stays native.+#[cfg(any(target_os = "linux", test))]+fn should_use_shm_renderer(+ webkit_version: (u32, u32),+ safe_mode: Option<&str>,+ disable_dmabuf: bool,+ disable_compositing: bool,+) -> bool {+ webkit_version >= (2, 52)+ && !is_non_empty_env_value(safe_mode)+ && disable_dmabuf+ && !disable_compositing+}+#[cfg(any(target_os = "linux", test))]fn should_force_wayland_gdk_backend(gdk_backend: Option<&str>,@@ -230,20 +246,43 @@ fn apply_linux_webkit_runtime_flags() {let niri_socket = std::env::var("NIRI_SOCKET").ok();- if should_disable_dmabuf_renderer(safe_mode.as_deref(), niri_socket.as_deref(), &desktop_refs)- && std::env::var(WEBKIT_DISABLE_DMABUF_RENDERER).is_err()- {- std::env::set_var(WEBKIT_DISABLE_DMABUF_RENDERER, "1");- }-- if should_disable_compositing_mode(+ let disable_dmabuf =+ should_disable_dmabuf_renderer(safe_mode.as_deref(), niri_socket.as_deref(), &desktop_refs);+ let disable_compositing = should_disable_compositing_mode(safe_mode.as_deref(),niri_socket.as_deref(),std::env::var("WAYLAND_DISPLAY").ok().as_deref(),std::env::var(GDK_BACKEND).ok().as_deref(),&desktop_refs,- ) && std::env::var(WEBKIT_DISABLE_COMPOSITING_MODE).is_err()+ );+ // SAFETY: WebKit's version getters take no pointers and require no GTK+ // initialization. They report the loaded library, not the build host.+ let webkit_version = unsafe {+ (+ webkit2gtk::ffi::webkit_get_major_version(),+ webkit2gtk::ffi::webkit_get_minor_version(),+ )+ };+ if should_use_shm_renderer(+ webkit_version,+ safe_mode.as_deref(),+ disable_dmabuf,+ disable_compositing,+ ) && std::env::var_os(WEBKIT_DISABLE_DMABUF_RENDERER).is_none()+ && std::env::var_os(WEBKIT_DISABLE_COMPOSITING_MODE).is_none(){+ // Unlike disabling the renderer, SHM keeps the backing store available+ // for video while avoiding hardware-buffer imports (#1374).+ if std::env::var_os(WEBKIT_DMABUF_RENDERER_FORCE_SHM).is_none() {+ std::env::set_var(WEBKIT_DMABUF_RENDERER_FORCE_SHM, "1");+ }+ return;+ }++ if disable_dmabuf && std::env::var_os(WEBKIT_DISABLE_DMABUF_RENDERER).is_none() {+ std::env::set_var(WEBKIT_DISABLE_DMABUF_RENDERER, "1");+ }+ if disable_compositing && std::env::var_os(WEBKIT_DISABLE_COMPOSITING_MODE).is_none() {std::env::set_var(WEBKIT_DISABLE_COMPOSITING_MODE, "1");}}@@ -580,7 +619,7 @@ mod tests {}#[test]- fn x11_keeps_dmabuf_disabled_and_skips_compositing() {+ fn legacy_x11_keeps_dmabuf_disabled_and_skips_compositing() {// The shape of #1374: an X11 session still gets the stability flag it// has had since #1117, and does not get the compositing one. Both clear// the same hardware-acceleration boolean, so leaving compositing unset@@ -594,8 +633,8 @@ mod tests {#[test]fn explicit_x11_gdk_backend_keeps_compositing_on_wayland() {- // XWayland renders through the X11 path this flag crashes, and- // GDK_BACKEND=x11 is the workaround recommended in #1117.+ // An explicit X11 backend skips the Wayland-only workaround even+ // when a Wayland compositor is available.assert!(!should_disable_compositing_mode(None,None,@@ -613,6 +652,43 @@ mod tests {));}+ #[test]+ fn modern_x11_uses_shm_without_disabling_the_backing_store() {+ let desktop = [Some("i3"), None, None];+ for (wayland, backend) in [(None, None), (Some("wayland-0"), Some("x11"))] {+ assert!(should_use_shm_renderer(+ (2, 52),+ None,+ should_disable_dmabuf_renderer(None, None, &desktop),+ should_disable_compositing_mode(None, None, wayland, backend, &desktop),+ ));+ }+ assert!(should_use_shm_renderer((2, 52), Some(" "), true, false));+ }++ #[test]+ fn shm_preserves_legacy_wayland_niri_and_explicit_modes() {+ assert!(!should_use_shm_renderer((2, 50), None, true, false));+ assert!(!should_use_shm_renderer((2, 38), None, true, false));+ let desktop = [None, None, None];+ assert!(!should_use_shm_renderer(+ (2, 52),+ None,+ should_disable_dmabuf_renderer(None, None, &desktop),+ should_disable_compositing_mode(None, None, Some("wayland-0"), None, &desktop),+ ));+ let niri = [Some("niri"), None, None];+ assert!(!should_use_shm_renderer(+ (2, 52),+ None,+ should_disable_dmabuf_renderer(None, None, &niri),+ should_disable_compositing_mode(None, None, Some("wayland-0"), None, &niri),+ ));+ for mode in ["0", "false", "1", "true"] {+ assert!(!should_use_shm_renderer((2, 52), Some(mode), true, false));+ }+ }+#[test]fn compositing_mode_stays_disabled_by_default_on_wayland() {assert!(should_disable_compositing_mode(diff --git a/tests/browser/fullscreen.mjs b/tests/browser/fullscreen.mjsindex 0343f96c..878e23fb 100644--- a/tests/browser/fullscreen.mjs+++ b/tests/browser/fullscreen.mjs@@ -91,3 +91,90 @@ test("native fullscreen preserves the player subtree and F11 exits its top layerawait browser.close();}});++// The Linux/macOS polyfill must keep video and controls in the same subtree,+// including sites that request fullscreen on the document instead of the player.+for (const target of ["html", "body", "#player"]) {+ test(`polyfill preserves player controls when ${target} requests fullscreen`, async () => {+ const browser = await chromium.launch({+ headless: true,+ ...(process.env.PAKE_BROWSER_EXECUTABLE+ ? { executablePath: process.env.PAKE_BROWSER_EXECUTABLE }+ : {}),+ });+ try {+ const page = await browser.newPage({+ viewport: { width: 900, height: 600 },+ });+ await page.setContent(`+ <style>body{margin:0}#player{position:relative;width:100vw;height:100vh;background:#222}+ video{width:100%;height:100%}#preview{width:80px;height:45px;position:fixed;top:0;right:0}#controls{position:absolute;bottom:20px;left:20px;z-index:10}</style>+ <section id="player"><video></video><button id="controls">Pause</button></section><video id="preview"></video>`);+ await page.evaluate(() => {+ let fullscreen = false;+ window.__TAURI__ = {+ window: {+ getCurrentWindow: () => ({+ setFullscreen: async (value) => {+ fullscreen = value;+ },+ isFullscreen: async () => fullscreen,+ }),+ },+ };+ });+ await page.addScriptTag({+ content: await fs.readFile(+ `${process.env.PAKE_INJECT_ROOT || "src-tauri/src/inject"}/fullscreen.js`,+ "utf8",+ ),+ });+ for (let attempt = 0; attempt < 2; attempt++) {+ await page.evaluate(+ (selector) => document.querySelector(selector).requestFullscreen(),+ target,+ );+ assert.equal(+ await page.evaluate((selector) => {+ const player = document.querySelector("#player");+ const controls = document.querySelector("#controls");+ const rect = controls.getBoundingClientRect();+ return (+ document.fullscreenElement === document.querySelector(selector) &&+ player.contains(document.querySelector("video")) &&+ document.elementFromPoint(+ rect.x + rect.width / 2,+ rect.y + rect.height / 2,+ ) === controls+ );+ }, target),+ true,+ );+ if (target !== "#player") {+ assert.deepEqual(+ await page.locator("#preview").evaluate((element) => {+ const rect = element.getBoundingClientRect();+ return [rect.width, rect.height];+ }),+ [80, 45],+ );+ }+ await page.evaluate(() => document.exitFullscreen());+ assert.equal(+ await page.evaluate(() => document.fullscreenElement),+ null,+ );+ assert.equal(await page.locator("#player > video").count(), 1);+ assert.equal(await page.locator(".pake-fullscreen-element").count(), 0);+ assert.equal(+ await page.evaluate(+ () => document.body.parentElement === document.documentElement,+ ),+ true,+ );+ }+ } finally {+ await browser.close();+ }+ });+}