锁定移动壳外链导航失败响应
移动壳外链原生探测失败返回稳定不可打开结果 移动壳外链原生打开失败返回稳定不可打开结果 移动壳 HostBridge 外链异常返回稳定错误 移动壳配置检查补充外链原生失败边界反查
This commit is contained in:
@@ -159,6 +159,8 @@ const deepLinkPath = new URL('../src/shell/deepLink.ts', import.meta.url);
|
||||
const deepLinkSource = fs.readFileSync(deepLinkPath, 'utf8');
|
||||
const navigationPath = new URL('../src/shell/navigation.ts', import.meta.url);
|
||||
const navigationSource = fs.readFileSync(navigationPath, 'utf8');
|
||||
const navigationTestPath = new URL('../src/shell/navigation.test.ts', import.meta.url);
|
||||
const navigationTestSource = fs.readFileSync(navigationTestPath, 'utf8');
|
||||
const webViewPolicyPath = new URL('../src/shell/webViewPolicy.ts', import.meta.url);
|
||||
const webViewPolicySource = fs.readFileSync(webViewPolicyPath, 'utf8');
|
||||
const webViewHistoryPath = new URL('../src/shell/webViewHistory.ts', import.meta.url);
|
||||
@@ -1767,6 +1769,8 @@ for (const snippet of [
|
||||
'return normalizeHostBridgeExternalUrl(rawUrl)',
|
||||
'navigator.canOpenURL(externalUrl)',
|
||||
'navigator.openURL(externalUrl)',
|
||||
'catch {',
|
||||
'return false;',
|
||||
'shouldOpenInMobileShellWebView(rawUrl, allowedOrigin)',
|
||||
'new URL(rawUrl, allowedOrigin).toString()',
|
||||
]) {
|
||||
@@ -1775,6 +1779,14 @@ for (const snippet of [
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!navigationTestSource.includes('WebView 外链原生探测或打开失败时留在壳内') ||
|
||||
!navigationTestSource.includes('native canOpenURL failed') ||
|
||||
!navigationTestSource.includes('native openURL failed')
|
||||
) {
|
||||
throw new Error('mobile shell navigation tests must cover native external open failures');
|
||||
}
|
||||
|
||||
if (
|
||||
navigationSource.includes('javascript:') ||
|
||||
navigationSource.includes('mailto:') ||
|
||||
@@ -2194,6 +2206,7 @@ for (const snippet of [
|
||||
'Linking.openURL',
|
||||
'javascript:alert(1)',
|
||||
'external URL cannot be opened',
|
||||
'converts native external open exceptions to stable host_error',
|
||||
'navigation.openNativePage unsupported in mobile shell',
|
||||
'app.reloadWebView unsupported in mobile shell',
|
||||
'hostCapabilities',
|
||||
@@ -2385,8 +2398,8 @@ for (const snippet of [
|
||||
'shellHarness.networkListeners[0]?.({',
|
||||
"type: 'genarrative.mobile.historyState'",
|
||||
'mobile host event failed for network.statusChanged',
|
||||
'external WebView navigation open failure is logged instead of hidden',
|
||||
'mobile shell navigation failed for external_navigation.open',
|
||||
'external WebView navigation native failures stay outside the WebView',
|
||||
"expect(Linking.openURL).toHaveBeenCalledWith(",
|
||||
]) {
|
||||
if (!shellAppTestSource.includes(snippet)) {
|
||||
throw new Error(`mobile shell ShellApp HostBridge event test missing ${snippet}`);
|
||||
|
||||
Reference in New Issue
Block a user