diff --git a/.github/workflows/desktop-installers.yml b/.github/workflows/desktop-installers.yml index 84c4698db..d97223e98 100644 --- a/.github/workflows/desktop-installers.yml +++ b/.github/workflows/desktop-installers.yml @@ -62,6 +62,8 @@ jobs: codesign --force --deep --sign - "$app" codesign --verify --deep --strict "$app" - name: Build and smoke-test DMG + env: + OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD: '1' run: | mount="$RUNNER_TEMP/desktop-mount" installer="$PWD/apps/desktop/installer/macos" @@ -137,6 +139,8 @@ jobs: npm run pack:windows --prefix apps/desktop if ($LASTEXITCODE -ne 0) { throw 'Windows packaging failed' } - name: Smoke-test installed application + env: + OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD: '1' run: | $name = "OpenDirector-v$env:DESKTOP_VERSION-win-x64-unsigned.exe" $installer = Get-Item "apps/desktop/build/$name" diff --git a/apps/desktop/scripts/smoke-window.mjs b/apps/desktop/scripts/smoke-window.mjs index 226f24627..53d6be906 100644 --- a/apps/desktop/scripts/smoke-window.mjs +++ b/apps/desktop/scripts/smoke-window.mjs @@ -1,5 +1,5 @@ import { guardLargeVideoDataUrl, largeVideoState, verifyLargeVideoBytes } from './large-video.mjs'; -import { app, BrowserWindow } from 'electron'; +import { app, BrowserWindow, clipboard } from 'electron'; import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { createHash } from 'node:crypto'; import { join } from 'node:path'; @@ -94,6 +94,11 @@ export async function smokeWindow({ window, host, getLocale }) { window.focus(); window.webContents.focus(); await waitFor(() => window.isFocused(), 'Desktop window could not take focus before search'); + if (process.env.OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD === '1') { + await waitFor(() => window.webContents.executeJavaScript('document.hasFocus()'), 'Renderer did not take document focus before the clipboard check'); + await assertClipboardReadDenied(window); + await assertClipboardWrite(window, 'opendirector-smoke-click', true); + } await window.webContents.executeJavaScript("document.querySelector('.od-sidebar-search-toggle').click()"); await waitFor(() => window.webContents.executeJavaScript("document.activeElement === document.querySelector('.od-sidebar-search')"), 'Project search did not take focus'); const firstProject = await window.webContents.executeJavaScript("document.querySelector('.od-project-sidebar nav button span').textContent"); @@ -266,13 +271,64 @@ export async function smokeWindow({ window, host, getLocale }) { await window.webContents.executeJavaScript("document.querySelector('.od-caption-actions button').click()"); } await waitFor(() => window.webContents.executeJavaScript(`localStorage.getItem('opendirector.desktop.sidebar.v1') === '${result.sidebarFinallyOpen ? 'open' : 'closed'}'`), 'Sidebar preference was not saved'); + await assertFullscreen(window); await window.webContents.executeJavaScript('window.opendirectorDesktop.setExporting(true)'); await delay(50); window.close(); - if (window.isVisible() || !(await host.inspect())) throw new Error('Closing a window stopped the Host'); + await assertWindowClosedAndHostRunning(window, host); return result; } +async function assertWindowClosedAndHostRunning(window, host) { + const visible = () => !window.isDestroyed() && window.isVisible(); + const deadline = performance.now() + 15_000; + while (performance.now() < deadline) { + if (!visible() && (await host.inspect())) return; + await delay(100); + } + throw new Error(`Closing a window stopped the Host (window visible: ${visible()})`); +} + +async function assertClipboardReadDenied(window) { + const read = await window.webContents.executeJavaScript( + `navigator.clipboard.readText().then(() => 'granted', error => error.name)`, false); + if (read !== 'NotAllowedError') throw new Error('A clipboard read was not denied'); +} + +async function assertClipboardWrite(window, text, userGesture) { + const previous = await clipboard.readText(); + try { + await window.webContents.executeJavaScript( + `navigator.clipboard.writeText(${JSON.stringify(text)}).then(() => true, error => { throw new Error('Clipboard write was rejected: ' + error.name); })`, userGesture); + let actual = await clipboard.readText(); + for (let attempt = 0; attempt < 20 && actual !== text; attempt++) { + await delay(100); + actual = await clipboard.readText(); + } + if (actual !== text) throw new Error('Clipboard write did not reach the system clipboard'); + } finally { + await clipboard.writeText(previous); + } +} + +async function assertFullscreen(window) { + const state = await window.webContents.executeJavaScript(`(async () => { + const element = document.querySelector('.cw-workspace') ?? document.body; + const outcome = await Promise.race([ + element.requestFullscreen().then(() => 'entered', error => error.name), + new Promise(resolve => setTimeout(() => resolve('pending'), 10000)), + ]); + if (outcome !== 'entered') return { outcome }; + const entered = document.fullscreenElement === element; + document.exitFullscreen().catch(() => {}); + return { outcome, entered }; + })()`, true); + if (state.outcome !== 'entered') throw new Error(`Fullscreen request did not enter fullscreen: ${state.outcome}`); + if (!state.entered) throw new Error('Fullscreen request did not make the element fullscreen'); + await waitFor(() => window.webContents.executeJavaScript('!document.fullscreenElement'), 'Fullscreen did not exit'); + await waitFor(() => !window.isFullScreen(), 'Fullscreen did not exit the window'); +} + async function smokeLargeVideo(window, host, projectId, fixture, firstLaunch) { const { webContents } = window; const name = 'large-video.mp4'; diff --git a/apps/desktop/src/main.mjs b/apps/desktop/src/main.mjs index db8d0b23c..a73a8a296 100644 --- a/apps/desktop/src/main.mjs +++ b/apps/desktop/src/main.mjs @@ -8,6 +8,7 @@ import { Host, ownedURL, proxyRequest } from './host.mjs'; import { resolveHostEnv } from './environment.mjs'; import { messages, localeFor } from './locale.mjs'; import { registerCommand, commandPath } from './command.mjs'; +import { permissionGranted } from './permissions.mjs'; app.setName('OpenDirector'); const desktopChrome = ['darwin', 'win32'].includes(process.platform); @@ -134,7 +135,10 @@ async function start() { }); await host.ready; const ownedSession = session.fromPartition('persist:opendirector'); - ownedSession.setPermissionRequestHandler((_contents, _permission, callback) => callback(false)); + ownedSession.setPermissionRequestHandler((_contents, permission, callback, details) => + callback(permissionGranted(permission, details.requestingUrl))); + ownedSession.setPermissionCheckHandler((_contents, permission, requestingOrigin) => + permissionGranted(permission, requestingOrigin)); let projectSubscription; ownedSession.protocol.handle('opendirector', request => proxyRequest(request, host, async (url, options) => { const pathname = new URL(url).pathname; diff --git a/apps/desktop/src/permissions.mjs b/apps/desktop/src/permissions.mjs new file mode 100644 index 000000000..31ed2e2ea --- /dev/null +++ b/apps/desktop/src/permissions.mjs @@ -0,0 +1,12 @@ +import { ownedURL } from './host.mjs'; + +const granted = new Set(['clipboard-sanitized-write', 'fullscreen', 'automatic-fullscreen']); + +export function permissionGranted(permission, requestingUrl) { + if (!granted.has(permission)) return false; + try { + return ownedURL(requestingUrl); + } catch { + return false; + } +} diff --git a/apps/desktop/tests/permissions.test.mjs b/apps/desktop/tests/permissions.test.mjs new file mode 100644 index 000000000..b79e029af --- /dev/null +++ b/apps/desktop/tests/permissions.test.mjs @@ -0,0 +1,37 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { permissionGranted } from '../src/permissions.mjs'; + +const app = 'opendirector://app/'; +const allowed = ['clipboard-sanitized-write', 'fullscreen', 'automatic-fullscreen']; + +test('The application page receives the permissions its controls use', () => { + for (const permission of allowed) { + assert.equal(permissionGranted(permission, app), true, permission); + assert.equal(permissionGranted(permission, 'opendirector://app/canvas?x=1'), true, permission); + assert.equal(permissionGranted(permission, 'opendirector://app'), true, permission); + } +}); + +test('Clipboard reads stay denied while sanitized writes are granted', () => { + assert.equal(permissionGranted('clipboard-read', app), false); + assert.equal(permissionGranted('clipboard-read', 'opendirector://app/canvas'), false); + assert.equal(permissionGranted('clipboard-sanitized-write', app), true); +}); + +test('Other renderer permissions stay denied', () => { + for (const permission of ['media', 'display-capture', 'geolocation', 'notifications', + 'midi', 'pointerLock', 'openExternal', 'fileSystem', 'serial', 'usb', 'unknown', '']) { + assert.equal(permissionGranted(permission, app), false, permission); + } +}); + +test('The granted permissions do not extend to other origins', () => { + for (const origin of ['https://example.com/', 'file:///C:/tmp/a.html', 'opendirector://other/', + 'opendirector://app:8080/', 'opendirector://app@evil.com/', 'opendirector://x.app/', + '', undefined, null, 'null', 'not a url']) { + for (const permission of allowed) { + assert.equal(permissionGranted(permission, origin), false, `${permission} on ${String(origin)}`); + } + } +}); diff --git a/docs/architecture/desktop.md b/docs/architecture/desktop.md index 158c81d66..1a651bf1d 100644 --- a/docs/architecture/desktop.md +++ b/docs/architecture/desktop.md @@ -18,6 +18,8 @@ The main process starts the bundled Python runtime and gives the Host a fresh cr The renderer requests application pages, media, and API resources through `opendirector://app`. The main process forwards those requests to the Host with the launch credential. The Host checks the credential before it serves the request. The renderer runs with Node integration off and context isolation on. A preload bridge exposes specific desktop operations, including edit-session registration and language and export status updates. +Renderer permissions are denied by default with an explicit allow list in [`permissions.mjs`](../../apps/desktop/src/permissions.mjs), limited to `opendirector://app`: `clipboard-sanitized-write`, the name a `navigator.clipboard.writeText` call carrying user activation requests, and the two fullscreen names `requestFullscreen` uses. The read/write clipboard name stays denied because every copy in the shared UI starts from a click and the renderer never reads the system clipboard, so granting it would hand the page a capability no caller uses. The fullscreen names are granted because a denial leaves the request promise unsettled and the player's button silently does nothing. With `OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD=1`, the installed smoke test also asserts that a copy carrying renderer user activation reaches the system clipboard and that the renderer's clipboard read is refused; it always asserts that a fullscreen request enters and exits. Granting a new renderer permission is a policy change, not a UI detail. + ## The Host owns project state The Host uses the same project storage, command validation, and edit-session rules as the standalone API. The desktop shell handles window behavior and opens native dialogs for file input and downloads. diff --git a/docs/architecture/desktop.zh-CN.md b/docs/architecture/desktop.zh-CN.md index 8caf00124..6c44e5ee0 100644 --- a/docs/architecture/desktop.zh-CN.md +++ b/docs/architecture/desktop.zh-CN.md @@ -18,6 +18,8 @@ flowchart LR 渲染进程通过 `opendirector://app` 请求应用页面、媒体和 API 资源。主进程转发请求时附带启动凭证,Host 验证凭证后处理请求。渲染进程关闭 Node 集成并开启上下文隔离。预加载脚本提供有限的桌面接口,包括登记编辑会话、同步语言和导出状态。 +渲染进程权限默认全部拒绝,只对 `opendirector://app` 开放一份显式清单(见 [`permissions.mjs`](../../apps/desktop/src/permissions.mjs)):带用户激活的 `navigator.clipboard.writeText` 申请的 `clipboard-sanitized-write`,以及 `requestFullscreen` 使用的两种全屏权限。读写剪贴板名称不授予:界面里的复制都由点击发起,渲染进程也从不读取系统剪贴板,授予它等于给页面一项没有调用方的能力。全屏若不授予,申请 Promise 会一直挂起,播放器的全屏按钮会静默失效。设置 `OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD=1` 时,已安装包的冒烟检查还会断言带用户激活的复制确实写入系统剪贴板、渲染进程读取剪贴板被拒绝;全屏能够进入也能够退出的断言则始终执行。新增任何渲染进程权限都属于策略变更,不是界面细节。 + ## Host 管理工程状态 Host 与独立 API 共用工程存储、命令校验和编辑会话规则。桌面壳管理窗口,并通过原生对话框选择文件和保存下载。 diff --git a/docs/development/desktop.md b/docs/development/desktop.md index 497d2ccbe..8233e346e 100644 --- a/docs/development/desktop.md +++ b/docs/development/desktop.md @@ -18,10 +18,12 @@ node apps/desktop/scripts/smoke.mjs /absolute/path/to/packaged/OpenDirector The runtime preparation builds the Python wheel using the existing build backend, including Web assets, skills and the actual OpenCode executable. It installs the wheel and dependencies into a private standalone Python distribution, validates CLI help and both media binaries, and records the target in `runtime/manifest.json`. It never modifies system Python. Supply media binaries with their redistribution licenses for the target; system package-manager binaries with external shared-library dependencies are not portable. -The smoke check launches the packaged executable with isolated temporary data. It connects the bundled OpenCode, chooses Canvas mode, and imports a WAV through Welcome with a local media model configuration that needs no provider calls. It also drops local MP4, PNG, and WAV files, verifies the saved assets and nodes after reopening, checks authenticated API calls, renderer isolation and both locales, and hides the window while the Host stays running. +The smoke check launches the packaged executable with isolated temporary data. It connects the bundled OpenCode, chooses Canvas mode, and imports a WAV through Welcome with a local media model configuration that needs no provider calls. It also drops local MP4, PNG, and WAV files, verifies the saved assets and nodes after reopening, checks authenticated API calls, renderer isolation and both locales, and hides the window while the Host stays running. With `OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD=1` it also asserts that a renderer copy carrying user activation reaches the system clipboard and that the renderer cannot read the clipboard; the flag is off by default so an ordinary run does not replace the clipboard of the machine that launches it. The fullscreen assertion runs in every smoke. It makes no provider calls. It does not establish Agent-assisted creation, export quality, signing, or support on an untested platform. The live trace fixture supplies the running flag for its own synthetic turn. The trace window reads incremental data from the packaged Host and renders the appended trace record. +Copy actions in the shared UI use `navigator.clipboard.writeText`, and the media player uses `requestFullscreen`; both are renderer permissions. The shell therefore grants the names those calls request and denies every other renderer permission ([`permissions.mjs`](../../apps/desktop/src/permissions.mjs)). Measure the permission names in the shipped Electron build instead of inferring them from Chromium, and check clipboard calls in the state the assertions run: in Electron 45 a scripted clipboard write asked for `clipboard-read`, the read/write name that also opens `navigator.clipboard.readText`, while a write carrying user activation asks for `clipboard-sanitized-write`. The shell grants only the name a user-activation write requests, and the packaged smoke issues the write with Chromium's gesture flag — the activation a click supplies — then checks that it reaches the system clipboard and that `readText` is refused with `NotAllowedError`. The smoke forces window focus before those checks; in the PR #458 packaged run, after earlier page interactions, the granted policy also admitted a write without transient activation, so the smoke does not assert that the activation-free write is refused. That write's requested permission name was not recorded, so the reason is not isolated; a focused probe page still requested `clipboard-read` and had that write refused. Fullscreen follows the same rule from the deny side: denying `automatic-fullscreen` or `fullscreen` leaves the request promise unsettled, so the button does nothing instead of reporting a refusal. The smoke therefore asserts that a fullscreen request settles, enters and exits. A browser page cannot stand in for these checks either, because Chrome grants the write itself, so only the packaged smoke run covers the shell policy. The permission name a write requests comes from Chromium's shared permission code and does not vary by platform; only a packaged run on a given platform establishes that its system clipboard and window server behave. + ## Terminal command Use **Manage terminal command** in the application menu to install the launcher in `~/.local/bin`. Add that directory to PATH if needed. The app preserves existing entries. To uninstall or repair an old installation, check the path shown in the app and manually remove the OpenDirector entry. To repair it, run Install again. `opendirector desktop` opens this installation; `opendirector serve` runs the ordinary standalone API. Business CLI commands retain their existing `--url`, project, session and revision rules. Automatic attachment of an external CLI to the private desktop Host is not available. diff --git a/docs/development/desktop.zh-CN.md b/docs/development/desktop.zh-CN.md index 18f372d6e..7b7213594 100644 --- a/docs/development/desktop.zh-CN.md +++ b/docs/development/desktop.zh-CN.md @@ -18,10 +18,12 @@ node apps/desktop/scripts/smoke.mjs /absolute/path/to/packaged/OpenDirector 运行时准备复用现有构建后端生成 Python wheel,包含前端、技能和实际 OpenCode 可执行文件;将 wheel 和依赖安装到私有独立 Python,验证 CLI 帮助及两个媒体程序,并将平台写入 `runtime/manifest.json`。不会修改系统 Python。提供对应平台可分发的媒体程序及许可证;依赖包管理器外部动态库的系统二进制不能直接作为便携运行时。 -冒烟检查使用临时数据目录启动打包程序,连接内置 OpenCode,选择画布模式,并通过欢迎页导入 WAV。测试使用无需调用模型服务的本地媒体模型配置。随后拖入本地 MP4、PNG 和 WAV 文件,重开工程确认素材和节点已保存,检查 API 鉴权、渲染隔离和中英文切换,并确认隐藏窗口后 Host 仍在运行。 +冒烟检查使用临时数据目录启动打包程序,连接内置 OpenCode,选择画布模式,并通过欢迎页导入 WAV。测试使用无需调用模型服务的本地媒体模型配置。随后拖入本地 MP4、PNG 和 WAV 文件,重开工程确认素材和节点已保存,检查 API 鉴权、渲染隔离和中英文切换,并确认隐藏窗口后 Host 仍在运行。设置 `OPENDIRECTOR_DESKTOP_SMOKE_CLIPBOARD=1` 时,冒烟还断言带用户激活的复制确实写入系统剪贴板、渲染进程读取剪贴板被拒绝;默认关闭,避免在日常运行中改写开发机的剪贴板。全屏断言在每次冒烟中都会执行。该检查不代表已完成 Agent 辅助创作、导出质量、签名或未测试平台的验收。 实时轨迹用例为合成的测试轮次提供运行标志。轨迹窗口从打包的 Host 增量读取数据并显示追加的轨迹记录。 +界面中的复制操作使用 `navigator.clipboard.writeText`,媒体播放器使用 `requestFullscreen`,两者都受渲染进程权限约束。桌面壳因此只授予这些调用实际申请的名称,其余渲染进程权限继续默认拒绝(见 [`permissions.mjs`](../../apps/desktop/src/permissions.mjs))。权限名称要在实际 Electron 构建里实测,不能从 Chromium 源码推导;剪贴板调用还要在断言实际运行的状态下检查:Electron 45 里脚本调用的写入申请 `clipboard-read`,也就是同时能打开 `navigator.clipboard.readText` 的读写名称,而同一段写入带有用户激活时申请 `clipboard-sanitized-write`。桌面壳只授予带用户激活的写入所申请的名称;安装包冒烟以 Chromium 的用户手势标志发出这次写入(点击提供的就是这种激活),再检查它确实写入系统剪贴板、`readText` 以 `NotAllowedError` 被拒。冒烟在进行这些检查前会强制窗口获得焦点;在 PR #458 的安装包运行中,经过前面的页面交互后,授予的策略同样允许了无用户激活的写入,因此冒烟不断言脚本写入被拒绝。该次写入申请的权限名称没有被记录,所以原因尚未隔离;已确认获得焦点的探针页面仍为此类写入申请 `clipboard-read` 并被拒绝,焦点本身并不能解释这一差异。全屏是同一类问题的反面:拒绝 `automatic-fullscreen` 或 `fullscreen` 会让申请 Promise 一直不落地,按钮看起来毫无反应而不是报错,因此冒烟也断言全屏申请能落地、能进入、能退出。普通浏览器页面同样不能替代这些检查,因为 Chrome 自己会授予写入权限,只有实际安装包的冒烟运行能覆盖桌面壳的权限策略。写入申请的权限名称来自 Chromium 共用的权限代码,不随平台变化;某个平台的系统剪贴板和窗口服务行为是否一致,只有在该平台跑一次安装包冒烟才能确认。 + ## 终端命令 通过应用菜单的“管理终端命令”在 `~/.local/bin` 安装启动器,必要时将该目录加入 PATH。应用会保留已有入口。如需卸载或修复旧安装,请检查应用显示的路径,确认入口属于 OpenDirector 后手动移除。修复时再点一次安装。`opendirector desktop` 打开此安装的桌面应用;`opendirector serve` 运行独立 API。业务命令沿用 `--url`、工程、会话和版本规则,目前不支持外部 CLI 自动连接桌面私有 Host。 diff --git a/docs/development/lessons.md b/docs/development/lessons.md index 292eaf466..bd8a47d2e 100644 --- a/docs/development/lessons.md +++ b/docs/development/lessons.md @@ -105,6 +105,17 @@ When work exposes a consequential risk or a recurring problem, add a lesson or u - **Final-window follow-up:** Native PR #193 regressions also broke the guard after the final pre-write check returned and after the final post-write check returned. A check is not an atomic write/cleanup guarantee. Retain the one-time native removal receipt, verify its ACE multiplicities under a fresh guard after a conflict, and report unconfirmed cleanup rather than spending the delta again. At release, distinguish a real oplock-break completion from the host's own cancellation and preserve an existing body error. This contract cannot prevent a principal with independent WRITE_DAC from changing permissions after the guard has been released; do not claim permanent ACL immutability. - **Installation ownership follow-up:** A deterministic PR #193 probe also replayed the pre-install descriptor plus an external identical deny. Retaining both successful installation receipts across the retry let cleanup remove the external rule. ACE counts cannot establish provenance: an equal-count replacement is also possible. If the installation's guard cannot finish successfully after a native acknowledgment, stop initialization and report unconfirmed ownership without retrying or removing that handle's uncertain ACEs. A setter wrapper error with a successfully checked and released guard remains an ordinary rollback case. Cover pre-write retry, both replay shapes, additive writers, partial preparation, setter errors and release failures; distinguish portable control flow from actual Windows scheduling. +## A deny-all renderer permission handler also denies clipboard writes + +- **Trigger:** Adding a renderer permission policy to an Electron shell, or a copy button that fails only in the packaged app. +- **Lesson:** [PR #397](https://github.com/ThinkFlowLab/OpenDirector/pull/397) installed `setPermissionRequestHandler(() => callback(false))`. Electron grants renderer permissions by default and only denies through that handler, so every `navigator.clipboard.writeText` copy in the shared UI rejected with `NotAllowedError: Write permission denied.` in the packaged application while the same page worked in a browser that grants the write itself. +- **Check:** State renderer permissions as an explicit allow list limited to the shell's own origin, and check the renderer's clipboard calls from the main process in the state the user path runs in. Measured Electron 45 on Windows, `navigator.clipboard.writeText` asks for different names per path: a scripted write without transient activation requests `clipboard-read` and is refused, while a write carrying user activation — the flag a click supplies — requests `clipboard-sanitized-write`. An allow list with only `clipboard-read` therefore passed the scripted smoke write while every copy button a user pressed still failed, and `document.execCommand('copy')` also returned false, so a scripted fallback cannot repair a denied write. Focus alone did not change the scripted result: PR #458's probe forced and verified renderer focus, and with `clipboard-sanitized-write` granted the scripted write still requested `clipboard-read` and was refused, while that PR's packaged smoke, after earlier page interactions, resolved the same write on Windows and failed its refusal assertion. Measure the requested name and the state in the shipped build; do not infer either from Chromium source, and do not let a permission-free scripted call stand in for a click. +- **Permission follow-up:** Chromium reports a scripted write without transient activation as `clipboard-read`, the same permission that opens `navigator.clipboard.readText`, so granting it to keep a scripted assertion passing hands the page the ability to read the system clipboard. Name the capability, not the call: grant the name a write with user activation requests, and assert in the installed run that `readText` stays refused. Do not also assert that an activation-free write is refused: in PR #458's packaged smoke run, after earlier page interactions, the granted policy admitted that write too, and the permission name it requested in that state was not recorded, so the reason is not isolated. A probe with verified renderer focus still requested `clipboard-read` and was refused. A test that grants whatever the smoke needs makes the smoke drive the policy instead of checking it. +- **Origin follow-up:** Scope by `details.requestingUrl` in the request handler and by the requesting origin in the check handler. Electron 45's `PermissionRequest` typings expose only `isMainFrame` and `requestingUrl`; `securityOrigin` is optional and belongs to `MediaAccessPermissionRequest`, so it is not a value every permission request carries. Treat a non-app origin as a denial instead of letting `new URL` throw. `requestingUrl` is always a string, so a fallback for a missing value never runs; the value that needs handling is the empty or unparsable one, and falling back to the page URL there would promote an untrusted frame's request to the shell's own grant. +- **Fullscreen follow-up:** A denial the renderer never sees is the harder failure: denying `fullscreen` or `automatic-fullscreen` leaves `requestFullscreen`'s promise unsettled, so the button does nothing and no `.catch` runs. Assert the settled request, the entry, and the exit; a permission granted only on paper is indistinguishable from a denied one until the promise is waited on with a timeout. +- **Close follow-up:** The end-of-smoke check that closing the window leaves the Host running is one instantaneous observation. On the macOS runner it failed on the second smoke launch (`Closing a window stopped the Host`) while the Host was still serving and was stopped only by the failure path; the identical check passed on the first launch and on earlier heads. Wait for the native fullscreen exit, then poll until the window is hidden and the Host answers an inspection within a bounded budget before reporting a stop. +- **Clipboard read-back follow-up:** `clipboard.readText()` is asynchronous in Electron 45, so a smoke assertion that compares its return value directly always fails; await it, and poll instead of reading once — the renderer promise settles before the system clipboard holds the value, so an immediate read still returns the previous contents (measured intermittently for a write carrying user activation). Run clipboard assertions only when an isolated-verification flag is set, because reading and writing the system clipboard replaces whatever the machine held, including non-text formats that cannot be restored; a default developer run must not touch it. Failure messages state which assertion failed, never the clipboard contents. + ## A process exit and ownership of its descendants are separate facts - **Trigger:** Adapting browser fixture cleanup or sampled process memory to Windows. diff --git a/docs/development/validation.md b/docs/development/validation.md index 75e79f85d..8a4be9317 100644 --- a/docs/development/validation.md +++ b/docs/development/validation.md @@ -277,6 +277,7 @@ Replace `all` with comma-separated runtime IDs to select a subset. Bundled reads | 编辑器与时间线 | 结构往返、素材保护、重开续编、真实文件播放及导出 | | UI 与 Agent 接入 | 相同意图的业务结果一致,交错编辑和草稿保留 | | 交互与同步 | 真实拖动、缩放、焦点、锁定、重复事件和断线恢复 | +| 桌面壳与原生能力 | 渲染进程权限清单、安装包冒烟中带用户激活的剪贴板写入与读取拒绝、全屏请求;浏览器默认授权不能代表桌面壳行为 | | 性能 | 固定素材和手势下比较帧延迟、长任务、内存或 CPU 数据 | | 文档 | 链接、命令与文件路径正确,依赖文件随仓库交付 |