mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
[PM-5189] Refactoring implementation
This commit is contained in:
@@ -96,7 +96,7 @@ type OverlayBackgroundExtensionMessageHandlers = {
|
||||
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
|
||||
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||
getInlineMenuVisibilitySetting: () => void;
|
||||
getAutofillInlineMenuVisibility: () => void;
|
||||
checkAutofillInlineMenuFocused: () => void;
|
||||
focusAutofillInlineMenuList: () => void;
|
||||
updateAutofillInlineMenuPosition: ({
|
||||
|
||||
@@ -638,7 +638,7 @@ describe("OverlayBackground", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getInlineMenuVisibilitySetting message handler", () => {
|
||||
describe("getAutofillInlineMenuVisibility message handler", () => {
|
||||
beforeEach(() => {
|
||||
jest
|
||||
.spyOn(overlayBackground as any, "getInlineMenuVisibility")
|
||||
@@ -646,7 +646,7 @@ describe("OverlayBackground", () => {
|
||||
});
|
||||
|
||||
it("will set the overlayVisibility property", async () => {
|
||||
sendMockExtensionMessage({ command: "getInlineMenuVisibilitySetting" });
|
||||
sendMockExtensionMessage({ command: "getAutofillInlineMenuVisibility" });
|
||||
await flushPromises();
|
||||
|
||||
expect(await overlayBackground["getInlineMenuVisibility"]()).toBe(
|
||||
@@ -658,7 +658,7 @@ describe("OverlayBackground", () => {
|
||||
const sendMessageSpy = jest.fn();
|
||||
|
||||
sendMockExtensionMessage(
|
||||
{ command: "getInlineMenuVisibilitySetting" },
|
||||
{ command: "getAutofillInlineMenuVisibility" },
|
||||
undefined,
|
||||
sendMessageSpy,
|
||||
);
|
||||
|
||||
@@ -68,7 +68,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
||||
closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message),
|
||||
autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message),
|
||||
autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender),
|
||||
getInlineMenuVisibilitySetting: () => this.getInlineMenuVisibility(),
|
||||
getAutofillInlineMenuVisibility: () => this.getInlineMenuVisibility(),
|
||||
checkAutofillInlineMenuFocused: () => this.checkInlineMenuFocused(),
|
||||
focusAutofillInlineMenuList: () => this.focusInlineMenuList(),
|
||||
updateAutofillInlineMenuPosition: ({ message, sender }) =>
|
||||
|
||||
@@ -230,7 +230,7 @@ describe("AutofillOverlayContentService", () => {
|
||||
autofillFieldData,
|
||||
);
|
||||
|
||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getInlineMenuVisibilitySetting");
|
||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getAutofillInlineMenuVisibility");
|
||||
expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual(
|
||||
AutofillOverlayVisibility.OnFieldFocus,
|
||||
);
|
||||
|
||||
@@ -94,7 +94,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
||||
}
|
||||
|
||||
if (!this.inlineMenuVisibility) {
|
||||
await this.getInlineMenuVisibilitySetting();
|
||||
await this.getAutofillInlineMenuVisibility();
|
||||
}
|
||||
|
||||
this.setupFormFieldElementEventListeners(formFieldElement);
|
||||
@@ -730,8 +730,8 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
||||
* If the setting is not found, a default value of OnFieldFocus will be used
|
||||
* @private
|
||||
*/
|
||||
private async getInlineMenuVisibilitySetting() {
|
||||
const overlayVisibility = await this.sendExtensionMessage("getInlineMenuVisibilitySetting");
|
||||
private async getAutofillInlineMenuVisibility() {
|
||||
const overlayVisibility = await this.sendExtensionMessage("getAutofillInlineMenuVisibility");
|
||||
this.inlineMenuVisibility = overlayVisibility || AutofillOverlayVisibility.OnFieldFocus;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user