mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 17:23:37 +00:00
[PM-5189] Refactoring implementation
This commit is contained in:
@@ -130,7 +130,7 @@ type PortOnMessageHandlerParams = PortMessageParam & PortConnectionParam;
|
|||||||
|
|
||||||
type OverlayButtonPortMessageHandlers = {
|
type OverlayButtonPortMessageHandlers = {
|
||||||
[key: string]: CallableFunction;
|
[key: string]: CallableFunction;
|
||||||
overlayButtonClicked: ({ port }: PortConnectionParam) => void;
|
autofillInlineMenuButtonClicked: ({ port }: PortConnectionParam) => void;
|
||||||
closeAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
closeAutofillInlineMenu: ({ port }: PortConnectionParam) => void;
|
||||||
forceCloseAutofillOverlay: ({ port }: PortConnectionParam) => void;
|
forceCloseAutofillOverlay: ({ port }: PortConnectionParam) => void;
|
||||||
overlayPageBlurred: () => void;
|
overlayPageBlurred: () => void;
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ describe("OverlayBackground", () => {
|
|||||||
jest.spyOn(overlayBackground as any, "unlockVault").mockImplementation();
|
jest.spyOn(overlayBackground as any, "unlockVault").mockImplementation();
|
||||||
|
|
||||||
sendPortMessage(buttonMessageConnectorPortSpy, {
|
sendPortMessage(buttonMessageConnectorPortSpy, {
|
||||||
command: "overlayButtonClicked",
|
command: "autofillInlineMenuButtonClicked",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1153,7 +1153,7 @@ describe("OverlayBackground", () => {
|
|||||||
jest.spyOn(overlayBackground as any, "openInlineMenu").mockImplementation();
|
jest.spyOn(overlayBackground as any, "openInlineMenu").mockImplementation();
|
||||||
|
|
||||||
sendPortMessage(buttonMessageConnectorPortSpy, {
|
sendPortMessage(buttonMessageConnectorPortSpy, {
|
||||||
command: "overlayButtonClicked",
|
command: "autofillInlineMenuButtonClicked",
|
||||||
portKey,
|
portKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
deletedCipher: () => this.updateOverlayCiphers(),
|
deletedCipher: () => this.updateOverlayCiphers(),
|
||||||
};
|
};
|
||||||
private readonly overlayButtonPortMessageHandlers: OverlayButtonPortMessageHandlers = {
|
private readonly overlayButtonPortMessageHandlers: OverlayButtonPortMessageHandlers = {
|
||||||
overlayButtonClicked: ({ port }) => this.handleOverlayButtonClicked(port),
|
autofillInlineMenuButtonClicked: ({ port }) => this.handleInlineMenuButtonClicked(port),
|
||||||
closeAutofillInlineMenu: ({ port }) => this.closeInlineMenu(port.sender),
|
closeAutofillInlineMenu: ({ port }) => this.closeInlineMenu(port.sender),
|
||||||
forceCloseAutofillOverlay: ({ port }) =>
|
forceCloseAutofillOverlay: ({ port }) =>
|
||||||
this.closeInlineMenu(port.sender, { forceCloseAutofillInlineMenu: true }),
|
this.closeInlineMenu(port.sender, { forceCloseAutofillInlineMenu: true }),
|
||||||
@@ -686,7 +686,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*
|
*
|
||||||
* @param port - The port of the overlay button
|
* @param port - The port of the overlay button
|
||||||
*/
|
*/
|
||||||
private handleOverlayButtonClicked(port: chrome.runtime.Port) {
|
private handleInlineMenuButtonClicked(port: chrome.runtime.Port) {
|
||||||
if (this.userAuthStatus !== AuthenticationStatus.Unlocked) {
|
if (this.userAuthStatus !== AuthenticationStatus.Unlocked) {
|
||||||
void this.unlockVault(port);
|
void this.unlockVault(port);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ describe("AutofillOverlayButton", () => {
|
|||||||
autofillOverlayButton["buttonElement"].click();
|
autofillOverlayButton["buttonElement"].click();
|
||||||
|
|
||||||
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
expect(globalThis.parent.postMessage).toHaveBeenCalledWith(
|
||||||
{ command: "overlayButtonClicked", portKey },
|
{ command: "autofillInlineMenuButtonClicked", portKey },
|
||||||
"*",
|
"*",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ class AutofillOverlayButton extends AutofillOverlayPageElement {
|
|||||||
* parent window indicating that the button was clicked.
|
* parent window indicating that the button was clicked.
|
||||||
*/
|
*/
|
||||||
private handleButtonElementClick = () => {
|
private handleButtonElementClick = () => {
|
||||||
this.postMessageToParent({ command: "overlayButtonClicked" });
|
this.postMessageToParent({ command: "autofillInlineMenuButtonClicked" });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user