mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
feat(PlatformUtils): [Auth/PM-25817] New PlatformUtilsService.isChromium() method (#16468)
This commit is contained in:
@@ -356,6 +356,33 @@ describe("Browser Utils Service", () => {
|
||||
expect(result).toBe("");
|
||||
});
|
||||
});
|
||||
|
||||
describe("isChromium", () => {
|
||||
const chromiumDevices: DeviceType[] = [
|
||||
DeviceType.ChromeExtension,
|
||||
DeviceType.EdgeExtension,
|
||||
DeviceType.OperaExtension,
|
||||
DeviceType.VivaldiExtension,
|
||||
];
|
||||
|
||||
const nonChromiumDevices: DeviceType[] = [
|
||||
DeviceType.FirefoxExtension,
|
||||
DeviceType.SafariExtension,
|
||||
];
|
||||
afterEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
test.each(chromiumDevices)("returns true when getDevice() is %s", (deviceType) => {
|
||||
jest.spyOn(browserPlatformUtilsService, "getDevice").mockReturnValue(deviceType);
|
||||
expect(browserPlatformUtilsService.isChromium()).toBe(true);
|
||||
});
|
||||
|
||||
test.each(nonChromiumDevices)("returns false when getDevice() is %s", (deviceType) => {
|
||||
jest.spyOn(browserPlatformUtilsService, "getDevice").mockReturnValue(deviceType);
|
||||
expect(browserPlatformUtilsService.isChromium()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Safari Height Fix", () => {
|
||||
|
||||
@@ -123,6 +123,10 @@ export abstract class BrowserPlatformUtilsService implements PlatformUtilsServic
|
||||
return this.getDevice() === DeviceType.SafariExtension;
|
||||
}
|
||||
|
||||
isChromium(): boolean {
|
||||
return this.isChrome() || this.isEdge() || this.isOpera() || this.isVivaldi();
|
||||
}
|
||||
|
||||
/**
|
||||
* Safari previous to version 16.1 had a bug which caused artifacts on hover in large extension popups.
|
||||
* https://bugs.webkit.org/show_bug.cgi?id=218704
|
||||
|
||||
Reference in New Issue
Block a user