diff --git a/packages/connect-popup/e2e/tests/browser-support.test.ts b/packages/connect-popup/e2e/tests/browser-support.test.ts index d0ea748c04f5..61bf645e00a8 100644 --- a/packages/connect-popup/e2e/tests/browser-support.test.ts +++ b/packages/connect-popup/e2e/tests/browser-support.test.ts @@ -48,7 +48,7 @@ test('unsupported browser', async ({ browser }) => { await context.close(); }); -test('outdated-browser', async ({ browser }) => { +test('outdated browser', async ({ browser }) => { const context = await browser.newContext({ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/50.0', @@ -76,27 +76,35 @@ test('outdated-browser', async ({ browser }) => { }); // test mobile browsers -test.describe(() => { - const fixtures = [ - { desc: 'iPhone', device: iPhone }, - { desc: 'android', device: android }, - ]; - for (const f of fixtures) { - test(`env: web, device: mobile/${f.desc} => not allowed `, async ({ browser }) => { - const context = await browser.newContext({ - ...f.device, - }); - const page = await context.newPage(); - await page.goto(formatUrl(url, `methods/bitcoin/getPublicKey/`)); +test(`env: web, device: mobile/iPhone => not allowed `, async ({ browser }) => { + const context = await browser.newContext({ + ...iPhone, + }); + const page = await context.newPage(); + await page.goto(formatUrl(url, `methods/bitcoin/getPublicKey/`)); + + popup = await openPopup(page); + // unfortunately webusb now does not work for connect-popup, so mobile chrome won't run even if it technically could + await popup.waitForSelector('text=Smartphones not supported yet'); + await popup.screenshot({ path: `${dir}/mobile-iphone-not-supported.png` }); - popup = await openPopup(page); - // unfortunately webusb now does not work for connect-popup, so mobile chrome won't run even if it technically could - await popup.waitForSelector('text=Smartphones not supported yet'); - await popup.screenshot({ path: `${dir}/mobile-${f.desc}-not-supported.png` }); + await popup.click('text=Close'); + await page.close(); + await context.close(); +}); - await popup.click('text=Close'); - await page.close(); - await context.close(); - }); - } +test(`env: web, device: mobile/Android => allowed `, async ({ browser }) => { + const context = await browser.newContext({ + ...android, + }); + const page = await context.newPage(); + await page.goto(formatUrl(url, `methods/bitcoin/getPublicKey/`)); + + popup = await openPopup(page); + + await popup.waitForSelector('text=Connect Trezor to continue'); + await popup.screenshot({ path: `${dir}/mobile-android-supported.png` }); + + await page.close(); + await context.close(); }); diff --git a/packages/connect-popup/src/view/browser.ts b/packages/connect-popup/src/view/browser.ts index 3bf6936badce..782170d5c527 100644 --- a/packages/connect-popup/src/view/browser.ts +++ b/packages/connect-popup/src/view/browser.ts @@ -5,9 +5,9 @@ import { storage } from '@trezor/connect-common'; import { container, showView } from './common'; export const initBrowserView = (systemInfo: SystemInfo): Promise => { - if (systemInfo?.os.mobile) { - // popup is not supported on mobile devices - // webusb is now available only on trezor.io domains and bridge can't be installed on mobile + if (systemInfo?.os.mobile && !systemInfo?.browser.supported) { + // popup can now support smartphones that have WebUSB support (e.g. Android with Chrome) + // browsers that are not supported will get rejected showView('smartphones-not-supported'); return Promise.resolve(false);