锁定微信原生页跳转失败提示

H5 HostBridge 微信小程序跳转失败不再透出原生 errMsg

HostBridge 测试覆盖微信跳转失败稳定提示

native shell 总门禁反查微信跳转失败边界
This commit is contained in:
2026-06-20 13:43:48 +08:00
parent 1cf9e6bcc6
commit fba6fb75fb
3 changed files with 64 additions and 1 deletions
+25
View File
@@ -1027,6 +1027,10 @@ function assertH5HostBridgePayloadBoundaries() {
'src/services/host-bridge/hostBridge.ts',
'utf8',
);
const h5HostBridgeTestSource = fs.readFileSync(
'src/services/host-bridge/hostBridge.test.ts',
'utf8',
);
const nativeRequestCapabilities = extractTsStringArray(
sharedContractSource,
'HOST_BRIDGE_METHODS',
@@ -1117,6 +1121,27 @@ function assertH5HostBridgePayloadBoundaries() {
'H5 HostBridge facade must reject unsafe native app navigation targets before sending navigation.openNativePage',
);
}
if (
!h5HostBridgeSource.includes(
"'[host-bridge] wechat mini program navigation failed'",
) ||
!h5HostBridgeSource.includes('reject(new Error(errorMessage));') ||
h5HostBridgeSource.includes('reject(new Error(error?.errMsg || errorMessage));')
) {
throw new Error(
'H5 HostBridge facade must not expose wx.miniProgram.navigateTo native failures',
);
}
for (const snippet of [
'hides wechat mini program navigation native failure details',
"errMsg: 'navigateTo:fail private native detail'",
"rejects.toThrow(\n '请在微信小程序内完成登录',",
"rejects.not.toThrow(\n 'private native detail',",
]) {
if (!h5HostBridgeTestSource.includes(snippet)) {
throw new Error(`H5 HostBridge navigation failure test must include ${snippet}`);
}
}
if (
!h5HostBridgeSource.includes(
'absolutizeHostSharePayloadUrls(params),',