接入原生壳外链打开路径
H5 新增 openHostExternalUrl 并归一化外链 URL 备案号和资产调试原图在 native_app 中优先交给宿主打开 补充 HostBridge 外链测试和宿主壳文档
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
getNativeAppHostRuntime,
|
||||
isWechatMiniProgramWebViewRuntime,
|
||||
navigateHostNativePage,
|
||||
openHostExternalUrl,
|
||||
openHostShare,
|
||||
openHostShareGrid,
|
||||
openWechatMiniProgramShareGridPage,
|
||||
@@ -317,6 +318,9 @@ describe('hostBridge', () => {
|
||||
await expect(requestHostHapticsImpact({ style: 'medium' })).resolves.toBe(
|
||||
true,
|
||||
);
|
||||
await expect(
|
||||
openHostExternalUrl({ url: '/works/detail?work=PZ-1' }),
|
||||
).resolves.toBe(true);
|
||||
await expect(setHostAppTitle({ title: ' 拼图 - 陶泥儿 ' })).resolves.toBe(
|
||||
true,
|
||||
);
|
||||
@@ -364,6 +368,14 @@ describe('hostBridge', () => {
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'app.openExternalUrl',
|
||||
payload: {
|
||||
url: `${window.location.origin}/works/detail?work=PZ-1`,
|
||||
},
|
||||
}),
|
||||
});
|
||||
expect(invoke).toHaveBeenCalledWith('host_bridge_request', {
|
||||
request: expect.objectContaining({
|
||||
method: 'app.setTitle',
|
||||
@@ -418,6 +430,12 @@ describe('hostBridge', () => {
|
||||
await expect(requestHostHapticsImpact({ style: 'light' })).resolves.toBe(
|
||||
false,
|
||||
);
|
||||
await expect(
|
||||
openHostExternalUrl({ url: 'https://beian.miit.gov.cn/' }),
|
||||
).resolves.toBe(false);
|
||||
await expect(
|
||||
openHostExternalUrl({ url: 'javascript:alert(1)' }),
|
||||
).resolves.toBe(false);
|
||||
await expect(setHostAppTitle({ title: '拼图 - 陶泥儿' })).resolves.toBe(
|
||||
false,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user