diff --git a/apps/browser/src/autofill/content/autofill-init.spec.ts b/apps/browser/src/autofill/content/autofill-init.spec.ts index 570f5f09378..3479c7fdf2d 100644 --- a/apps/browser/src/autofill/content/autofill-init.spec.ts +++ b/apps/browser/src/autofill/content/autofill-init.spec.ts @@ -156,21 +156,19 @@ describe("AutofillInit", () => { }); it("triggers extension message handlers from the AutofillOverlayContentService", () => { - autofillOverlayContentService.extensionMessageHandlers.messageHandler = jest.fn(); + autofillOverlayContentService.messageHandlers.messageHandler = jest.fn(); sendMockExtensionMessage({ command: "messageHandler" }, sender, sendResponse); - expect( - autofillOverlayContentService.extensionMessageHandlers.messageHandler, - ).toHaveBeenCalled(); + expect(autofillOverlayContentService.messageHandlers.messageHandler).toHaveBeenCalled(); }); it("triggers extension message handlers from the AutofillInlineMenuContentService", () => { - inlineMenuElements.extensionMessageHandlers.messageHandler = jest.fn(); + inlineMenuElements.messageHandlers.messageHandler = jest.fn(); sendMockExtensionMessage({ command: "messageHandler" }, sender, sendResponse); - expect(inlineMenuElements.extensionMessageHandlers.messageHandler).toHaveBeenCalled(); + expect(inlineMenuElements.messageHandlers.messageHandler).toHaveBeenCalled(); }); describe("collectPageDetails", () => { diff --git a/apps/browser/src/autofill/content/autofill-init.ts b/apps/browser/src/autofill/content/autofill-init.ts index 1382676f1af..3c11378016c 100644 --- a/apps/browser/src/autofill/content/autofill-init.ts +++ b/apps/browser/src/autofill/content/autofill-init.ts @@ -196,12 +196,12 @@ class AutofillInit implements AutofillInitInterface { * @param command - The extension message command. */ private getExtensionMessageHandler(command: string): CallableFunction | undefined { - if (this.autofillOverlayContentService?.extensionMessageHandlers?.[command]) { - return this.autofillOverlayContentService.extensionMessageHandlers[command]; + if (this.autofillOverlayContentService?.messageHandlers?.[command]) { + return this.autofillOverlayContentService.messageHandlers[command]; } - if (this.autofillInlineMenuContentService?.extensionMessageHandlers?.[command]) { - return this.autofillInlineMenuContentService.extensionMessageHandlers[command]; + if (this.autofillInlineMenuContentService?.messageHandlers?.[command]) { + return this.autofillInlineMenuContentService.messageHandlers[command]; } return this.extensionMessageHandlers[command]; diff --git a/apps/browser/src/autofill/overlay/inline-menu/abstractions/autofill-inline-menu-content.service.ts b/apps/browser/src/autofill/overlay/inline-menu/abstractions/autofill-inline-menu-content.service.ts index d6579dfe1aa..21a4879c47b 100644 --- a/apps/browser/src/autofill/overlay/inline-menu/abstractions/autofill-inline-menu-content.service.ts +++ b/apps/browser/src/autofill/overlay/inline-menu/abstractions/autofill-inline-menu-content.service.ts @@ -10,7 +10,7 @@ export type InlineMenuExtensionMessageHandlers = { }; export interface AutofillInlineMenuContentService { - extensionMessageHandlers: InlineMenuExtensionMessageHandlers; + messageHandlers: InlineMenuExtensionMessageHandlers; isElementInlineMenu(element: HTMLElement): boolean; destroy(): void; } diff --git a/apps/browser/src/autofill/overlay/inline-menu/content/autofill-inline-menu-content.service.ts b/apps/browser/src/autofill/overlay/inline-menu/content/autofill-inline-menu-content.service.ts index 2fe6d812a1d..95e6109ae5d 100644 --- a/apps/browser/src/autofill/overlay/inline-menu/content/autofill-inline-menu-content.service.ts +++ b/apps/browser/src/autofill/overlay/inline-menu/content/autofill-inline-menu-content.service.ts @@ -34,7 +34,7 @@ export class AutofillInlineMenuContentService implements AutofillInlineMenuConte display: "block", zIndex: "2147483647", }; - private readonly _extensionMessageHandlers: InlineMenuExtensionMessageHandlers = { + private readonly extensionMessageHandlers: InlineMenuExtensionMessageHandlers = { closeAutofillInlineMenu: ({ message }) => this.removeInlineMenu(message), appendAutofillInlineMenuToDom: ({ message }) => this.appendInlineMenuElements(message), toggleAutofillInlineMenuHidden: ({ message }) => this.toggleInlineMenuHidden(message), @@ -46,8 +46,8 @@ export class AutofillInlineMenuContentService implements AutofillInlineMenuConte this.setupMutationObserver(); } - get extensionMessageHandlers() { - return this._extensionMessageHandlers; + get messageHandlers() { + return this.extensionMessageHandlers; } isElementInlineMenu(element: HTMLElement) { diff --git a/apps/browser/src/autofill/services/abstractions/autofill-overlay-content.service.ts b/apps/browser/src/autofill/services/abstractions/autofill-overlay-content.service.ts index a995a81c127..82ab82039b6 100644 --- a/apps/browser/src/autofill/services/abstractions/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/abstractions/autofill-overlay-content.service.ts @@ -28,7 +28,7 @@ export type AutofillOverlayContentExtensionMessageHandlers = { export interface AutofillOverlayContentService { pageDetailsUpdateRequired: boolean; - extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers; + messageHandlers: AutofillOverlayContentExtensionMessageHandlers; init(): void; setupAutofillInlineMenuListenerOnField( autofillFieldElement: ElementWithOpId, 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 7719458b82f..746e6b59360 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -40,7 +40,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ private recalculateSubFrameOffsetsTimeout: number | NodeJS.Timeout; private autofillFieldKeywordsMap: WeakMap = new WeakMap(); private eventHandlersMemo: { [key: string]: EventListener } = {}; - readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = { + private readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = { openAutofillInlineMenu: ({ message }) => this.openAutofillInlineMenu(message), addNewVaultItemFromOverlay: () => this.addNewVaultItem(), blurMostRecentlyFocusedField: () => this.blurMostRecentlyFocusedField(), @@ -70,6 +70,14 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ this.setupGlobalEventListeners(); } + /** + * Getter used to access the extension message handlers associated + * with the autofill overlay content service. + */ + get messageHandlers(): AutofillOverlayContentExtensionMessageHandlers { + return this.extensionMessageHandlers; + } + /** * Sets up the autofill inline menu listener on the form field element. This method is called * during the page details collection process.