mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +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("");
|
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", () => {
|
describe("Safari Height Fix", () => {
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ export abstract class BrowserPlatformUtilsService implements PlatformUtilsServic
|
|||||||
return this.getDevice() === DeviceType.SafariExtension;
|
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.
|
* 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
|
* https://bugs.webkit.org/show_bug.cgi?id=218704
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ export class CliPlatformUtilsService implements PlatformUtilsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isChromium(): boolean {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
isMacAppStore() {
|
isMacAppStore() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,10 @@ export class ElectronPlatformUtilsService implements PlatformUtilsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isChromium(): boolean {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
isMacAppStore(): boolean {
|
isMacAppStore(): boolean {
|
||||||
return ipc.platform.isMacAppStore;
|
return ipc.platform.isMacAppStore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,4 +203,35 @@ describe("Web Platform Utils Service", () => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("isChromium", () => {
|
||||||
|
const chromiumDevices = [
|
||||||
|
DeviceType.ChromeBrowser,
|
||||||
|
DeviceType.EdgeBrowser,
|
||||||
|
DeviceType.OperaBrowser,
|
||||||
|
DeviceType.VivaldiBrowser,
|
||||||
|
];
|
||||||
|
|
||||||
|
const nonChromiumDevices = [
|
||||||
|
DeviceType.FirefoxBrowser,
|
||||||
|
DeviceType.SafariBrowser,
|
||||||
|
DeviceType.IEBrowser,
|
||||||
|
DeviceType.DuckDuckGoBrowser,
|
||||||
|
DeviceType.UnknownBrowser,
|
||||||
|
];
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jest.restoreAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(chromiumDevices)("returns true when getDevice() is %s", (deviceType) => {
|
||||||
|
jest.spyOn(webPlatformUtilsService, "getDevice").mockReturnValue(deviceType);
|
||||||
|
expect(webPlatformUtilsService.isChromium()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(nonChromiumDevices)("returns false when getDevice() is %s", (deviceType) => {
|
||||||
|
jest.spyOn(webPlatformUtilsService, "getDevice").mockReturnValue(deviceType);
|
||||||
|
expect(webPlatformUtilsService.isChromium()).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
|||||||
return this.getDevice() === DeviceType.SafariBrowser;
|
return this.getDevice() === DeviceType.SafariBrowser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isChromium(): boolean {
|
||||||
|
return this.isChrome() || this.isEdge() || this.isOpera() || this.isVivaldi();
|
||||||
|
}
|
||||||
|
|
||||||
isWebKit(): boolean {
|
isWebKit(): boolean {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export abstract class PlatformUtilsService {
|
|||||||
abstract isOpera(): boolean;
|
abstract isOpera(): boolean;
|
||||||
abstract isVivaldi(): boolean;
|
abstract isVivaldi(): boolean;
|
||||||
abstract isSafari(): boolean;
|
abstract isSafari(): boolean;
|
||||||
|
abstract isChromium(): boolean;
|
||||||
abstract isMacAppStore(): boolean;
|
abstract isMacAppStore(): boolean;
|
||||||
abstract isPopupOpen(): Promise<boolean>;
|
abstract isPopupOpen(): Promise<boolean>;
|
||||||
abstract launchUri(uri: string, options?: any): void;
|
abstract launchUri(uri: string, options?: any): void;
|
||||||
|
|||||||
Reference in New Issue
Block a user