mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
safari device checks and tests
This commit is contained in:
parent
3743e5b409
commit
12ad4f6df8
@ -81,5 +81,25 @@ describe('Browser Utils Service', () => {
|
||||
const browserPlatformUtilsService = new BrowserPlatformUtilsService();
|
||||
expect(browserPlatformUtilsService.getDevice()).toBe(DeviceType.Edge);
|
||||
});
|
||||
|
||||
it('should detect safari', () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
configurable: true,
|
||||
value: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8'
|
||||
});
|
||||
|
||||
const browserPlatformUtilsService = new BrowserPlatformUtilsService();
|
||||
expect(browserPlatformUtilsService.getDevice()).toBe(DeviceType.Safari);
|
||||
});
|
||||
|
||||
it('should detect vivaldi', () => {
|
||||
Object.defineProperty(navigator, 'userAgent', {
|
||||
configurable: true,
|
||||
value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.97 Safari/537.36 Vivaldi/1.94.1008.40'
|
||||
});
|
||||
|
||||
const browserPlatformUtilsService = new BrowserPlatformUtilsService();
|
||||
expect(browserPlatformUtilsService.getDevice()).toBe(DeviceType.Vivaldi);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -68,6 +68,8 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
this.deviceCache = DeviceType.Edge;
|
||||
} else if (navigator.userAgent.indexOf(' Vivaldi/') !== -1) {
|
||||
this.deviceCache = DeviceType.Vivaldi;
|
||||
} else if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
|
||||
this.deviceCache = DeviceType.Safari;
|
||||
} else if ((window as any).chrome) {
|
||||
this.deviceCache = DeviceType.Chrome;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user