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;
|
closeAutofillInlineMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
|
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
|
||||||
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
getInlineMenuVisibilitySetting: () => void;
|
getAutofillInlineMenuVisibility: () => void;
|
||||||
checkAutofillInlineMenuFocused: () => void;
|
checkAutofillInlineMenuFocused: () => void;
|
||||||
focusAutofillInlineMenuList: () => void;
|
focusAutofillInlineMenuList: () => void;
|
||||||
updateAutofillInlineMenuPosition: ({
|
updateAutofillInlineMenuPosition: ({
|
||||||
|
|||||||
@@ -638,7 +638,7 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getInlineMenuVisibilitySetting message handler", () => {
|
describe("getAutofillInlineMenuVisibility message handler", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest
|
jest
|
||||||
.spyOn(overlayBackground as any, "getInlineMenuVisibility")
|
.spyOn(overlayBackground as any, "getInlineMenuVisibility")
|
||||||
@@ -646,7 +646,7 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("will set the overlayVisibility property", async () => {
|
it("will set the overlayVisibility property", async () => {
|
||||||
sendMockExtensionMessage({ command: "getInlineMenuVisibilitySetting" });
|
sendMockExtensionMessage({ command: "getAutofillInlineMenuVisibility" });
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(await overlayBackground["getInlineMenuVisibility"]()).toBe(
|
expect(await overlayBackground["getInlineMenuVisibility"]()).toBe(
|
||||||
@@ -658,7 +658,7 @@ describe("OverlayBackground", () => {
|
|||||||
const sendMessageSpy = jest.fn();
|
const sendMessageSpy = jest.fn();
|
||||||
|
|
||||||
sendMockExtensionMessage(
|
sendMockExtensionMessage(
|
||||||
{ command: "getInlineMenuVisibilitySetting" },
|
{ command: "getAutofillInlineMenuVisibility" },
|
||||||
undefined,
|
undefined,
|
||||||
sendMessageSpy,
|
sendMessageSpy,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message),
|
closeAutofillInlineMenu: ({ message, sender }) => this.closeInlineMenu(sender, message),
|
||||||
autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message),
|
autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message),
|
||||||
autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender),
|
autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender),
|
||||||
getInlineMenuVisibilitySetting: () => this.getInlineMenuVisibility(),
|
getAutofillInlineMenuVisibility: () => this.getInlineMenuVisibility(),
|
||||||
checkAutofillInlineMenuFocused: () => this.checkInlineMenuFocused(),
|
checkAutofillInlineMenuFocused: () => this.checkInlineMenuFocused(),
|
||||||
focusAutofillInlineMenuList: () => this.focusInlineMenuList(),
|
focusAutofillInlineMenuList: () => this.focusInlineMenuList(),
|
||||||
updateAutofillInlineMenuPosition: ({ message, sender }) =>
|
updateAutofillInlineMenuPosition: ({ message, sender }) =>
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getInlineMenuVisibilitySetting");
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("getAutofillInlineMenuVisibility");
|
||||||
expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual(
|
expect(autofillOverlayContentService["inlineMenuVisibility"]).toEqual(
|
||||||
AutofillOverlayVisibility.OnFieldFocus,
|
AutofillOverlayVisibility.OnFieldFocus,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.inlineMenuVisibility) {
|
if (!this.inlineMenuVisibility) {
|
||||||
await this.getInlineMenuVisibilitySetting();
|
await this.getAutofillInlineMenuVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setupFormFieldElementEventListeners(formFieldElement);
|
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
|
* If the setting is not found, a default value of OnFieldFocus will be used
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private async getInlineMenuVisibilitySetting() {
|
private async getAutofillInlineMenuVisibility() {
|
||||||
const overlayVisibility = await this.sendExtensionMessage("getInlineMenuVisibilitySetting");
|
const overlayVisibility = await this.sendExtensionMessage("getAutofillInlineMenuVisibility");
|
||||||
this.inlineMenuVisibility = overlayVisibility || AutofillOverlayVisibility.OnFieldFocus;
|
this.inlineMenuVisibility = overlayVisibility || AutofillOverlayVisibility.OnFieldFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user