区分原生文件选择取消语义

H5 HostBridge 将原生取消从不支持能力错误中拆出

文件导入与拍摄取消统一返回 null,保留不支持和畸形结果为 false

补充取消导入与拍摄回归测试并加入原生壳门禁反查
This commit is contained in:
2026-06-20 05:07:43 +08:00
parent 17c1dac76d
commit 3c853da830
3 changed files with 86 additions and 15 deletions
+24
View File
@@ -1252,26 +1252,32 @@ function assertH5HostBridgePayloadBoundaries() {
{
functionName: 'importHostTextFile',
normalizer: 'normalizeHostBridgeImportTextResult',
preserveCancellation: true,
},
{
functionName: 'importHostDocumentFile',
normalizer: 'normalizeHostBridgeImportDocumentResult',
preserveCancellation: true,
},
{
functionName: 'importHostImageFile',
normalizer: 'normalizeHostBridgeImportImageResult',
preserveCancellation: true,
},
{
functionName: 'captureHostImageFile',
normalizer: 'normalizeHostBridgeImportImageResult',
preserveCancellation: true,
},
{
functionName: 'importHostAudioFile',
normalizer: 'normalizeHostBridgeImportAudioResult',
preserveCancellation: true,
},
{
functionName: 'subscribeHostImageDrop',
normalizer: 'normalizeHostBridgeImportImageResult',
preserveCancellation: false,
},
]) {
const functionSource = extractFunctionSource(
@@ -1283,6 +1289,24 @@ function assertH5HostBridgePayloadBoundaries() {
`${importBoundary.functionName} must normalize imported file results with shared ${importBoundary.normalizer}`,
);
}
if (
importBoundary.preserveCancellation &&
(!functionSource.includes('isCancelledHostBridgeError(error)') ||
!functionSource.includes('return null;'))
) {
throw new Error(
`${importBoundary.functionName} must preserve native user cancellation as null`,
);
}
}
const unsupportedHelperSource = extractFunctionSource(
h5HostBridgeSource,
'isUnsupportedHostBridgeError',
);
if (unsupportedHelperSource.includes("'cancelled'")) {
throw new Error(
'H5 HostBridge facade must not treat native user cancellation as unsupported capability',
);
}
for (const localMimeSet of [
'HOST_BRIDGE_TEXT_MIME_TYPE_SET',