app: treat pure Chromium UA as supported for extension banner

Match Chromium/ as well as Chrome/ so builds that omit Chrome in the
user agent still see the install nudge. Cover with a unit test.
This commit is contained in:
Roland 2026-07-18 13:51:37 -06:00
parent db7603012e
commit c79127e7da
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
2 changed files with 12 additions and 1 deletions

View file

@ -3,6 +3,7 @@ import {render, screen, waitFor} from '../../test-utils';
import {ExtensionInstallSuggestion} from './ExtensionInstallSuggestion';
const CHROME_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36';
const CHROMIUM_UA = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chromium/147.0.0.0 Safari/537.36';
const FIREFOX_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0';
const SAFARI_UA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15';
@ -57,6 +58,15 @@ describe('ExtensionInstallSuggestion', () => {
);
});
it('renders the install message on pure Chromium (Chromium/ without Chrome/)', async () => {
setUserAgent(CHROMIUM_UA);
render(<ExtensionInstallSuggestion/>);
await waitFor(
() => expect(screen.getByText(/Install the WROLPi browser extension/i)).toBeInTheDocument(),
{timeout: 1500},
);
});
it('renders nothing on Safari even when the marker is absent', async () => {
setUserAgent(SAFARI_UA);
render(<ExtensionInstallSuggestion/>);

View file

@ -12,7 +12,8 @@ export function detectBrowser() {
if (ua.includes('Firefox')) return 'firefox';
if (ua.includes('Edg/')) return 'chromium';
if (ua.includes('OPR/') || ua.includes('Opera')) return 'chromium';
if (ua.includes('Chrome')) return 'chromium';
// Pure Chromium builds may advertise Chromium/ without Chrome/.
if (ua.includes('Chrome') || ua.includes('Chromium')) return 'chromium';
return 'unknown';
}