锁定移动剪贴板不可用读取

移动剪贴板单测覆盖底层不可用值返回 host_error

移动壳配置检查反查剪贴板不可用读取边界

共享决策日志补充剪贴板失败语义
This commit is contained in:
2026-06-20 10:37:58 +08:00
parent 00f4af13c6
commit ea50282e11
3 changed files with 26 additions and 2 deletions
+16 -1
View File
@@ -42,6 +42,11 @@ const capabilitiesTestPath = new URL(
const capabilitiesTestSource = fs.readFileSync(capabilitiesTestPath, 'utf8');
const clipboardPath = new URL('../src/host-bridge/clipboard.ts', import.meta.url);
const clipboardSource = fs.readFileSync(clipboardPath, 'utf8');
const clipboardTestPath = new URL(
'../src/host-bridge/clipboard.test.ts',
import.meta.url,
);
const clipboardTestSource = fs.readFileSync(clipboardTestPath, 'utf8');
const dispatchPath = new URL('../src/host-bridge/dispatch.ts', import.meta.url);
const dispatchSource = fs.readFileSync(dispatchPath, 'utf8');
const dispatchTestPath = new URL(
@@ -2156,9 +2161,19 @@ for (const snippet of [
throw new Error(`mobile shell clipboard module is missing ${snippet}`);
}
}
if (!bridgeTestSource.includes("'猫'.repeat(100000)")) {
if (!clipboardTestSource.includes("'猫'.repeat(100000)")) {
throw new Error('mobile shell clipboard tests must cover Unicode truncation');
}
for (const snippet of [
'rejects unavailable clipboard text without reporting a successful empty value',
'Clipboard.getStringAsync).mockResolvedValue(undefined as never)',
"code: 'host_error'",
"message: 'clipboard text unavailable'",
]) {
if (!clipboardTestSource.includes(snippet)) {
throw new Error(`mobile shell clipboard tests must cover unavailable reads: ${snippet}`);
}
}
if (
!hapticsSource.includes('normalizeHostBridgeHapticsImpactStyle(rawStyle)') ||