mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
[PM-5189] Refactoring implementation
This commit is contained in:
@@ -418,7 +418,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).not.toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.Button,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -426,7 +426,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).not.toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.List,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -440,7 +440,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.Button,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -448,7 +448,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.List,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -470,7 +470,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.Button,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -478,7 +478,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).not.toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "appendInlineMenuElementsToDom",
|
||||
command: "appendAutofillInlineMenuToDom",
|
||||
overlayElement: AutofillOverlayElement.List,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -882,7 +882,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "closeInlineMenu",
|
||||
command: "closeAutofillInlineMenu",
|
||||
overlayElement: AutofillOverlayElement.Button,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -922,7 +922,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "closeInlineMenu",
|
||||
command: "closeAutofillInlineMenu",
|
||||
overlayElement: AutofillOverlayElement.List,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -930,7 +930,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).not.toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "closeInlineMenu",
|
||||
command: "closeAutofillInlineMenu",
|
||||
overlayElement: AutofillOverlayElement.Button,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -944,7 +944,7 @@ describe("OverlayBackground", () => {
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{
|
||||
command: "closeInlineMenu",
|
||||
command: "closeAutofillInlineMenu",
|
||||
overlayElement: undefined,
|
||||
},
|
||||
{ frameId: 0 },
|
||||
@@ -1188,7 +1188,7 @@ describe("OverlayBackground", () => {
|
||||
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{ command: "checkIsInlineMenuButtonVisible" },
|
||||
{ command: "checkIsAutofillInlineMenuButtonVisible" },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
});
|
||||
@@ -1202,7 +1202,7 @@ describe("OverlayBackground", () => {
|
||||
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{ command: "checkIsInlineMenuListVisible" },
|
||||
{ command: "checkIsAutofillInlineMenuListVisible" },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
});
|
||||
@@ -1449,7 +1449,7 @@ describe("OverlayBackground", () => {
|
||||
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
sender.tab,
|
||||
{ command: "closeInlineMenu", overlayElement: undefined },
|
||||
{ command: "closeAutofillInlineMenu", overlayElement: undefined },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
expect(tabSendMessageDataSpy).toBeCalledWith(
|
||||
|
||||
@@ -483,7 +483,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
sender: chrome.runtime.MessageSender,
|
||||
{ forceCloseAutofillInlineMenu, overlayElement }: CloseInlineMenuMessage = {},
|
||||
) {
|
||||
const command = "closeInlineMenu";
|
||||
const command = "closeAutofillInlineMenu";
|
||||
const sendOptions = { frameId: 0 };
|
||||
if (forceCloseAutofillInlineMenu) {
|
||||
void BrowserApi.tabSendMessage(sender.tab, { command, overlayElement }, sendOptions);
|
||||
@@ -568,7 +568,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
|
||||
await BrowserApi.tabSendMessage(
|
||||
sender.tab,
|
||||
{ command: "appendInlineMenuElementsToDom", overlayElement },
|
||||
{ command: "appendAutofillInlineMenuToDom", overlayElement },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
|
||||
@@ -703,7 +703,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
|
||||
void BrowserApi.tabSendMessage(
|
||||
sender.tab,
|
||||
{ command: "toggleInlineMenuHidden", isInlineMenuHidden: isAutofillInlineMenuHidden },
|
||||
{ command: "toggleAutofillInlineMenuHidden", isInlineMenuHidden: isAutofillInlineMenuHidden },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
|
||||
@@ -988,7 +988,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
): Promise<boolean> {
|
||||
return await BrowserApi.tabSendMessage(
|
||||
sender.tab,
|
||||
{ command: "checkIsInlineMenuButtonVisible" },
|
||||
{ command: "checkIsAutofillInlineMenuButtonVisible" },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
): Promise<boolean> {
|
||||
return await BrowserApi.tabSendMessage(
|
||||
sender.tab,
|
||||
{ command: "checkIsInlineMenuListVisible" },
|
||||
{ command: "checkIsAutofillInlineMenuListVisible" },
|
||||
{ frameId: 0 },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ import { AutofillExtensionMessageParam } from "../../../content/abstractions/aut
|
||||
|
||||
export type InlineMenuExtensionMessageHandlers = {
|
||||
[key: string]: CallableFunction;
|
||||
closeInlineMenu: ({ message }: AutofillExtensionMessageParam) => void;
|
||||
appendInlineMenuElementsToDom: ({ message }: AutofillExtensionMessageParam) => Promise<void>;
|
||||
toggleInlineMenuHidden: ({ message }: AutofillExtensionMessageParam) => void;
|
||||
checkIsInlineMenuButtonVisible: () => boolean;
|
||||
checkIsInlineMenuListVisible: () => boolean;
|
||||
closeAutofillInlineMenu: ({ message }: AutofillExtensionMessageParam) => void;
|
||||
appendAutofillInlineMenuToDom: ({ message }: AutofillExtensionMessageParam) => Promise<void>;
|
||||
toggleAutofillInlineMenuHidden: ({ message }: AutofillExtensionMessageParam) => void;
|
||||
checkIsAutofillInlineMenuButtonVisible: () => boolean;
|
||||
checkIsAutofillInlineMenuListVisible: () => boolean;
|
||||
};
|
||||
|
||||
export interface AutofillInlineMenuContentService {
|
||||
|
||||
@@ -35,12 +35,12 @@ export class AutofillInlineMenuContentService implements AutofillInlineMenuConte
|
||||
zIndex: "2147483647",
|
||||
};
|
||||
private readonly _extensionMessageHandlers: InlineMenuExtensionMessageHandlers = {
|
||||
closeInlineMenu: ({ message }) => this.removeInlineMenu(message),
|
||||
appendInlineMenuElementsToDom: ({ message }) => this.appendInlineMenuElements(message),
|
||||
toggleInlineMenuHidden: ({ message }) =>
|
||||
closeAutofillInlineMenu: ({ message }) => this.removeInlineMenu(message),
|
||||
appendAutofillInlineMenuToDom: ({ message }) => this.appendInlineMenuElements(message),
|
||||
toggleAutofillInlineMenuHidden: ({ message }) =>
|
||||
this.toggleInlineMenuHidden(message.isInlineMenuHidden),
|
||||
checkIsInlineMenuButtonVisible: () => this.isInlineMenuButtonVisible(),
|
||||
checkIsInlineMenuListVisible: () => this.isInlineMenuListVisible(),
|
||||
checkIsAutofillInlineMenuButtonVisible: () => this.isInlineMenuButtonVisible(),
|
||||
checkIsAutofillInlineMenuListVisible: () => this.isInlineMenuListVisible(),
|
||||
};
|
||||
|
||||
constructor() {
|
||||
|
||||
Reference in New Issue
Block a user