1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-01 23:01:28 +01:00

[PM-5189] Updating message references to better reflect intent

This commit is contained in:
Cesar Gonzalez 2024-04-16 13:17:22 -05:00
parent 141dfbaef4
commit a21c83b3d6
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
10 changed files with 80 additions and 80 deletions

View File

@ -92,8 +92,8 @@ type BackgroundOnMessageHandlerParams = BackgroundMessageParam & BackgroundSende
type OverlayBackgroundExtensionMessageHandlers = {
[key: string]: CallableFunction;
openAutofillOverlay: () => void;
closeAutofillOverlay: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
openAutofillOverlayMenu: () => void;
closeAutofillOverlayMenu: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
autofillOverlayElementClosed: ({ message }: BackgroundMessageParam) => void;
autofillOverlayAddNewVaultItem: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
getAutofillOverlayVisibility: () => void;
@ -131,7 +131,7 @@ type PortOnMessageHandlerParams = PortMessageParam & PortConnectionParam;
type OverlayButtonPortMessageHandlers = {
[key: string]: CallableFunction;
overlayButtonClicked: ({ port }: PortConnectionParam) => void;
closeAutofillOverlay: ({ port }: PortConnectionParam) => void;
closeAutofillOverlayMenu: ({ port }: PortConnectionParam) => void;
forceCloseAutofillOverlay: ({ port }: PortConnectionParam) => void;
overlayPageBlurred: () => void;
redirectOverlayFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;

View File

@ -536,7 +536,7 @@ describe("OverlayBackground", () => {
it("will return a response if the message handler returns a response", async () => {
const message = {
command: "openAutofillOverlay",
command: "openAutofillOverlayMenu",
};
const sender = mock<chrome.runtime.MessageSender>({ tab: { id: 1 } });
const sendResponse = jest.fn();
@ -552,17 +552,17 @@ describe("OverlayBackground", () => {
});
describe("extension message handlers", () => {
describe("openAutofillOverlay message handler", () => {
describe("openAutofillOverlayMenu message handler", () => {
it("opens the autofill overlay by sending a message to the current tab", async () => {
const sender = mock<chrome.runtime.MessageSender>({ tab: { id: 1 } });
jest.spyOn(BrowserApi, "getTabFromCurrentWindowId").mockResolvedValueOnce(sender.tab);
jest.spyOn(BrowserApi, "tabSendMessage").mockImplementation();
sendMockExtensionMessage({ command: "openAutofillOverlay" });
sendMockExtensionMessage({ command: "openAutofillOverlayMenu" });
await flushPromises();
expect(BrowserApi.tabSendMessage).not.toHaveBeenCalledWith(sender.tab, {
command: "openAutofillOverlay",
command: "openAutofillOverlayMenu",
isFocusingFieldElement: false,
isOpeningFullOverlay: false,
authStatus: AuthenticationStatus.Unlocked,
@ -981,7 +981,7 @@ describe("OverlayBackground", () => {
const message = {
command: "unlockCompleted",
data: {
commandToRetry: { message: { command: "openAutofillOverlay" } },
commandToRetry: { message: { command: "openAutofillOverlayMenu" } },
},
};
jest.spyOn(BrowserApi, "getTabFromCurrentWindowId").mockResolvedValueOnce(sender.tab);
@ -993,7 +993,7 @@ describe("OverlayBackground", () => {
expect(BrowserApi.tabSendMessage).toHaveBeenCalledWith(
sender.tab,
{
command: "openAutofillOverlay",
command: "openAutofillOverlayMenu",
isFocusingFieldElement: true,
isOpeningFullOverlay: false,
authStatus: AuthenticationStatus.Unlocked,
@ -1144,23 +1144,23 @@ describe("OverlayBackground", () => {
});
it("opens the autofill overlay if the auth status is unlocked", () => {
jest.spyOn(overlayBackground as any, "openOverlay").mockImplementation();
jest.spyOn(overlayBackground as any, "openOverlayMenu").mockImplementation();
sendPortMessage(buttonMessageConnectorPortSpy, {
command: "overlayButtonClicked",
portKey,
});
expect(overlayBackground["openOverlay"]).toHaveBeenCalled();
expect(overlayBackground["openOverlayMenu"]).toHaveBeenCalled();
});
// TODO: The tests for `closeAutofillOverlay` and `forceCloseAutofillOverlay` need to be fleshed out
describe("closeAutofillOverlay", () => {
// TODO: The tests for `closeAutofillOverlayMenu` and `forceCloseAutofillOverlay` need to be fleshed out
describe("closeAutofillOverlayMenu", () => {
it("sends a `closeOverlay` message to the sender tab", () => {
jest.spyOn(BrowserApi, "tabSendMessage");
sendPortMessage(buttonMessageConnectorPortSpy, {
command: "closeAutofillOverlay",
command: "closeAutofillOverlayMenu",
portKey,
});
@ -1281,14 +1281,14 @@ describe("OverlayBackground", () => {
describe("unlockVault", () => {
it("closes the autofill overlay and opens the unlock popout", async () => {
jest.spyOn(overlayBackground as any, "closeOverlay").mockImplementation();
jest.spyOn(overlayBackground as any, "closeOverlayMenu").mockImplementation();
jest.spyOn(overlayBackground as any, "openUnlockPopout").mockImplementation();
jest.spyOn(BrowserApi, "tabSendMessageData").mockImplementation();
sendPortMessage(listMessageConnectorPortSpy, { command: "unlockVault", portKey });
await flushPromises();
expect(overlayBackground["closeOverlay"]).toHaveBeenCalledWith(
expect(overlayBackground["closeOverlayMenu"]).toHaveBeenCalledWith(
listMessageConnectorPortSpy.sender,
);
expect(BrowserApi.tabSendMessageData).toHaveBeenCalledWith(
@ -1296,7 +1296,7 @@ describe("OverlayBackground", () => {
"addToLockedVaultPendingNotifications",
{
commandToRetry: {
message: { command: "openAutofillOverlay" },
message: { command: "openAutofillOverlayMenu" },
sender: listMessageConnectorPortSpy.sender,
},
target: "overlay.background",

View File

@ -64,8 +64,8 @@ class OverlayBackground implements OverlayBackgroundInterface {
private overlayPageTranslations: Record<string, string>;
private iconsServerUrl: string;
private readonly extensionMessageHandlers: OverlayBackgroundExtensionMessageHandlers = {
openAutofillOverlay: () => this.openOverlay(false),
closeAutofillOverlay: ({ message, sender }) => this.closeOverlay(sender, message),
openAutofillOverlayMenu: () => this.openOverlayMenu(false),
closeAutofillOverlayMenu: ({ message, sender }) => this.closeOverlayMenu(sender, message),
autofillOverlayElementClosed: ({ message }) => this.overlayElementClosed(message),
autofillOverlayAddNewVaultItem: ({ message, sender }) => this.addNewVaultItem(message, sender),
getAutofillOverlayVisibility: () => this.getOverlayVisibility(),
@ -92,9 +92,9 @@ class OverlayBackground implements OverlayBackgroundInterface {
};
private readonly overlayButtonPortMessageHandlers: OverlayButtonPortMessageHandlers = {
overlayButtonClicked: ({ port }) => this.handleOverlayButtonClicked(port),
closeAutofillOverlay: ({ port }) => this.closeOverlay(port.sender),
closeAutofillOverlayMenu: ({ port }) => this.closeOverlayMenu(port.sender),
forceCloseAutofillOverlay: ({ port }) =>
this.closeOverlay(port.sender, { forceCloseOverlay: true }),
this.closeOverlayMenu(port.sender, { forceCloseOverlay: true }),
overlayPageBlurred: () => this.checkOverlayListFocused(),
redirectOverlayFocusOut: ({ message, port }) => this.redirectOverlayFocusOut(message, port),
updateOverlayPageColorScheme: () => this.updateButtonPageColorScheme(),
@ -102,7 +102,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
private readonly overlayListPortMessageHandlers: OverlayListPortMessageHandlers = {
checkAutofillOverlayButtonFocused: () => this.checkOverlayButtonFocused(),
forceCloseAutofillOverlay: ({ port }) =>
this.closeOverlay(port.sender, { forceCloseOverlay: true }),
this.closeOverlayMenu(port.sender, { forceCloseOverlay: true }),
overlayPageBlurred: () => this.checkOverlayButtonFocused(),
unlockVault: ({ port }) => this.unlockVault(port),
fillSelectedListItem: ({ message, port }) => this.fillSelectedOverlayListItem(message, port),
@ -409,7 +409,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
* @param forceCloseOverlay - Identifies whether the overlay should be forced closed
* @param overlayElement - The overlay element to close, either the list or button
*/
private closeOverlay(
private closeOverlayMenu(
sender: chrome.runtime.MessageSender,
{
forceCloseOverlay,
@ -614,13 +614,13 @@ class OverlayBackground implements OverlayBackgroundInterface {
* @param isFocusingFieldElement - Identifies whether the field element should be focused when the overlay is opened
* @param isOpeningFullOverlay - Identifies whether the full overlay should be forced open regardless of other states
*/
private async openOverlay(isFocusingFieldElement = false, isOpeningFullOverlay = false) {
private async openOverlayMenu(isFocusingFieldElement = false, isOpeningFullOverlay = false) {
const currentTab = await BrowserApi.getTabFromCurrentWindowId();
await BrowserApi.tabSendMessage(
currentTab,
{
command: "openAutofillOverlay",
command: "openAutofillOverlayMenu",
isFocusingFieldElement,
isOpeningFullOverlay,
authStatus: await this.getAuthStatus(),
@ -681,7 +681,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
return;
}
void this.openOverlay(false, true);
void this.openOverlayMenu(false, true);
}
/**
@ -692,9 +692,9 @@ class OverlayBackground implements OverlayBackgroundInterface {
private async unlockVault(port: chrome.runtime.Port) {
const { sender } = port;
this.closeOverlay(port.sender);
this.closeOverlayMenu(port.sender);
const retryMessage: LockedVaultPendingNotificationsData = {
commandToRetry: { message: { command: "openAutofillOverlay" }, sender },
commandToRetry: { message: { command: "openAutofillOverlayMenu" }, sender },
target: "overlay.background",
};
await BrowserApi.tabSendMessageData(
@ -742,8 +742,8 @@ class OverlayBackground implements OverlayBackgroundInterface {
private async unlockCompleted(message: OverlayBackgroundExtensionMessage) {
await this.getAuthStatus();
if (message.data?.commandToRetry?.message?.command === "openAutofillOverlay") {
await this.openOverlay(true);
if (message.data?.commandToRetry?.message?.command === "openAutofillOverlayMenu") {
await this.openOverlayMenu(true);
}
}

View File

@ -459,7 +459,7 @@ describe("AutofillOverlayIframeService", () => {
autofillOverlayIframeService["iframe"].src = "http://malicious-site.com";
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceClose: true,
});
});
@ -471,7 +471,7 @@ describe("AutofillOverlayIframeService", () => {
autofillOverlayIframeService["iframe"].src = "http://malicious-site.com";
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceClose: true,
});
});

View File

@ -324,7 +324,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
* mutation observer is triggered excessively.
*/
private forceCloseAutofillOverlay() {
void this.sendExtensionMessage("closeAutofillOverlay", { forceClose: true });
void this.sendExtensionMessage("closeAutofillOverlayMenu", { forceClose: true });
}
/**

View File

@ -74,7 +74,7 @@ describe("AutofillOverlayButton", () => {
await flushPromises();
expect(globalThis.parent.postMessage).not.toHaveBeenCalledWith({
command: "closeAutofillOverlay",
command: "closeAutofillOverlayMenu",
});
});
@ -85,7 +85,7 @@ describe("AutofillOverlayButton", () => {
await flushPromises();
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
{ command: "closeAutofillOverlay", portKey },
{ command: "closeAutofillOverlayMenu", portKey },
"*",
);
});

View File

@ -115,7 +115,7 @@ class AutofillOverlayButton extends AutofillOverlayPageElement {
return;
}
this.postMessageToParent({ command: "closeAutofillOverlay" });
this.postMessageToParent({ command: "closeAutofillOverlayMenu" });
}
}

View File

@ -13,7 +13,7 @@ export type OpenAutofillOverlayOptions = {
export type AutofillOverlayContentExtensionMessageHandlers = {
[key: string]: CallableFunction;
openAutofillOverlay: ({ message }: AutofillExtensionMessageParam) => void;
openAutofillOverlayMenu: ({ message }: AutofillExtensionMessageParam) => void;
addNewVaultItemFromOverlay: () => void;
blurMostRecentOverlayField: () => void;
bgUnlockPopoutOpened: () => void;

View File

@ -321,7 +321,7 @@ describe("AutofillOverlayContentService", () => {
it("closes the autofill overlay when the `Escape` key is pressed", () => {
autofillFieldElement.dispatchEvent(new KeyboardEvent("keyup", { code: "Escape" }));
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
});
@ -364,7 +364,7 @@ describe("AutofillOverlayContentService", () => {
);
const openAutofillOverlaySpy = jest.spyOn(
autofillOverlayContentService as any,
"openAutofillOverlay",
"openAutofillOverlayMenu",
);
jest
.spyOn(autofillOverlayContentService as any, "isInlineMenuListVisible")
@ -454,7 +454,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("input"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
@ -475,14 +475,14 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("input"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
});
it("opens the autofill overlay if the form field is empty", async () => {
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlay");
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlayMenu");
(autofillFieldElement as HTMLInputElement).value = "";
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
@ -492,12 +492,12 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("input"));
await flushPromises();
expect(autofillOverlayContentService["openAutofillOverlay"]).toHaveBeenCalled();
expect(autofillOverlayContentService["openAutofillOverlayMenu"]).toHaveBeenCalled();
});
it("opens the autofill overlay if the form field is empty and the user is authed", async () => {
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(true);
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlay");
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlayMenu");
(autofillFieldElement as HTMLInputElement).value = "";
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
@ -507,7 +507,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("input"));
await flushPromises();
expect(autofillOverlayContentService["openAutofillOverlay"]).toHaveBeenCalled();
expect(autofillOverlayContentService["openAutofillOverlayMenu"]).toHaveBeenCalled();
});
it("opens the autofill overlay if the form field is empty and the overlay ciphers are not populated", async () => {
@ -515,7 +515,7 @@ describe("AutofillOverlayContentService", () => {
jest
.spyOn(autofillOverlayContentService as any, "isInlineMenuCiphersPopulated")
.mockResolvedValue(false);
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlay");
jest.spyOn(autofillOverlayContentService as any, "openAutofillOverlayMenu");
(autofillFieldElement as HTMLInputElement).value = "";
await autofillOverlayContentService.setupAutofillOverlayListenerOnField(
@ -525,7 +525,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("input"));
await flushPromises();
expect(autofillOverlayContentService["openAutofillOverlay"]).toHaveBeenCalled();
expect(autofillOverlayContentService["openAutofillOverlayMenu"]).toHaveBeenCalled();
});
});
@ -633,7 +633,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("focus"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
@ -652,7 +652,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("focus"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
@ -670,7 +670,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("focus"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlay");
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlayMenu");
});
it("opens the autofill overlay if the overlay ciphers are not populated and the user is authed", async () => {
@ -686,7 +686,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldElement.dispatchEvent(new Event("focus"));
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlay");
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlayMenu");
});
it("updates the overlay button position if the focus event is not opening the overlay", async () => {
@ -723,7 +723,7 @@ describe("AutofillOverlayContentService", () => {
autofillFieldData,
);
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlay");
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("openAutofillOverlayMenu");
expect(autofillOverlayContentService["mostRecentlyFocusedField"]).toEqual(
autofillFieldElement,
);
@ -743,7 +743,7 @@ describe("AutofillOverlayContentService", () => {
});
});
describe("openAutofillOverlay", () => {
describe("openAutofillOverlayMenu", () => {
let autofillFieldElement: ElementWithOpId<FormFieldElement>;
beforeEach(() => {
@ -764,7 +764,7 @@ describe("AutofillOverlayContentService", () => {
it("skips opening the overlay if a field has not been recently focused", () => {
autofillOverlayContentService["mostRecentlyFocusedField"] = undefined;
autofillOverlayContentService["openAutofillOverlay"]();
autofillOverlayContentService["openAutofillOverlayMenu"]();
expect(sendExtensionMessageSpy).not.toHaveBeenCalled();
});
@ -780,7 +780,7 @@ describe("AutofillOverlayContentService", () => {
"focusMostRecentOverlayField",
);
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
autofillOverlayContentService["openAutofillOverlayMenu"]({ isFocusingFieldElement: true });
expect(focusMostRecentOverlayFieldSpy).toHaveBeenCalled();
});
@ -796,7 +796,7 @@ describe("AutofillOverlayContentService", () => {
"focusMostRecentOverlayField",
);
autofillOverlayContentService["openAutofillOverlay"]({ isFocusingFieldElement: true });
autofillOverlayContentService["openAutofillOverlayMenu"]({ isFocusingFieldElement: true });
expect(focusMostRecentOverlayFieldSpy).not.toHaveBeenCalled();
});
@ -804,7 +804,7 @@ describe("AutofillOverlayContentService", () => {
it("stores the user's auth status", () => {
autofillOverlayContentService["authStatus"] = undefined;
autofillOverlayContentService["openAutofillOverlay"]({
autofillOverlayContentService["openAutofillOverlayMenu"]({
authStatus: AuthenticationStatus.Unlocked,
});
@ -814,7 +814,7 @@ describe("AutofillOverlayContentService", () => {
it("opens both autofill overlay elements", () => {
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
autofillOverlayContentService["openAutofillOverlay"]();
autofillOverlayContentService["openAutofillOverlayMenu"]();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", {
overlayElement: AutofillOverlayElement.Button,
@ -828,7 +828,7 @@ describe("AutofillOverlayContentService", () => {
autofillOverlayContentService["autofillOverlayVisibility"] =
AutofillOverlayVisibility.OnButtonClick;
autofillOverlayContentService["openAutofillOverlay"]({ isOpeningFullOverlay: false });
autofillOverlayContentService["openAutofillOverlayMenu"]({ isOpeningFullOverlay: false });
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", {
overlayElement: AutofillOverlayElement.Button,
@ -842,7 +842,7 @@ describe("AutofillOverlayContentService", () => {
autofillOverlayContentService["autofillOverlayVisibility"] =
AutofillOverlayVisibility.OnButtonClick;
autofillOverlayContentService["openAutofillOverlay"]({ isOpeningFullOverlay: true });
autofillOverlayContentService["openAutofillOverlayMenu"]({ isOpeningFullOverlay: true });
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillOverlayPosition", {
overlayElement: AutofillOverlayElement.Button,
@ -856,7 +856,7 @@ describe("AutofillOverlayContentService", () => {
jest.spyOn(autofillOverlayContentService as any, "sendExtensionMessage");
autofillOverlayContentService.pageDetailsUpdateRequired = true;
autofillOverlayContentService["openAutofillOverlay"]();
autofillOverlayContentService["openAutofillOverlayMenu"]();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("bgCollectPageDetails", {
sender: "autofillOverlayContentService",
@ -1022,7 +1022,7 @@ describe("AutofillOverlayContentService", () => {
await autofillOverlayContentService.redirectOverlayFocusOut(RedirectFocusDirection.Current);
jest.advanceTimersByTime(150);
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay");
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu");
});
it("finds all focusable tabs if the focusable elements array is not populated", async () => {
@ -1130,7 +1130,7 @@ describe("AutofillOverlayContentService", () => {
isOverlayHidden: false,
setTransparentOverlay: true,
});
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
});
@ -1184,7 +1184,7 @@ describe("AutofillOverlayContentService", () => {
jest.advanceTimersByTime(800);
await flushPromises();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
});
@ -1194,7 +1194,7 @@ describe("AutofillOverlayContentService", () => {
it("skips removing the overlay if the document is visible", () => {
autofillOverlayContentService["handleVisibilityChangeEvent"]();
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
});
@ -1208,7 +1208,7 @@ describe("AutofillOverlayContentService", () => {
autofillOverlayContentService["handleVisibilityChangeEvent"]();
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlay", {
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
});

View File

@ -41,7 +41,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
private eventHandlersMemo: { [key: string]: EventListener } = {};
readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = {
openAutofillOverlay: ({ message }) => this.openAutofillOverlay(message),
openAutofillOverlayMenu: ({ message }) => this.openAutofillOverlayMenu(message),
addNewVaultItemFromOverlay: () => this.addNewVaultItem(),
blurMostRecentOverlayField: () => this.blurMostRecentOverlayField(),
bgUnlockPopoutOpened: () => this.blurMostRecentOverlayField(true),
@ -111,7 +111,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
*
* @param options - Options for opening the autofill overlay.
*/
openAutofillOverlay(options: OpenAutofillOverlayOptions = {}) {
openAutofillOverlayMenu(options: OpenAutofillOverlayOptions = {}) {
const { isFocusingFieldElement, isOpeningFullOverlay, authStatus } = options;
if (!this.mostRecentlyFocusedField) {
return;
@ -157,7 +157,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
this.mostRecentlyFocusedField?.blur();
if (isRemovingOverlay) {
void sendExtensionMessage("closeAutofillOverlay");
void sendExtensionMessage("closeAutofillOverlayMenu");
}
}
@ -194,7 +194,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
if (direction === RedirectFocusDirection.Current) {
this.focusMostRecentOverlayField();
setTimeout(() => void this.sendExtensionMessage("closeAutofillOverlay"), 100);
setTimeout(() => void this.sendExtensionMessage("closeAutofillOverlayMenu"), 100);
return;
}
@ -304,7 +304,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private handleFormFieldKeyupEvent = async (event: KeyboardEvent) => {
const eventCode = event.code;
if (eventCode === "Escape") {
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
return;
@ -331,7 +331,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private async focusOverlayList() {
if (this.mostRecentlyFocusedField && !(await this.isInlineMenuListVisible())) {
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
this.openAutofillOverlay({ isOpeningFullOverlay: true });
this.openAutofillOverlayMenu({ isOpeningFullOverlay: true });
setTimeout(() => this.sendExtensionMessage("focusAutofillOverlayList"), 125);
return;
}
@ -366,14 +366,14 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
this.storeModifiedFormElement(formFieldElement);
if (await this.hideOverlayListOnFilledField(formFieldElement)) {
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
return;
}
this.openAutofillOverlay();
this.openAutofillOverlayMenu();
}
/**
@ -459,7 +459,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
this.autofillOverlayVisibility === AutofillOverlayVisibility.OnButtonClick ||
(formElementHasValue && initiallyFocusedField !== this.mostRecentlyFocusedField)
) {
await this.sendExtensionMessage("closeAutofillOverlay", {
await this.sendExtensionMessage("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
@ -470,7 +470,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
return;
}
void this.sendExtensionMessage("openAutofillOverlay");
void this.sendExtensionMessage("openAutofillOverlayMenu");
}
/**
@ -780,7 +780,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
private triggerOverlayRepositionUpdates = async () => {
if (!this.recentlyFocusedFieldIsCurrentlyFocused()) {
this.toggleOverlayHidden(false, true);
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
return;
@ -795,7 +795,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
this.mostRecentlyFocusedField as FillableFormFieldElement,
)
) {
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
overlayElement: AutofillOverlayElement.List,
forceCloseOverlay: true,
});
@ -807,7 +807,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
return;
}
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
};
@ -868,7 +868,7 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
}
this.mostRecentlyFocusedField = null;
void this.sendExtensionMessage("closeAutofillOverlay", {
void this.sendExtensionMessage("closeAutofillOverlayMenu", {
forceCloseOverlay: true,
});
};