1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-31 08:43:54 +00:00

remove safari from guard & disable forced popout in vault import

This commit is contained in:
John Harrington
2025-12-11 15:53:15 -07:00
parent b4a1d9f437
commit 6619d4486a
6 changed files with 4 additions and 64 deletions

View File

@@ -84,40 +84,15 @@ describe("filePickerPopoutGuard", () => {
inSidebarSpy.mockReturnValue(false);
});
it("should open popout and block navigation when not in popout", async () => {
it("should allow navigation without popout requirement", async () => {
const guard = filePickerPopoutGuard();
const result = await TestBed.runInInjectionContext(() => guard(mockRoute, mockState));
expect(getDeviceSpy).toHaveBeenCalledWith(window);
expect(inPopoutSpy).toHaveBeenCalledWith(window);
expect(openPopoutSpy).toHaveBeenCalledWith("popup/index.html#/add-send?type=1");
expect(closePopupSpy).toHaveBeenCalledWith(window);
expect(result).toBe(false);
});
it("should allow navigation when already in popout", async () => {
inPopoutSpy.mockReturnValue(true);
const guard = filePickerPopoutGuard();
const result = await TestBed.runInInjectionContext(() => guard(mockRoute, mockState));
expect(openPopoutSpy).not.toHaveBeenCalled();
expect(closePopupSpy).not.toHaveBeenCalled();
expect(result).toBe(true);
});
it("should not allow sidebar bypass (Safari doesn't support sidebar)", async () => {
inSidebarSpy.mockReturnValue(true);
inPopoutSpy.mockReturnValue(false);
const guard = filePickerPopoutGuard();
const result = await TestBed.runInInjectionContext(() => guard(mockRoute, mockState));
// Safari requires popout, sidebar is not sufficient
expect(openPopoutSpy).toHaveBeenCalledWith("popup/index.html#/add-send?type=1");
expect(closePopupSpy).toHaveBeenCalledWith(window);
expect(result).toBe(false);
});
});
describe("Chromium browsers on Linux", () => {

View File

@@ -11,9 +11,9 @@ import { DeviceType } from "@bitwarden/common/enums";
*
* Browser-specific requirements:
* - Firefox: Requires sidebar OR popout (crashes with file picker in popup: https://bugzilla.mozilla.org/show_bug.cgi?id=1292701)
* - Safari: Requires popout only
* - Chromium on Linux/Mac: Requires sidebar OR popout
* - Chromium on Windows: No special requirement
* - Safari: No special requirement
*
* @returns CanActivateFn that opens popout and blocks navigation when file picker access is needed
*/
@@ -33,11 +33,6 @@ export function filePickerPopoutGuard(): CanActivateFn {
needsPopout = true;
}
// Safari: needs popout only (sidebar not available)
if (deviceType === DeviceType.SafariExtension && !inPopout) {
needsPopout = true;
}
// Chromium on Linux: needs sidebar OR popout for file picker access
// All Chromium-based browsers (Chrome, Edge, Opera, Vivaldi) on Linux
const isChromiumBased = [

View File

@@ -30,8 +30,6 @@ import { DialogService } from "@bitwarden/components";
import { StateProvider } from "@bitwarden/state";
import { DecryptionFailureDialogComponent } from "@bitwarden/vault";
import { BrowserApi } from "../../../../platform/browser/browser-api";
import BrowserPopupUtils from "../../../../platform/browser/browser-popup-utils";
import { IntroCarouselService } from "../../services/intro-carousel.service";
import { VaultPopupAutofillService } from "../../services/vault-popup-autofill.service";
import { VaultPopupCopyButtonsService } from "../../services/vault-popup-copy-buttons.service";
@@ -141,8 +139,6 @@ jest
jest
.spyOn(DecryptionFailureDialogComponent, "open")
.mockImplementation((_: DialogService, _params: any) => mockDialogRef as any);
jest.spyOn(BrowserApi, "isPopupOpen").mockResolvedValue(false);
jest.spyOn(BrowserPopupUtils, "openCurrentPagePopout").mockResolvedValue();
describe("VaultV2Component", () => {
let component: VaultV2Component;
@@ -379,29 +375,13 @@ describe("VaultV2Component", () => {
expect(PremiumUpgradeDialogComponent.open).toHaveBeenCalledTimes(1);
});
it("navigateToImport navigates and opens popout if popup is open", fakeAsync(async () => {
(BrowserApi.isPopupOpen as jest.Mock).mockResolvedValueOnce(true);
it("navigateToImport navigates to import route", fakeAsync(async () => {
const ngRouter = TestBed.inject(Router);
jest.spyOn(ngRouter, "navigate").mockResolvedValue(true as any);
await component["navigateToImport"]();
expect(ngRouter.navigate).toHaveBeenCalledWith(["/import"]);
expect(BrowserPopupUtils.openCurrentPagePopout).toHaveBeenCalled();
}));
it("navigateToImport does not popout when popup is not open", fakeAsync(async () => {
(BrowserApi.isPopupOpen as jest.Mock).mockResolvedValueOnce(false);
const ngRouter = TestBed.inject(Router);
jest.spyOn(ngRouter, "navigate").mockResolvedValue(true as any);
await component["navigateToImport"]();
expect(ngRouter.navigate).toHaveBeenCalledWith(["/import"]);
expect(BrowserPopupUtils.openCurrentPagePopout).not.toHaveBeenCalled();
}));
it("ngOnInit dismisses intro carousel and opens decryption dialog for non-deleted failures", fakeAsync(() => {

View File

@@ -45,8 +45,6 @@ import {
import { DecryptionFailureDialogComponent } from "@bitwarden/vault";
import { CurrentAccountComponent } from "../../../../auth/popup/account-switching/current-account.component";
import { BrowserApi } from "../../../../platform/browser/browser-api";
import BrowserPopupUtils from "../../../../platform/browser/browser-popup-utils";
import { PopOutComponent } from "../../../../platform/popup/components/pop-out.component";
import { PopupHeaderComponent } from "../../../../platform/popup/layout/popup-header.component";
import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page.component";
@@ -313,9 +311,6 @@ export class VaultV2Component implements OnInit, AfterViewInit, OnDestroy {
async navigateToImport() {
await this.router.navigate(["/import"]);
if (await BrowserApi.isPopupOpen()) {
await BrowserPopupUtils.openCurrentPagePopout(window);
}
}
async dismissVaultNudgeSpotlight(type: NudgeType) {

View File

@@ -25,7 +25,7 @@
1
</span>
</div>
<i slot="end" class="bwi bwi-popout" aria-hidden="true"></i>
<i slot="end" class="bwi bwi-angle-right" aria-hidden="true"></i>
</button>
</bit-item>
<bit-item>

View File

@@ -15,8 +15,6 @@ import { PremiumUpgradePromptService } from "@bitwarden/common/vault/abstraction
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { BadgeComponent, ItemModule, ToastOptions, ToastService } from "@bitwarden/components";
import { BrowserApi } from "../../../platform/browser/browser-api";
import BrowserPopupUtils from "../../../platform/browser/browser-popup-utils";
import { PopOutComponent } from "../../../platform/popup/components/pop-out.component";
import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-header.component";
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
@@ -88,9 +86,6 @@ export class VaultSettingsV2Component implements OnInit, OnDestroy {
async import() {
await this.router.navigate(["/import"]);
if (await BrowserApi.isPopupOpen()) {
await BrowserPopupUtils.openCurrentPagePopout(window);
}
}
async sync() {