mirror of
https://github.com/bitwarden/browser
synced 2026-01-31 00:33:33 +00:00
This reverts commit 05ca57d538.
This commit is contained in:
@@ -140,11 +140,6 @@ describe("BrowserPopupUtils", () => {
|
||||
|
||||
describe("openPopout", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(BrowserApi, "getPlatformInfo").mockResolvedValueOnce({
|
||||
os: "linux",
|
||||
arch: "x86-64",
|
||||
nacl_arch: "x86-64",
|
||||
});
|
||||
jest.spyOn(BrowserApi, "getWindow").mockResolvedValueOnce({
|
||||
id: 1,
|
||||
left: 100,
|
||||
@@ -155,8 +150,6 @@ describe("BrowserPopupUtils", () => {
|
||||
width: PopupWidthOptions.default,
|
||||
});
|
||||
jest.spyOn(BrowserApi, "createWindow").mockImplementation();
|
||||
jest.spyOn(BrowserApi, "updateWindowProperties").mockImplementation();
|
||||
jest.spyOn(BrowserApi, "getPlatformInfo").mockImplementation();
|
||||
});
|
||||
|
||||
it("creates a window with the default window options", async () => {
|
||||
@@ -274,63 +267,6 @@ describe("BrowserPopupUtils", () => {
|
||||
url: `chrome-extension://id/${url}?uilocation=popout&singleActionPopout=123`,
|
||||
});
|
||||
});
|
||||
|
||||
it("exits fullscreen and focuses popout window if the current window is fullscreen and platform is mac", async () => {
|
||||
const url = "popup/index.html";
|
||||
jest.spyOn(BrowserPopupUtils as any, "isSingleActionPopoutOpen").mockResolvedValueOnce(false);
|
||||
jest.spyOn(BrowserApi, "getPlatformInfo").mockReset().mockResolvedValueOnce({
|
||||
os: "mac",
|
||||
arch: "x86-64",
|
||||
nacl_arch: "x86-64",
|
||||
});
|
||||
jest.spyOn(BrowserApi, "getWindow").mockReset().mockResolvedValueOnce({
|
||||
id: 1,
|
||||
left: 100,
|
||||
top: 100,
|
||||
focused: false,
|
||||
alwaysOnTop: false,
|
||||
incognito: false,
|
||||
width: PopupWidthOptions.default,
|
||||
state: "fullscreen",
|
||||
});
|
||||
jest
|
||||
.spyOn(BrowserApi, "createWindow")
|
||||
.mockResolvedValueOnce({ id: 2 } as chrome.windows.Window);
|
||||
|
||||
await BrowserPopupUtils.openPopout(url, { senderWindowId: 1 });
|
||||
expect(BrowserApi.updateWindowProperties).toHaveBeenCalledWith(1, {
|
||||
state: "maximized",
|
||||
});
|
||||
expect(BrowserApi.updateWindowProperties).toHaveBeenCalledWith(2, {
|
||||
focused: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("doesnt exit fullscreen if the platform is not mac", async () => {
|
||||
const url = "popup/index.html";
|
||||
jest.spyOn(BrowserPopupUtils as any, "isSingleActionPopoutOpen").mockResolvedValueOnce(false);
|
||||
jest.spyOn(BrowserApi, "getPlatformInfo").mockReset().mockResolvedValueOnce({
|
||||
os: "win",
|
||||
arch: "x86-64",
|
||||
nacl_arch: "x86-64",
|
||||
});
|
||||
jest.spyOn(BrowserApi, "getWindow").mockResolvedValueOnce({
|
||||
id: 1,
|
||||
left: 100,
|
||||
top: 100,
|
||||
focused: false,
|
||||
alwaysOnTop: false,
|
||||
incognito: false,
|
||||
width: PopupWidthOptions.default,
|
||||
state: "fullscreen",
|
||||
});
|
||||
|
||||
await BrowserPopupUtils.openPopout(url);
|
||||
|
||||
expect(BrowserApi.updateWindowProperties).not.toHaveBeenCalledWith(1, {
|
||||
state: "maximized",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("openCurrentPagePopout", () => {
|
||||
|
||||
@@ -168,29 +168,8 @@ export default class BrowserPopupUtils {
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const platform = await BrowserApi.getPlatformInfo();
|
||||
const isMacOS = platform.os === "mac";
|
||||
const isFullscreen = senderWindow.state === "fullscreen";
|
||||
const isFullscreenAndMacOS = isFullscreen && isMacOS;
|
||||
//macOS specific handling for improved UX when sender in fullscreen aka green button;
|
||||
if (isFullscreenAndMacOS) {
|
||||
await BrowserApi.updateWindowProperties(senderWindow.id, {
|
||||
state: "maximized",
|
||||
});
|
||||
|
||||
//wait for macOS animation to finish
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
}
|
||||
|
||||
const newWindow = await BrowserApi.createWindow(popoutWindowOptions);
|
||||
|
||||
if (isFullscreenAndMacOS) {
|
||||
await BrowserApi.updateWindowProperties(newWindow.id, {
|
||||
focused: true,
|
||||
});
|
||||
}
|
||||
|
||||
return newWindow;
|
||||
return await BrowserApi.createWindow(popoutWindowOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user