diff --git a/apps/browser/src/autofill/background/abstractions/overlay.background.ts b/apps/browser/src/autofill/background/abstractions/overlay.background.ts index addb020404d..03c6b8d7b4a 100644 --- a/apps/browser/src/autofill/background/abstractions/overlay.background.ts +++ b/apps/browser/src/autofill/background/abstractions/overlay.background.ts @@ -98,7 +98,7 @@ type OverlayBackgroundExtensionMessageHandlers = { autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; getInlineMenuVisibilitySetting: () => void; checkAutofillOverlayMenuFocused: () => void; - focusAutofillOverlayList: () => void; + focusAutofillOverlayMenuList: () => void; updateAutofillOverlayMenuPosition: ({ message, sender, diff --git a/apps/browser/src/autofill/background/overlay.background.spec.ts b/apps/browser/src/autofill/background/overlay.background.spec.ts index af7755a8903..dbcb59c09b9 100644 --- a/apps/browser/src/autofill/background/overlay.background.spec.ts +++ b/apps/browser/src/autofill/background/overlay.background.spec.ts @@ -698,8 +698,8 @@ describe("OverlayBackground", () => { }); }); - describe("focusAutofillOverlayList message handler", () => { - it("will send a `focusOverlayList` message to the overlay list port", async () => { + describe("focusAutofillOverlayMenuList message handler", () => { + it("will send a `focusOverlayMenuList` message to the overlay list port", async () => { await initOverlayElementPorts({ initList: true, initButton: false, @@ -707,9 +707,9 @@ describe("OverlayBackground", () => { initListMessageConnectorSpy: false, }); - sendMockExtensionMessage({ command: "focusAutofillOverlayList" }); + sendMockExtensionMessage({ command: "focusAutofillOverlayMenuList" }); - expect(listPortSpy.postMessage).toHaveBeenCalledWith({ command: "focusOverlayList" }); + expect(listPortSpy.postMessage).toHaveBeenCalledWith({ command: "focusOverlayMenuList" }); }); }); diff --git a/apps/browser/src/autofill/background/overlay.background.ts b/apps/browser/src/autofill/background/overlay.background.ts index 24433a3adf5..30f8fd2658e 100644 --- a/apps/browser/src/autofill/background/overlay.background.ts +++ b/apps/browser/src/autofill/background/overlay.background.ts @@ -70,7 +70,7 @@ class OverlayBackground implements OverlayBackgroundInterface { autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender), getInlineMenuVisibilitySetting: () => this.getInlineMenuVisibility(), checkAutofillOverlayMenuFocused: () => this.checkOverlayMenuFocused(), - focusAutofillOverlayList: () => this.focusOverlayList(), + focusAutofillOverlayMenuList: () => this.focusOverlayMenuList(), updateAutofillOverlayMenuPosition: ({ message, sender }) => this.updateOverlayMenuPosition(message, sender), updateAutofillOverlayMenuHidden: ({ message, sender }) => @@ -736,8 +736,8 @@ class OverlayBackground implements OverlayBackgroundInterface { /** * Facilitates redirecting focus to the overlay list. */ - private focusOverlayList() { - this.overlayListPort?.postMessage({ command: "focusOverlayList" }); + private focusOverlayMenuList() { + this.overlayListPort?.postMessage({ command: "focusOverlayMenuList" }); } /** diff --git a/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-list.ts b/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-list.ts index e7f4e544dfe..bced26c2188 100644 --- a/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-list.ts +++ b/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-list.ts @@ -22,7 +22,7 @@ type OverlayListWindowMessageHandlers = { initAutofillOverlayList: ({ message }: { message: InitAutofillOverlayListMessage }) => void; checkAutofillOverlayListFocused: () => void; updateOverlayListCiphers: ({ message }: { message: UpdateOverlayListCiphersMessage }) => void; - focusOverlayList: () => void; + focusOverlayMenuList: () => void; }; export { diff --git a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.spec.ts b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.spec.ts index bc87721b966..fe8847a10cc 100644 --- a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.spec.ts +++ b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.spec.ts @@ -330,7 +330,7 @@ describe("AutofillOverlayList", () => { "setAttribute", ); - postWindowMessage({ command: "focusOverlayList" }); + postWindowMessage({ command: "focusOverlayMenuList" }); expect(overlayContainerSetAttributeSpy).toHaveBeenCalledWith("role", "dialog"); expect(overlayContainerSetAttributeSpy).toHaveBeenCalledWith("aria-modal", "true"); @@ -348,7 +348,7 @@ describe("AutofillOverlayList", () => { autofillOverlayList["overlayListContainer"].querySelector("#unlock-button"); jest.spyOn(unlockButton as HTMLElement, "focus"); - postWindowMessage({ command: "focusOverlayList" }); + postWindowMessage({ command: "focusOverlayMenuList" }); expect((unlockButton as HTMLElement).focus).toBeCalled(); }); @@ -360,7 +360,7 @@ describe("AutofillOverlayList", () => { autofillOverlayList["overlayListContainer"].querySelector("#new-item-button"); jest.spyOn(newItemButton as HTMLElement, "focus"); - postWindowMessage({ command: "focusOverlayList" }); + postWindowMessage({ command: "focusOverlayMenuList" }); expect((newItemButton as HTMLElement).focus).toBeCalled(); }); @@ -371,7 +371,7 @@ describe("AutofillOverlayList", () => { autofillOverlayList["overlayListContainer"].querySelector(".fill-cipher-button"); jest.spyOn(firstCipherItem as HTMLElement, "focus"); - postWindowMessage({ command: "focusOverlayList" }); + postWindowMessage({ command: "focusOverlayMenuList" }); expect((firstCipherItem as HTMLElement).focus).toBeCalled(); }); diff --git a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts index 9838c75d2fb..ac5a7e3ef08 100644 --- a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts +++ b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts @@ -26,7 +26,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement { initAutofillOverlayList: ({ message }) => this.initAutofillOverlayList(message), checkAutofillOverlayListFocused: () => this.checkOverlayListFocused(), updateOverlayListCiphers: ({ message }) => this.updateListItems(message.ciphers), - focusOverlayList: () => this.focusOverlayList(), + focusOverlayMenuList: () => this.focusOverlayMenuList(), }; constructor() { @@ -486,7 +486,7 @@ class AutofillOverlayList extends AutofillOverlayPageElement { * determined by the presence of the unlock button, new item button, or * the first cipher button. */ - private focusOverlayList() { + private focusOverlayMenuList() { this.overlayListContainer.setAttribute("role", "dialog"); this.overlayListContainer.setAttribute("aria-modal", "true"); diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts index 1f540377d6b..2741d8ee8e0 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.spec.ts @@ -375,11 +375,11 @@ describe("AutofillOverlayContentService", () => { expect(updateMostRecentlyFocusedFieldSpy).toHaveBeenCalledWith(autofillFieldElement); expect(openAutofillOverlaySpy).toHaveBeenCalledWith({ isOpeningFullOverlay: true }); - expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("focusAutofillOverlayList"); + expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("focusAutofillOverlayMenuList"); jest.advanceTimersByTime(150); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("focusAutofillOverlayList"); + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("focusAutofillOverlayMenuList"); }); it("focuses the overlay list when the `ArrowDown` key is pressed", async () => { @@ -390,7 +390,7 @@ describe("AutofillOverlayContentService", () => { autofillFieldElement.dispatchEvent(new KeyboardEvent("keyup", { code: "ArrowDown" })); await flushPromises(); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("focusAutofillOverlayList"); + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("focusAutofillOverlayMenuList"); }); }); diff --git a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts index 19fe8ed6b7d..fa29c622ce1 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -319,7 +319,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte event.preventDefault(); event.stopPropagation(); - void this.focusOverlayList(); + void this.focusOverlayMenuList(); } }; @@ -328,15 +328,15 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte * the overlay will be opened and the list will be focused after a short delay. Ensures * that the overlay list is focused when the user presses the down arrow key. */ - private async focusOverlayList() { + private async focusOverlayMenuList() { if (this.mostRecentlyFocusedField && !(await this.isInlineMenuListVisible())) { await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField); this.openAutofillOverlayMenu({ isOpeningFullOverlay: true }); - setTimeout(() => this.sendExtensionMessage("focusAutofillOverlayList"), 125); + setTimeout(() => this.sendExtensionMessage("focusAutofillOverlayMenuList"), 125); return; } - void this.sendExtensionMessage("focusAutofillOverlayList"); + void this.sendExtensionMessage("focusAutofillOverlayMenuList"); } /** diff --git a/apps/browser/src/autofill/services/autofill.service.spec.ts b/apps/browser/src/autofill/services/autofill.service.spec.ts index 66cc4ac4d2c..93e772b708b 100644 --- a/apps/browser/src/autofill/services/autofill.service.spec.ts +++ b/apps/browser/src/autofill/services/autofill.service.spec.ts @@ -1,13 +1,14 @@ -import { mock, mockReset } from "jest-mock-extended"; -import { of } from "rxjs"; +import { mock, MockProxy, mockReset } from "jest-mock-extended"; +import { BehaviorSubject, of } from "rxjs"; import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service"; import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; -import { AutofillSettingsService } from "@bitwarden/common/autofill/services/autofill-settings.service"; +import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; import { DefaultDomainSettingsService, DomainSettingsService, } from "@bitwarden/common/autofill/services/domain-settings.service"; +import { InlineMenuVisibilitySetting } from "@bitwarden/common/autofill/types"; import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service"; import { EventType } from "@bitwarden/common/enums"; import { UriMatchStrategy } from "@bitwarden/common/models/domain/domain-service"; @@ -62,7 +63,7 @@ const mockEquivalentDomains = [ describe("AutofillService", () => { let autofillService: AutofillService; const cipherService = mock(); - const autofillSettingsService = mock(); + let autofillSettingsService: MockProxy; const mockUserId = Utils.newGuid() as UserId; const accountService: FakeAccountService = mockAccountServiceWith(mockUserId); const fakeStateProvider: FakeStateProvider = new FakeStateProvider(accountService); @@ -72,8 +73,12 @@ describe("AutofillService", () => { const logService = mock(); const userVerificationService = mock(); const billingAccountProfileStateService = mock(); + let inlineMenuVisibilitySettingMock$!: BehaviorSubject; beforeEach(() => { + inlineMenuVisibilitySettingMock$ = new BehaviorSubject(AutofillOverlayVisibility.OnFieldFocus); + autofillSettingsService = mock(); + autofillSettingsService.inlineMenuVisibility$ = inlineMenuVisibilitySettingMock$; autofillService = new AutofillService( cipherService, autofillSettingsService,