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:
@@ -151,7 +151,7 @@ export type InlineMenuListPortMessageHandlers = {
|
|||||||
checkAutofillInlineMenuButtonFocused: () => void;
|
checkAutofillInlineMenuButtonFocused: () => void;
|
||||||
autofillInlineMenuBlurred: () => void;
|
autofillInlineMenuBlurred: () => void;
|
||||||
unlockVault: ({ port }: PortConnectionParam) => void;
|
unlockVault: ({ port }: PortConnectionParam) => void;
|
||||||
fillSelectedAutofillInlineMenuListItem: ({ message, port }: PortOnMessageHandlerParams) => void;
|
fillAutofillInlineMenuCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
|
||||||
addNewVaultItem: ({ port }: PortConnectionParam) => void;
|
addNewVaultItem: ({ port }: PortConnectionParam) => void;
|
||||||
viewSelectedCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
|
viewSelectedCipher: ({ message, port }: PortOnMessageHandlerParams) => void;
|
||||||
redirectAutofillInlineMenuFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;
|
redirectAutofillInlineMenuFocusOut: ({ message, port }: PortOnMessageHandlerParams) => void;
|
||||||
|
|||||||
@@ -1621,14 +1621,14 @@ describe("OverlayBackground", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("fillSelectedAutofillInlineMenuListItem message handler", () => {
|
describe("fillAutofillInlineMenuCipher message handler", () => {
|
||||||
const pageDetails = createAutofillPageDetailsMock({
|
const pageDetails = createAutofillPageDetailsMock({
|
||||||
login: { username: "username1", password: "password1" },
|
login: { username: "username1", password: "password1" },
|
||||||
});
|
});
|
||||||
|
|
||||||
it("ignores the fill request if the overlay cipher id is not provided", async () => {
|
it("ignores the fill request if the overlay cipher id is not provided", async () => {
|
||||||
sendPortMessage(listMessageConnectorSpy, {
|
sendPortMessage(listMessageConnectorSpy, {
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
@@ -1639,7 +1639,7 @@ describe("OverlayBackground", () => {
|
|||||||
|
|
||||||
it("ignores the fill request if the tab does not contain any identified page details", async () => {
|
it("ignores the fill request if the tab does not contain any identified page details", async () => {
|
||||||
sendPortMessage(listMessageConnectorSpy, {
|
sendPortMessage(listMessageConnectorSpy, {
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
inlineMenuCipherId: "inline-menu-cipher-1",
|
inlineMenuCipherId: "inline-menu-cipher-1",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
@@ -1661,7 +1661,7 @@ describe("OverlayBackground", () => {
|
|||||||
autofillService.isPasswordRepromptRequired.mockResolvedValue(true);
|
autofillService.isPasswordRepromptRequired.mockResolvedValue(true);
|
||||||
|
|
||||||
sendPortMessage(listMessageConnectorSpy, {
|
sendPortMessage(listMessageConnectorSpy, {
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
inlineMenuCipherId: "inline-menu-cipher-1",
|
inlineMenuCipherId: "inline-menu-cipher-1",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
@@ -1691,7 +1691,7 @@ describe("OverlayBackground", () => {
|
|||||||
autofillService.isPasswordRepromptRequired.mockResolvedValue(false);
|
autofillService.isPasswordRepromptRequired.mockResolvedValue(false);
|
||||||
|
|
||||||
sendPortMessage(listMessageConnectorSpy, {
|
sendPortMessage(listMessageConnectorSpy, {
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
inlineMenuCipherId: "inline-menu-cipher-2",
|
inlineMenuCipherId: "inline-menu-cipher-2",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
@@ -1730,7 +1730,7 @@ describe("OverlayBackground", () => {
|
|||||||
autofillService.doAutoFill.mockResolvedValue("totp-code");
|
autofillService.doAutoFill.mockResolvedValue("totp-code");
|
||||||
|
|
||||||
sendPortMessage(listMessageConnectorSpy, {
|
sendPortMessage(listMessageConnectorSpy, {
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
inlineMenuCipherId: "inline-menu-cipher-2",
|
inlineMenuCipherId: "inline-menu-cipher-2",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
checkAutofillInlineMenuButtonFocused: () => this.checkInlineMenuButtonFocused(),
|
checkAutofillInlineMenuButtonFocused: () => this.checkInlineMenuButtonFocused(),
|
||||||
autofillInlineMenuBlurred: () => this.checkInlineMenuButtonFocused(),
|
autofillInlineMenuBlurred: () => this.checkInlineMenuButtonFocused(),
|
||||||
unlockVault: ({ port }) => this.unlockVault(port),
|
unlockVault: ({ port }) => this.unlockVault(port),
|
||||||
fillSelectedAutofillInlineMenuListItem: ({ message, port }) =>
|
fillAutofillInlineMenuCipher: ({ message, port }) =>
|
||||||
this.fillSelectedInlineMenuListItem(message, port),
|
this.fillSelectedInlineMenuListItem(message, port),
|
||||||
addNewVaultItem: ({ port }) => this.getNewVaultItemDetails(port),
|
addNewVaultItem: ({ port }) => this.getNewVaultItemDetails(port),
|
||||||
viewSelectedCipher: ({ message, port }) => this.viewSelectedCipher(message, port),
|
viewSelectedCipher: ({ message, port }) => this.viewSelectedCipher(message, port),
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ describe("AutofillInlineMenuList", () => {
|
|||||||
fillCipherButton.dispatchEvent(new Event("click"));
|
fillCipherButton.dispatchEvent(new Event("click"));
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "fillSelectedAutofillInlineMenuListItem", inlineMenuCipherId: "1", portKey },
|
{ command: "fillAutofillInlineMenuCipher", inlineMenuCipherId: "1", portKey },
|
||||||
"*",
|
"*",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -285,7 +285,7 @@ export class AutofillInlineMenuList extends AutofillInlineMenuPageElement {
|
|||||||
return this.useEventHandlersMemo(
|
return this.useEventHandlersMemo(
|
||||||
() =>
|
() =>
|
||||||
this.postMessageToParent({
|
this.postMessageToParent({
|
||||||
command: "fillSelectedAutofillInlineMenuListItem",
|
command: "fillAutofillInlineMenuCipher",
|
||||||
inlineMenuCipherId: cipher.id,
|
inlineMenuCipherId: cipher.id,
|
||||||
}),
|
}),
|
||||||
`${cipher.id}-fill-cipher-button-click-handler`,
|
`${cipher.id}-fill-cipher-button-click-handler`,
|
||||||
|
|||||||
Reference in New Issue
Block a user