收口原生能力可信边界
H5 原生能力只信任真实 host.getRuntime 回包 移除桌面壳未声明网络事件白名单 补齐原生壳能力门控测试和共享决策记录
This commit is contained in:
@@ -98,7 +98,10 @@ import {
|
||||
regenerateBabyObjectMatchDraftAssets,
|
||||
saveBabyObjectMatchDraft,
|
||||
} from '../../services/edutainment-baby-object';
|
||||
import { resetHostRuntimeCacheForTest } from '../../services/host-bridge/hostBridge';
|
||||
import {
|
||||
resetHostRuntimeCacheForTest,
|
||||
setHostRuntimeCacheForTest,
|
||||
} from '../../services/host-bridge/hostBridge';
|
||||
import { resetNativeAppHostBridgeForTest } from '../../services/host-bridge/nativeAppHostBridge';
|
||||
import { jumpHopClient } from '../../services/jump-hop/jumpHopClient';
|
||||
import { match3dCreationClient } from '../../services/match3d-creation';
|
||||
@@ -315,11 +318,26 @@ function nativeAppPath(capabilities: HostBridgeCapability[] = []) {
|
||||
return `/?${params.toString()}`;
|
||||
}
|
||||
|
||||
function installTauriHostBridgeRecorder() {
|
||||
function installTauriHostBridgeRecorder(capabilities: HostBridgeCapability[] = []) {
|
||||
const requests: HostBridgeRequest[] = [];
|
||||
const invoke = vi.fn(async (_command: string, args?: Record<string, unknown>) => {
|
||||
const request = (args as { request: HostBridgeRequest }).request;
|
||||
requests.push(request);
|
||||
if (request.method === 'host.getRuntime') {
|
||||
return {
|
||||
bridge: 'GenarrativeHostBridge',
|
||||
version: 1,
|
||||
id: request.id,
|
||||
ok: true,
|
||||
result: {
|
||||
shell: 'tauri_desktop',
|
||||
platform: 'linux',
|
||||
hostVersion: '0.1.0',
|
||||
bridgeVersion: 1,
|
||||
capabilities: ['host.getRuntime', ...capabilities],
|
||||
},
|
||||
};
|
||||
}
|
||||
return {
|
||||
bridge: 'GenarrativeHostBridge',
|
||||
version: 1,
|
||||
@@ -9199,7 +9217,17 @@ test('native app jump hop draft completion sends host notification and badge fro
|
||||
resolveCompile = resolve;
|
||||
}),
|
||||
);
|
||||
const { requests } = installTauriHostBridgeRecorder();
|
||||
const { requests } = installTauriHostBridgeRecorder([
|
||||
'app.setBadgeCount',
|
||||
'notification.showLocal',
|
||||
]);
|
||||
setHostRuntimeCacheForTest({
|
||||
shell: 'tauri_desktop',
|
||||
platform: 'linux',
|
||||
hostVersion: '0.1.0',
|
||||
bridgeVersion: 1,
|
||||
capabilities: ['app.setBadgeCount', 'notification.showLocal'],
|
||||
});
|
||||
window.history.replaceState(
|
||||
null,
|
||||
'',
|
||||
@@ -9250,7 +9278,16 @@ test('native app jump hop draft completion sends host notification and badge fro
|
||||
|
||||
test('native app opens child motion demo through host navigation bridge', async () => {
|
||||
const user = userEvent.setup();
|
||||
const { requests } = installTauriHostBridgeRecorder();
|
||||
const { requests } = installTauriHostBridgeRecorder([
|
||||
'navigation.openNativePage',
|
||||
]);
|
||||
setHostRuntimeCacheForTest({
|
||||
shell: 'tauri_desktop',
|
||||
platform: 'linux',
|
||||
hostVersion: '0.1.0',
|
||||
bridgeVersion: 1,
|
||||
capabilities: ['navigation.openNativePage'],
|
||||
});
|
||||
window.history.replaceState(
|
||||
null,
|
||||
'',
|
||||
|
||||
Reference in New Issue
Block a user