From 43ba6256dc78f3481bdb3000483780b95e598c79 Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Tue, 16 Apr 2024 14:58:09 -0500 Subject: [PATCH] [PM-5189] Refactoring implementation --- .../abstractions/overlay.background.ts | 8 +-- .../background/overlay.background.spec.ts | 43 ++++++++-------- .../autofill/background/overlay.background.ts | 51 +++++++++++-------- .../autofill-overlay-iframe.service.ts | 2 +- .../autofill-overlay-iframe.service.spec.ts | 2 +- .../autofill-overlay-iframe.service.ts | 2 +- .../autofill-overlay-content.service.spec.ts | 38 ++++++++------ .../autofill-overlay-content.service.ts | 10 ++-- apps/browser/src/autofill/utils/index.spec.ts | 2 +- 9 files changed, 87 insertions(+), 71 deletions(-) diff --git a/apps/browser/src/autofill/background/abstractions/overlay.background.ts b/apps/browser/src/autofill/background/abstractions/overlay.background.ts index ab458c0860d..a0c224972d2 100644 --- a/apps/browser/src/autofill/background/abstractions/overlay.background.ts +++ b/apps/browser/src/autofill/background/abstractions/overlay.background.ts @@ -97,13 +97,13 @@ type OverlayBackgroundExtensionMessageHandlers = { autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void; autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; getAutofillOverlayVisibility: () => void; - checkAutofillOverlayFocused: () => void; + checkAutofillOverlayMenuFocused: () => void; focusAutofillOverlayList: () => void; - updateAutofillOverlayPosition: ({ + updateAutofillOverlayMenuPosition: ({ message, sender, }: BackgroundOnMessageHandlerParams) => Promise; - updateAutofillOverlayHidden: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; + updateAutofillOverlayMenuHidden: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; updateFocusedFieldData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; updateIsFieldCurrentlyFocused: ({ message }: BackgroundMessageParam) => void; checkIsFieldCurrentlyFocused: () => boolean; @@ -111,7 +111,7 @@ type OverlayBackgroundExtensionMessageHandlers = { checkIsFieldCurrentlyFilling: () => boolean; checkIsInlineMenuButtonVisible: ({ sender }: BackgroundSenderParam) => void; checkIsInlineMenuListVisible: ({ sender }: BackgroundSenderParam) => void; - checkIsInlineMenuCiphersPopulated: ({ sender }: BackgroundSenderParam) => void; + checkIsOverlayLoginCiphersPopulated: ({ sender }: BackgroundSenderParam) => void; updateSubFrameData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; rebuildSubFrameOffsets: ({ sender }: BackgroundSenderParam) => void; collectPageDetailsResponse: ({ message, sender }: BackgroundOnMessageHandlerParams) => void; diff --git a/apps/browser/src/autofill/background/overlay.background.spec.ts b/apps/browser/src/autofill/background/overlay.background.spec.ts index f45fec778c7..2e4bd724223 100644 --- a/apps/browser/src/autofill/background/overlay.background.spec.ts +++ b/apps/browser/src/autofill/background/overlay.background.spec.ts @@ -668,13 +668,13 @@ describe("OverlayBackground", () => { }); }); - describe("checkAutofillOverlayFocused message handler", () => { + describe("checkAutofillOverlayMenuFocused message handler", () => { beforeEach(async () => { await initOverlayElementPorts(); }); it("will check if the overlay list is focused if the list port is open", () => { - sendMockExtensionMessage({ command: "checkAutofillOverlayFocused" }); + sendMockExtensionMessage({ command: "checkAutofillOverlayMenuFocused" }); expect(listPortSpy.postMessage).toHaveBeenCalledWith({ command: "checkAutofillOverlayListFocused", @@ -687,7 +687,7 @@ describe("OverlayBackground", () => { it("will check if the overlay button is focused if the list port is not open", () => { overlayBackground["overlayListPort"] = undefined; - sendMockExtensionMessage({ command: "checkAutofillOverlayFocused" }); + sendMockExtensionMessage({ command: "checkAutofillOverlayMenuFocused" }); expect(buttonPortSpy.postMessage).toHaveBeenCalledWith({ command: "checkAutofillOverlayButtonFocused", @@ -713,7 +713,7 @@ describe("OverlayBackground", () => { }); }); - describe("updateAutofillOverlayPosition message handler", () => { + describe("updateAutofillOverlayMenuPosition message handler", () => { let sender: MockProxy; beforeEach(async () => { @@ -731,7 +731,7 @@ describe("OverlayBackground", () => { }); it("ignores updating the position if the overlay element type is not provided", () => { - sendMockExtensionMessage({ command: "updateAutofillOverlayPosition" }, sender); + sendMockExtensionMessage({ command: "updateAutofillOverlayMenuPosition" }, sender); expect(listPortSpy.postMessage).not.toHaveBeenCalledWith({ command: "updateIframePosition", @@ -749,7 +749,7 @@ describe("OverlayBackground", () => { sendMockExtensionMessage( { - command: "updateAutofillOverlayPosition", + command: "updateAutofillOverlayMenuPosition", overlayElement: AutofillOverlayElement.Button, }, sender, @@ -770,7 +770,7 @@ describe("OverlayBackground", () => { sendMockExtensionMessage( { - command: "updateAutofillOverlayPosition", + command: "updateAutofillOverlayMenuPosition", overlayElement: AutofillOverlayElement.Button, }, sender, @@ -791,7 +791,7 @@ describe("OverlayBackground", () => { sendMockExtensionMessage( { - command: "updateAutofillOverlayPosition", + command: "updateAutofillOverlayMenuPosition", overlayElement: AutofillOverlayElement.Button, }, sender, @@ -812,7 +812,7 @@ describe("OverlayBackground", () => { sendMockExtensionMessage( { - command: "updateAutofillOverlayPosition", + command: "updateAutofillOverlayMenuPosition", overlayElement: AutofillOverlayElement.Button, }, sender, @@ -831,7 +831,7 @@ describe("OverlayBackground", () => { sendMockExtensionMessage( { - command: "updateAutofillOverlayPosition", + command: "updateAutofillOverlayMenuPosition", overlayElement: AutofillOverlayElement.List, }, sender, @@ -845,24 +845,24 @@ describe("OverlayBackground", () => { }); }); - describe("updateOverlayHidden", () => { + describe("updateOverlayMenuHidden", () => { beforeEach(async () => { await initOverlayElementPorts(); }); it("sets the `display` CSS value on the overlay button and list", () => { - const message = { command: "updateAutofillOverlayHidden", isOverlayHidden: true }; + const message = { command: "updateAutofillOverlayMenuHidden", isOverlayHidden: true }; sendMockExtensionMessage(message); expect(buttonPortSpy.postMessage).toHaveBeenCalledWith({ - command: "updateOverlayHidden", + command: "updateOverlayMenuHidden", styles: { display: "none", }, }); expect(listPortSpy.postMessage).toHaveBeenCalledWith({ - command: "updateOverlayHidden", + command: "updateOverlayMenuHidden", styles: { display: "none", }, @@ -870,19 +870,22 @@ describe("OverlayBackground", () => { }); it("sets the `opacity` CSS value on the overlay button and list", () => { - const message = { command: "updateAutofillOverlayHidden", setTransparentOverlay: true }; + const message = { + command: "updateAutofillOverlayMenuHidden", + setTransparentOverlay: true, + }; sendMockExtensionMessage(message); expect(buttonPortSpy.postMessage).toHaveBeenCalledWith({ - command: "updateOverlayHidden", + command: "updateOverlayMenuHidden", styles: { display: "block", opacity: 0, }, }); expect(listPortSpy.postMessage).toHaveBeenCalledWith({ - command: "updateOverlayHidden", + command: "updateOverlayMenuHidden", styles: { display: "block", opacity: 0, @@ -1033,7 +1036,7 @@ describe("OverlayBackground", () => { describe("handlePortOnConnect", () => { beforeEach(() => { - jest.spyOn(overlayBackground as any, "updateOverlayPosition").mockImplementation(); + jest.spyOn(overlayBackground as any, "updateOverlayMenuPosition").mockImplementation(); jest.spyOn(overlayBackground as any, "getAuthStatus").mockImplementation(); jest.spyOn(overlayBackground as any, "getTranslations").mockImplementation(); jest.spyOn(overlayBackground as any, "getOverlayCipherData").mockImplementation(); @@ -1063,7 +1066,7 @@ describe("OverlayBackground", () => { expect(chrome.runtime.getURL).toHaveBeenCalledWith("overlay/list.css"); expect(overlayBackground["getTranslations"]).toHaveBeenCalled(); expect(overlayBackground["getOverlayCipherData"]).toHaveBeenCalled(); - expect(overlayBackground["updateOverlayPosition"]).toHaveBeenCalledWith( + expect(overlayBackground["updateOverlayMenuPosition"]).toHaveBeenCalledWith( { overlayElement: AutofillOverlayElement.List }, listPortSpy.sender, ); @@ -1083,7 +1086,7 @@ describe("OverlayBackground", () => { expect(overlayBackground["getAuthStatus"]).toHaveBeenCalled(); expect(chrome.runtime.getURL).toHaveBeenCalledWith("overlay/button.css"); expect(overlayBackground["getTranslations"]).toHaveBeenCalled(); - expect(overlayBackground["updateOverlayPosition"]).toHaveBeenCalledWith( + expect(overlayBackground["updateOverlayMenuPosition"]).toHaveBeenCalledWith( { overlayElement: AutofillOverlayElement.Button }, buttonPortSpy.sender, ); diff --git a/apps/browser/src/autofill/background/overlay.background.ts b/apps/browser/src/autofill/background/overlay.background.ts index b3808982bbc..274de48243a 100644 --- a/apps/browser/src/autofill/background/overlay.background.ts +++ b/apps/browser/src/autofill/background/overlay.background.ts @@ -53,7 +53,7 @@ class OverlayBackground implements OverlayBackgroundInterface { private overlayLoginCiphers: Map = new Map(); private pageDetailsForTab: PageDetailsForTab = {}; private subFrameOffsetsForTab: SubFrameOffsetsForTab = {}; - private updateOverlayPositionAfterSubFrameRebuildTimeout: number | NodeJS.Timeout; + private updateOverlayMenuPositionTimeout: number | NodeJS.Timeout; private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut; private overlayButtonPort: chrome.runtime.Port; private overlayListPort: chrome.runtime.Port; @@ -69,26 +69,27 @@ class OverlayBackground implements OverlayBackgroundInterface { autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message), autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender), getAutofillOverlayVisibility: () => this.getOverlayVisibility(), - checkAutofillOverlayFocused: () => this.checkOverlayFocused(), + checkAutofillOverlayMenuFocused: () => this.checkOverlayMenuFocused(), focusAutofillOverlayList: () => this.focusOverlayList(), - updateAutofillOverlayPosition: ({ message, sender }) => - this.updateOverlayPosition(message, sender), - updateAutofillOverlayHidden: ({ message, sender }) => this.updateOverlayHidden(message, sender), + updateAutofillOverlayMenuPosition: ({ message, sender }) => + this.updateOverlayMenuPosition(message, sender), + updateAutofillOverlayMenuHidden: ({ message, sender }) => + this.updateOverlayMenuHidden(message, sender), updateFocusedFieldData: ({ message, sender }) => this.setFocusedFieldData(message, sender), - collectPageDetailsResponse: ({ message, sender }) => this.storePageDetails(message, sender), - unlockCompleted: ({ message }) => this.unlockCompleted(message), - addEditCipherSubmitted: () => this.updateOverlayCiphers(), - deletedCipher: () => this.updateOverlayCiphers(), updateIsFieldCurrentlyFocused: ({ message }) => this.updateIsFieldCurrentlyFocused(message), checkIsFieldCurrentlyFocused: () => this.checkIsFieldCurrentlyFocused(), updateIsFieldCurrentlyFilling: ({ message }) => this.updateIsFieldCurrentlyFilling(message), checkIsFieldCurrentlyFilling: () => this.checkIsFieldCurrentlyFilling(), checkIsInlineMenuButtonVisible: ({ sender }) => this.checkIsInlineMenuButtonVisible(sender), checkIsInlineMenuListVisible: ({ sender }) => this.checkIsInlineMenuListVisible(sender), - checkIsInlineMenuCiphersPopulated: ({ sender }) => - this.checkIsInlineMenuCiphersPopulated(sender), + checkIsOverlayLoginCiphersPopulated: ({ sender }) => + this.checkIsOverlayLoginCiphersPopulated(sender), updateSubFrameData: ({ message, sender }) => this.updateSubFrameData(message, sender), rebuildSubFrameOffsets: ({ sender }) => this.rebuildSubFrameOffsets(sender), + collectPageDetailsResponse: ({ message, sender }) => this.storePageDetails(message, sender), + unlockCompleted: ({ message }) => this.unlockCompleted(message), + addEditCipherSubmitted: () => this.updateOverlayCiphers(), + deletedCipher: () => this.updateOverlayCiphers(), }; private readonly overlayButtonPortMessageHandlers: OverlayButtonPortMessageHandlers = { overlayButtonClicked: ({ port }) => this.handleOverlayButtonClicked(port), @@ -316,8 +317,8 @@ class OverlayBackground implements OverlayBackgroundInterface { return; } - if (this.updateOverlayPositionAfterSubFrameRebuildTimeout) { - clearTimeout(this.updateOverlayPositionAfterSubFrameRebuildTimeout); + if (this.updateOverlayMenuPositionTimeout) { + clearTimeout(this.updateOverlayMenuPositionTimeout); } const frameTabs = Array.from(subFrameOffsetsForTab.keys()); @@ -330,10 +331,16 @@ class OverlayBackground implements OverlayBackgroundInterface { await this.buildSubFrameOffsets(sender.tab, frameId, sender.url); } - this.updateOverlayPositionAfterSubFrameRebuildTimeout = setTimeout(() => { + this.updateOverlayMenuPositionTimeout = setTimeout(() => { if (this.isFieldCurrentlyFocused) { - void this.updateOverlayPosition({ overlayElement: AutofillOverlayElement.List }, sender); - void this.updateOverlayPosition({ overlayElement: AutofillOverlayElement.Button }, sender); + void this.updateOverlayMenuPosition( + { overlayElement: AutofillOverlayElement.List }, + sender, + ); + void this.updateOverlayMenuPosition( + { overlayElement: AutofillOverlayElement.Button }, + sender, + ); } }, 650); } @@ -378,7 +385,7 @@ class OverlayBackground implements OverlayBackgroundInterface { * Checks if the overlay is focused. Will check the overlay list * if it is open, otherwise it will check the overlay button. */ - private checkOverlayFocused() { + private checkOverlayMenuFocused() { if (this.overlayListPort) { this.checkOverlayListFocused(); @@ -473,7 +480,7 @@ class OverlayBackground implements OverlayBackgroundInterface { * @param overlayElement - The overlay element to update, either the list or button * @param sender - The sender of the extension message */ - private async updateOverlayPosition( + private async updateOverlayMenuPosition( { overlayElement }: { overlayElement?: string }, sender: chrome.runtime.MessageSender, ) { @@ -584,7 +591,7 @@ class OverlayBackground implements OverlayBackgroundInterface { * @param display - The display property of the overlay, either "block" or "none" * @param sender - The sender of the extension message */ - private updateOverlayHidden( + private updateOverlayMenuHidden( { isOverlayHidden, setTransparentOverlay }: OverlayBackgroundExtensionMessage, sender: chrome.runtime.MessageSender, ) { @@ -596,7 +603,7 @@ class OverlayBackground implements OverlayBackgroundInterface { styles = { ...styles, opacity }; } - const portMessage = { command: "updateOverlayHidden", styles }; + const portMessage = { command: "updateOverlayMenuHidden", styles }; void BrowserApi.tabSendMessage( sender.tab, @@ -880,7 +887,7 @@ class OverlayBackground implements OverlayBackgroundInterface { ); } - private checkIsInlineMenuCiphersPopulated(sender: chrome.runtime.MessageSender) { + private checkIsOverlayLoginCiphersPopulated(sender: chrome.runtime.MessageSender) { return sender.tab.id === this.focusedFieldData.tabId && this.overlayLoginCiphers.size > 0; } @@ -976,7 +983,7 @@ class OverlayBackground implements OverlayBackgroundInterface { ? AutofillOverlayPort.ListMessageConnector : AutofillOverlayPort.ButtonMessageConnector, }); - void this.updateOverlayPosition( + void this.updateOverlayMenuPosition( { overlayElement: isOverlayListPort ? AutofillOverlayElement.List diff --git a/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-iframe.service.ts b/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-iframe.service.ts index ac2d28afbf2..5e7945bc2db 100644 --- a/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-iframe.service.ts +++ b/apps/browser/src/autofill/overlay/abstractions/autofill-overlay-iframe.service.ts @@ -19,7 +19,7 @@ type BackgroundPortMessageHandlers = { initAutofillOverlayButton: ({ message }: AutofillOverlayIframeExtensionMessageParam) => void; initAutofillOverlayList: ({ message }: AutofillOverlayIframeExtensionMessageParam) => void; updateIframePosition: ({ message }: AutofillOverlayIframeExtensionMessageParam) => void; - updateOverlayHidden: ({ message }: AutofillOverlayIframeExtensionMessageParam) => void; + updateOverlayMenuHidden: ({ message }: AutofillOverlayIframeExtensionMessageParam) => void; updateOverlayPageColorScheme: () => void; }; diff --git a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts index 98de33bfcdc..af70149931a 100644 --- a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts +++ b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.spec.ts @@ -395,7 +395,7 @@ describe("AutofillOverlayIframeService", () => { it("updates the visibility of the iframe", () => { sendPortMessage(portSpy, { - command: "updateOverlayHidden", + command: "updateOverlayMenuHidden", styles: { display: "none" }, }); diff --git a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts index 62bc788dde1..c92892551ce 100644 --- a/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts +++ b/apps/browser/src/autofill/overlay/iframe-content/autofill-overlay-iframe.service.ts @@ -45,7 +45,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf initAutofillOverlayButton: ({ message }) => this.initAutofillOverlay(message), initAutofillOverlayList: ({ message }) => this.initAutofillOverlay(message), updateIframePosition: ({ message }) => this.updateIframePosition(message.styles), - updateOverlayHidden: ({ message }) => this.updateElementStyles(this.iframe, message.styles), + updateOverlayMenuHidden: ({ message }) => this.updateElementStyles(this.iframe, message.styles), updateOverlayPageColorScheme: () => this.updateOverlayPageColorScheme(), }; 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 3bc61bf3fb7..f1d3cdf2194 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 @@ -305,7 +305,7 @@ describe("AutofillOverlayContentService", () => { it("sends a message to the background to check if the overlay is focused", () => { autofillFieldElement.dispatchEvent(new Event("blur")); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("checkAutofillOverlayFocused"); + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("checkAutofillOverlayMenuFocused"); }); }); @@ -704,9 +704,12 @@ describe("AutofillOverlayContentService", () => { autofillFieldElement.dispatchEvent(new Event("focus")); await flushPromises(); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { - overlayElement: AutofillOverlayElement.Button, - }); + expect(sendExtensionMessageSpy).toHaveBeenCalledWith( + "updateAutofillOverlayMenuPosition", + { + overlayElement: AutofillOverlayElement.Button, + }, + ); }); }); }); @@ -816,10 +819,10 @@ describe("AutofillOverlayContentService", () => { autofillOverlayContentService["openAutofillOverlayMenu"](); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.Button, }); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.List, }); }); @@ -830,12 +833,15 @@ describe("AutofillOverlayContentService", () => { autofillOverlayContentService["openAutofillOverlayMenu"]({ isOpeningFullOverlay: false }); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.Button, }); - expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("updateAutofillOverlayPosition", { - overlayElement: AutofillOverlayElement.List, - }); + expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith( + "updateAutofillOverlayMenuPosition", + { + overlayElement: AutofillOverlayElement.List, + }, + ); }); it("overrides the onButtonClick visibility setting to open both overlay elements", () => { @@ -844,10 +850,10 @@ describe("AutofillOverlayContentService", () => { autofillOverlayContentService["openAutofillOverlayMenu"]({ isOpeningFullOverlay: true }); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.Button, }); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.List, }); }); @@ -1098,7 +1104,7 @@ describe("AutofillOverlayContentService", () => { globalThis.dispatchEvent(new Event(EVENTS.SCROLL)); await flushPromises(); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayHidden", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuHidden", { isOverlayHidden: true, setTransparentOverlay: false, }); @@ -1126,7 +1132,7 @@ describe("AutofillOverlayContentService", () => { await flushPromises(); jest.advanceTimersByTime(800); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayHidden", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuHidden", { isOverlayHidden: false, setTransparentOverlay: true, }); @@ -1157,10 +1163,10 @@ describe("AutofillOverlayContentService", () => { jest.advanceTimersByTime(800); await flushPromises(); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.Button, }); - expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", { + expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.List, }); expect(clearUserInteractionEventTimeoutSpy).toHaveBeenCalled(); 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 7ddde088d93..95f16f41f65 100644 --- a/apps/browser/src/autofill/services/autofill-overlay-content.service.ts +++ b/apps/browser/src/autofill/services/autofill-overlay-content.service.ts @@ -290,7 +290,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte void this.sendExtensionMessage("updateIsFieldCurrentlyFocused", { isFieldCurrentlyFocused: false, }); - void this.sendExtensionMessage("checkAutofillOverlayFocused"); + void this.sendExtensionMessage("checkAutofillOverlayMenuFocused"); }; /** @@ -547,7 +547,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte * Updates the position of the overlay button. */ private updateOverlayButtonPosition() { - void this.sendExtensionMessage("updateAutofillOverlayPosition", { + void this.sendExtensionMessage("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.Button, }); } @@ -556,7 +556,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte * Updates the position of the overlay list. */ private updateOverlayListPosition() { - void this.sendExtensionMessage("updateAutofillOverlayPosition", { + void this.sendExtensionMessage("updateAutofillOverlayMenuPosition", { overlayElement: AutofillOverlayElement.List, }); } @@ -568,7 +568,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte * @param setTransparentOverlay - Indicates if the overlay is closing. */ private toggleOverlayHidden(isHidden: boolean, setTransparentOverlay: boolean = false) { - void this.sendExtensionMessage("updateAutofillOverlayHidden", { + void this.sendExtensionMessage("updateAutofillOverlayMenuHidden", { isOverlayHidden: isHidden, setTransparentOverlay, }); @@ -1002,7 +1002,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte } private async isInlineMenuCiphersPopulated() { - return (await this.sendExtensionMessage("checkIsInlineMenuCiphersPopulated")) === true; + return (await this.sendExtensionMessage("checkIsOverlayLoginCiphersPopulated")) === true; } /** diff --git a/apps/browser/src/autofill/utils/index.spec.ts b/apps/browser/src/autofill/utils/index.spec.ts index 5dbb514b3f9..a81c7efb0a4 100644 --- a/apps/browser/src/autofill/utils/index.spec.ts +++ b/apps/browser/src/autofill/utils/index.spec.ts @@ -38,7 +38,7 @@ describe("generateRandomCustomElementName", () => { describe("sendExtensionMessage", () => { it("sends a message to the extention", () => { - const extensionMessageResponse = sendExtensionMessage("updateAutofillOverlayHidden", { + const extensionMessageResponse = sendExtensionMessage("updateAutofillOverlayMenuHidden", { display: "none", }); jest.spyOn(chrome.runtime, "sendMessage");