fix(game): own export chooser modal; PNG option outside in-app webviews only
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 59s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m26s
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 59s
CI / conformance (pull_request) Successful in 9s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m26s
Telegram's native showPopup delivers its callback with no user activation, so navigator.share (TG iOS) and clipboard writes (TG Android GCG copy) silently fail from it — the chooser is now always the app's own modal, keeping the button click's gesture alive for the delivery APIs. The data:URL preview modal is dropped: the Android TG/VK long-press menu mangles data: URLs (dead download, black-screen open, base64 clipboard garbage), so a binary PNG has no working client-side route in those webviews at all. The image option is withheld there until the server-rendered signed-URL delivery (Telegram downloadFile / VKWebAppDownloadFile) lands; the plain web and mobile browsers keep it. On-device findings by the owner on the test contour (TG iOS, TG Android, VK Android).
This commit is contained in:
@@ -87,19 +87,13 @@ describe('pickImageDelivery', () => {
|
||||
const canShareNav = { canShare: () => true, share: async () => {} };
|
||||
const noShareNav = { canShare: () => false, share: async () => {} };
|
||||
|
||||
it('shares when the platform can share files, even in an in-app webview (iOS)', () => {
|
||||
expect(pickImageDelivery(canShareNav, file, false)).toBe('share');
|
||||
expect(pickImageDelivery(canShareNav, file, true)).toBe('share');
|
||||
});
|
||||
|
||||
it('previews in an in-app webview that cannot share files (a binary PNG has no clipboard-text fallback)', () => {
|
||||
expect(pickImageDelivery(noShareNav, file, true)).toBe('preview');
|
||||
expect(pickImageDelivery(undefined, file, true)).toBe('preview');
|
||||
it('shares when the platform can share files', () => {
|
||||
expect(pickImageDelivery(canShareNav, file)).toBe('share');
|
||||
});
|
||||
|
||||
it('downloads on a plain browser without Web Share (desktop)', () => {
|
||||
expect(pickImageDelivery(noShareNav, file, false)).toBe('download');
|
||||
expect(pickImageDelivery(undefined, file, false)).toBe('download');
|
||||
expect(pickImageDelivery(noShareNav, file)).toBe('download');
|
||||
expect(pickImageDelivery(undefined, file)).toBe('download');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +115,7 @@ describe('shareOrDownloadImage', () => {
|
||||
const share = vi.fn().mockRejectedValue(new DOMException('cancelled', 'AbortError'));
|
||||
const { createElement } = stubEnv(true, share);
|
||||
|
||||
expect(await shareOrDownloadImage(png(), false)).toBe('shared');
|
||||
expect(await shareOrDownloadImage(png())).toBe('shared');
|
||||
|
||||
expect(share).toHaveBeenCalledOnce();
|
||||
expect(createElement).not.toHaveBeenCalled();
|
||||
@@ -130,20 +124,12 @@ describe('shareOrDownloadImage', () => {
|
||||
it('downloads via an anchor on a desktop browser that cannot share files', async () => {
|
||||
const { anchor, createElement } = stubEnv(false, vi.fn());
|
||||
|
||||
expect(await shareOrDownloadImage(png(), false)).toBe('downloaded');
|
||||
expect(await shareOrDownloadImage(png())).toBe('downloaded');
|
||||
|
||||
expect(createElement).toHaveBeenCalledWith('a');
|
||||
expect(anchor.click).toHaveBeenCalledOnce();
|
||||
expect(anchor.download).toBe('game-1.png');
|
||||
});
|
||||
|
||||
it('hands an in-app webview over to the preview modal (no share, no dead download)', async () => {
|
||||
const { createElement } = stubEnv(false, vi.fn());
|
||||
|
||||
expect(await shareOrDownloadImage(png(), true)).toBe('preview');
|
||||
|
||||
expect(createElement).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('pickTextShare', () => {
|
||||
|
||||
Reference in New Issue
Block a user