mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 01:33:33 +00:00
[PM-5189] Refactoring implementation
This commit is contained in:
@@ -48,7 +48,7 @@ export type OverlayAddNewItemMessage = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type CloseInlineMenuMessage = {
|
export type CloseInlineMenuMessage = {
|
||||||
forceCloseAutofillInlineMenu?: boolean;
|
forceCloseInlineMenu?: boolean;
|
||||||
overlayElement?: string;
|
overlayElement?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export type OverlayBackgroundExtensionMessage = {
|
|||||||
tab?: chrome.tabs.Tab;
|
tab?: chrome.tabs.Tab;
|
||||||
sender?: string;
|
sender?: string;
|
||||||
details?: AutofillPageDetails;
|
details?: AutofillPageDetails;
|
||||||
isAutofillInlineMenuHidden?: boolean;
|
isInlineMenuHidden?: boolean;
|
||||||
setTransparentInlineMenu?: boolean;
|
setTransparentInlineMenu?: boolean;
|
||||||
isFieldCurrentlyFocused?: boolean;
|
isFieldCurrentlyFocused?: boolean;
|
||||||
isFieldCurrentlyFilling?: boolean;
|
isFieldCurrentlyFilling?: boolean;
|
||||||
|
|||||||
@@ -819,7 +819,7 @@ describe("OverlayBackground", () => {
|
|||||||
{
|
{
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isFocusingFieldElement: false,
|
isFocusingFieldElement: false,
|
||||||
isOpeningFullAutofillInlineMenu: false,
|
isOpeningFullInlineMenu: false,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
},
|
},
|
||||||
{ frameId: 0 },
|
{ frameId: 0 },
|
||||||
@@ -839,7 +839,7 @@ describe("OverlayBackground", () => {
|
|||||||
{
|
{
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isFocusingFieldElement: false,
|
isFocusingFieldElement: false,
|
||||||
isOpeningFullAutofillInlineMenu: false,
|
isOpeningFullInlineMenu: false,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
},
|
},
|
||||||
{ frameId: 10 },
|
{ frameId: 10 },
|
||||||
@@ -872,7 +872,7 @@ describe("OverlayBackground", () => {
|
|||||||
sendMockExtensionMessage(
|
sendMockExtensionMessage(
|
||||||
{
|
{
|
||||||
command: "closeAutofillInlineMenu",
|
command: "closeAutofillInlineMenu",
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
overlayElement: AutofillOverlayElement.Button,
|
overlayElement: AutofillOverlayElement.Button,
|
||||||
},
|
},
|
||||||
sender,
|
sender,
|
||||||
@@ -899,7 +899,7 @@ describe("OverlayBackground", () => {
|
|||||||
sendMockExtensionMessage(
|
sendMockExtensionMessage(
|
||||||
{
|
{
|
||||||
command: "closeAutofillInlineMenu",
|
command: "closeAutofillInlineMenu",
|
||||||
forceCloseAutofillInlineMenu: false,
|
forceCloseInlineMenu: false,
|
||||||
overlayElement: AutofillOverlayElement.Button,
|
overlayElement: AutofillOverlayElement.Button,
|
||||||
},
|
},
|
||||||
sender,
|
sender,
|
||||||
@@ -1156,7 +1156,7 @@ describe("OverlayBackground", () => {
|
|||||||
it("posts a message to the overlay button and list which hides the menu", async () => {
|
it("posts a message to the overlay button and list which hides the menu", async () => {
|
||||||
const message = {
|
const message = {
|
||||||
command: "toggleAutofillInlineMenuHidden",
|
command: "toggleAutofillInlineMenuHidden",
|
||||||
isAutofillInlineMenuHidden: true,
|
isInlineMenuHidden: true,
|
||||||
setTransparentInlineMenu: false,
|
setTransparentInlineMenu: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1375,7 +1375,7 @@ describe("OverlayBackground", () => {
|
|||||||
{
|
{
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isFocusingFieldElement: true,
|
isFocusingFieldElement: true,
|
||||||
isOpeningFullAutofillInlineMenu: false,
|
isOpeningFullInlineMenu: false,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
},
|
},
|
||||||
{ frameId: 0 },
|
{ frameId: 0 },
|
||||||
@@ -1476,7 +1476,7 @@ describe("OverlayBackground", () => {
|
|||||||
{
|
{
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isFocusingFieldElement: false,
|
isFocusingFieldElement: false,
|
||||||
isOpeningFullAutofillInlineMenu: true,
|
isOpeningFullInlineMenu: true,
|
||||||
authStatus: AuthenticationStatus.Unlocked,
|
authStatus: AuthenticationStatus.Unlocked,
|
||||||
},
|
},
|
||||||
{ frameId: 0 },
|
{ frameId: 0 },
|
||||||
|
|||||||
@@ -476,16 +476,16 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
* Sends a message to the sender tab to close the autofill inline menu.
|
* Sends a message to the sender tab to close the autofill inline menu.
|
||||||
*
|
*
|
||||||
* @param sender - The sender of the port message
|
* @param sender - The sender of the port message
|
||||||
* @param forceCloseAutofillInlineMenu - Identifies whether the inline menu should be forced closed
|
* @param forceCloseInlineMenu - Identifies whether the inline menu should be forced closed
|
||||||
* @param overlayElement - The overlay element to close, either the list or button
|
* @param overlayElement - The overlay element to close, either the list or button
|
||||||
*/
|
*/
|
||||||
private closeInlineMenu(
|
private closeInlineMenu(
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
{ forceCloseAutofillInlineMenu, overlayElement }: CloseInlineMenuMessage = {},
|
{ forceCloseInlineMenu, overlayElement }: CloseInlineMenuMessage = {},
|
||||||
) {
|
) {
|
||||||
const command = "closeAutofillInlineMenu";
|
const command = "closeAutofillInlineMenu";
|
||||||
const sendOptions = { frameId: 0 };
|
const sendOptions = { frameId: 0 };
|
||||||
if (forceCloseAutofillInlineMenu) {
|
if (forceCloseInlineMenu) {
|
||||||
void BrowserApi.tabSendMessage(sender.tab, { command, overlayElement }, sendOptions);
|
void BrowserApi.tabSendMessage(sender.tab, { command, overlayElement }, sendOptions);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -688,10 +688,10 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
* @param sender - The sender of the extension message
|
* @param sender - The sender of the extension message
|
||||||
*/
|
*/
|
||||||
private updateInlineMenuHidden(
|
private updateInlineMenuHidden(
|
||||||
{ isAutofillInlineMenuHidden, setTransparentInlineMenu }: OverlayBackgroundExtensionMessage,
|
{ isInlineMenuHidden, setTransparentInlineMenu }: OverlayBackgroundExtensionMessage,
|
||||||
sender: chrome.runtime.MessageSender,
|
sender: chrome.runtime.MessageSender,
|
||||||
) {
|
) {
|
||||||
const display = isAutofillInlineMenuHidden ? "none" : "block";
|
const display = isInlineMenuHidden ? "none" : "block";
|
||||||
let styles: { display: string; opacity?: number } = { display };
|
let styles: { display: string; opacity?: number } = { display };
|
||||||
|
|
||||||
if (typeof setTransparentInlineMenu !== "undefined") {
|
if (typeof setTransparentInlineMenu !== "undefined") {
|
||||||
@@ -701,7 +701,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
|
|
||||||
void BrowserApi.tabSendMessage(
|
void BrowserApi.tabSendMessage(
|
||||||
sender.tab,
|
sender.tab,
|
||||||
{ command: "toggleAutofillInlineMenuHidden", isInlineMenuHidden: isAutofillInlineMenuHidden },
|
{ command: "toggleAutofillInlineMenuHidden", isInlineMenuHidden },
|
||||||
{ frameId: 0 },
|
{ frameId: 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -714,12 +714,9 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
* Sends a message to the currently active tab to open the autofill inline menu.
|
* Sends a message to the currently active tab to open the autofill inline menu.
|
||||||
*
|
*
|
||||||
* @param isFocusingFieldElement - Identifies whether the field element should be focused when the inline menu is opened
|
* @param isFocusingFieldElement - Identifies whether the field element should be focused when the inline menu is opened
|
||||||
* @param isOpeningFullAutofillInlineMenu - Identifies whether the full inline menu should be forced open regardless of other states
|
* @param isOpeningFullInlineMenu - Identifies whether the full inline menu should be forced open regardless of other states
|
||||||
*/
|
*/
|
||||||
private async openInlineMenu(
|
private async openInlineMenu(isFocusingFieldElement = false, isOpeningFullInlineMenu = false) {
|
||||||
isFocusingFieldElement = false,
|
|
||||||
isOpeningFullAutofillInlineMenu = false,
|
|
||||||
) {
|
|
||||||
const currentTab = await BrowserApi.getTabFromCurrentWindowId();
|
const currentTab = await BrowserApi.getTabFromCurrentWindowId();
|
||||||
|
|
||||||
await BrowserApi.tabSendMessage(
|
await BrowserApi.tabSendMessage(
|
||||||
@@ -727,7 +724,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
{
|
{
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isFocusingFieldElement,
|
isFocusingFieldElement,
|
||||||
isOpeningFullAutofillInlineMenu,
|
isOpeningFullInlineMenu,
|
||||||
authStatus: await this.getAuthStatus(),
|
authStatus: await this.getAuthStatus(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ export type AutofillExtensionMessage = {
|
|||||||
overlayElement?: string;
|
overlayElement?: string;
|
||||||
isFocusingFieldElement?: boolean;
|
isFocusingFieldElement?: boolean;
|
||||||
authStatus?: AuthenticationStatus;
|
authStatus?: AuthenticationStatus;
|
||||||
isOpeningFullAutofillInlineMenu?: boolean;
|
isOpeningFullInlineMenu?: boolean;
|
||||||
data?: {
|
data?: {
|
||||||
direction?: "previous" | "next" | "current";
|
direction?: "previous" | "next" | "current";
|
||||||
forceCloseAutofillInlineMenu?: boolean;
|
forceCloseInlineMenu?: boolean;
|
||||||
inlineMenuVisibility?: number;
|
inlineMenuVisibility?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
* Triggers a forced closure of the autofill inline menu. This is used when the
|
* Triggers a forced closure of the autofill inline menu. This is used when the
|
||||||
* mutation observer is triggered excessively.
|
* mutation observer is triggered excessively.
|
||||||
*/
|
*/
|
||||||
private forceCloseAutofillInlineMenu() {
|
private forceCloseInlineMenu() {
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", { forceClose: true });
|
void this.sendExtensionMessage("closeAutofillInlineMenu", { forceClose: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,7 +347,7 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
|
|
||||||
this.delayedCloseTimeout = globalThis.setTimeout(() => {
|
this.delayedCloseTimeout = globalThis.setTimeout(() => {
|
||||||
this.updateElementStyles(this.iframe, { transition: this.fadeInOpacityTransition });
|
this.updateElementStyles(this.iframe, { transition: this.fadeInOpacityTransition });
|
||||||
this.forceCloseAutofillInlineMenu();
|
this.forceCloseInlineMenu();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.foreignMutationsCount >= 10) {
|
if (this.foreignMutationsCount >= 10) {
|
||||||
this.forceCloseAutofillInlineMenu();
|
this.forceCloseInlineMenu();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,7 +421,7 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
if (this.mutationObserverIterations > 20) {
|
if (this.mutationObserverIterations > 20) {
|
||||||
clearTimeout(this.mutationObserverIterationsResetTimeout);
|
clearTimeout(this.mutationObserverIterationsResetTimeout);
|
||||||
resetCounters();
|
resetCounters();
|
||||||
this.forceCloseAutofillInlineMenu();
|
this.forceCloseInlineMenu();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { ElementWithOpId, FormFieldElement } from "../../types";
|
|||||||
|
|
||||||
export type OpenAutofillInlineMenuOptions = {
|
export type OpenAutofillInlineMenuOptions = {
|
||||||
isFocusingFieldElement?: boolean;
|
isFocusingFieldElement?: boolean;
|
||||||
isOpeningFullAutofillInlineMenu?: boolean;
|
isOpeningFullInlineMenu?: boolean;
|
||||||
authStatus?: AuthenticationStatus;
|
authStatus?: AuthenticationStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ export interface AutofillOverlayContentService {
|
|||||||
pageDetailsUpdateRequired: boolean;
|
pageDetailsUpdateRequired: boolean;
|
||||||
messageHandlers: AutofillOverlayContentExtensionMessageHandlers;
|
messageHandlers: AutofillOverlayContentExtensionMessageHandlers;
|
||||||
init(): void;
|
init(): void;
|
||||||
setupAutofillInlineMenuListenerOnField(
|
setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
autofillFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
autofillFieldData: AutofillField,
|
autofillFieldData: AutofillField,
|
||||||
): Promise<void>;
|
): Promise<void>;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("setupAutofillInlineMenuListenerOnField", () => {
|
describe("setupInlineMenuListenerOnField", () => {
|
||||||
let autofillFieldElement: ElementWithOpId<FormFieldElement>;
|
let autofillFieldElement: ElementWithOpId<FormFieldElement>;
|
||||||
let autofillFieldData: AutofillField;
|
let autofillFieldData: AutofillField;
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that are readonly", async () => {
|
it("ignores fields that are readonly", async () => {
|
||||||
autofillFieldData.readonly = true;
|
autofillFieldData.readonly = true;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -152,7 +152,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that contain a disabled attribute", async () => {
|
it("ignores fields that contain a disabled attribute", async () => {
|
||||||
autofillFieldData.disabled = true;
|
autofillFieldData.disabled = true;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -163,7 +163,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that are not viewable", async () => {
|
it("ignores fields that are not viewable", async () => {
|
||||||
autofillFieldData.viewable = false;
|
autofillFieldData.viewable = false;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -175,7 +175,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
AutoFillConstants.ExcludedInlineMenuTypes.forEach(async (excludedType) => {
|
AutoFillConstants.ExcludedInlineMenuTypes.forEach(async (excludedType) => {
|
||||||
autofillFieldData.type = excludedType;
|
autofillFieldData.type = excludedType;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -187,7 +187,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that contain the keyword `search`", async () => {
|
it("ignores fields that contain the keyword `search`", async () => {
|
||||||
autofillFieldData.placeholder = "search";
|
autofillFieldData.placeholder = "search";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -198,7 +198,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that contain the keyword `captcha` ", async () => {
|
it("ignores fields that contain the keyword `captcha` ", async () => {
|
||||||
autofillFieldData.placeholder = "captcha";
|
autofillFieldData.placeholder = "captcha";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -209,7 +209,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("ignores fields that do not appear as a login field", async () => {
|
it("ignores fields that do not appear as a login field", async () => {
|
||||||
autofillFieldData.placeholder = "another-type-of-field";
|
autofillFieldData.placeholder = "another-type-of-field";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -221,7 +221,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("skips setup on fields that have been previously set up", async () => {
|
it("skips setup on fields that have been previously set up", async () => {
|
||||||
autofillOverlayContentService["formFieldElements"].add(autofillFieldElement);
|
autofillOverlayContentService["formFieldElements"].add(autofillFieldElement);
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -234,7 +234,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
sendExtensionMessageSpy.mockResolvedValueOnce(undefined);
|
sendExtensionMessageSpy.mockResolvedValueOnce(undefined);
|
||||||
autofillOverlayContentService["inlineMenuVisibility"] = undefined;
|
autofillOverlayContentService["inlineMenuVisibility"] = undefined;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -249,7 +249,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
sendExtensionMessageSpy.mockResolvedValueOnce(AutofillOverlayVisibility.OnFieldFocus);
|
sendExtensionMessageSpy.mockResolvedValueOnce(AutofillOverlayVisibility.OnFieldFocus);
|
||||||
autofillOverlayContentService["inlineMenuVisibility"] = undefined;
|
autofillOverlayContentService["inlineMenuVisibility"] = undefined;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -272,7 +272,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
"op-1-username-field-focus-handler": focusHandler,
|
"op-1-username-field-focus-handler": focusHandler,
|
||||||
};
|
};
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -301,7 +301,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
describe("form field blur event listener", () => {
|
describe("form field blur event listener", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -324,7 +324,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
describe("form field keyup event listener", () => {
|
describe("form field keyup event listener", () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -335,7 +335,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillFieldElement.dispatchEvent(new KeyboardEvent("keyup", { code: "Escape" }));
|
autofillFieldElement.dispatchEvent(new KeyboardEvent("keyup", { code: "Escape" }));
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
);
|
);
|
||||||
const openAutofillOverlaySpy = jest.spyOn(
|
const openAutofillOverlaySpy = jest.spyOn(
|
||||||
autofillOverlayContentService as any,
|
autofillOverlayContentService as any,
|
||||||
"openAutofillInlineMenu",
|
"openInlineMenu",
|
||||||
);
|
);
|
||||||
jest
|
jest
|
||||||
.spyOn(autofillOverlayContentService as any, "isInlineMenuListVisible")
|
.spyOn(autofillOverlayContentService as any, "isInlineMenuListVisible")
|
||||||
@@ -388,7 +388,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(updateMostRecentlyFocusedFieldSpy).toHaveBeenCalledWith(autofillFieldElement);
|
expect(updateMostRecentlyFocusedFieldSpy).toHaveBeenCalledWith(autofillFieldElement);
|
||||||
expect(openAutofillOverlaySpy).toHaveBeenCalledWith({
|
expect(openAutofillOverlaySpy).toHaveBeenCalledWith({
|
||||||
isOpeningFullAutofillInlineMenu: true,
|
isOpeningFullInlineMenu: true,
|
||||||
});
|
});
|
||||||
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("focusAutofillInlineMenuList");
|
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("focusAutofillInlineMenuList");
|
||||||
|
|
||||||
@@ -420,7 +420,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
) as ElementWithOpId<HTMLSpanElement>;
|
) as ElementWithOpId<HTMLSpanElement>;
|
||||||
jest.spyOn(autofillOverlayContentService as any, "storeModifiedFormElement");
|
jest.spyOn(autofillOverlayContentService as any, "storeModifiedFormElement");
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
spanAutofillFieldElement,
|
spanAutofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -434,7 +434,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["mostRecentlyFocusedField"] =
|
autofillOverlayContentService["mostRecentlyFocusedField"] =
|
||||||
mock<ElementWithOpId<FormFieldElement>>();
|
mock<ElementWithOpId<FormFieldElement>>();
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -448,7 +448,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("stores the field as a user filled field if the form field data indicates that it is for a username", async () => {
|
it("stores the field as a user filled field if the form field data indicates that it is for a username", async () => {
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -464,7 +464,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
"password-field",
|
"password-field",
|
||||||
) as ElementWithOpId<FormFieldElement>;
|
) as ElementWithOpId<FormFieldElement>;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
passwordFieldElement,
|
passwordFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -479,7 +479,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(false);
|
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(false);
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -488,7 +488,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -500,7 +500,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -509,37 +509,37 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens the autofill inline menu if the form field is empty", async () => {
|
it("opens the autofill inline menu if the form field is empty", async () => {
|
||||||
jest.spyOn(autofillOverlayContentService as any, "openAutofillInlineMenu");
|
jest.spyOn(autofillOverlayContentService as any, "openInlineMenu");
|
||||||
(autofillFieldElement as HTMLInputElement).value = "";
|
(autofillFieldElement as HTMLInputElement).value = "";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(autofillOverlayContentService["openAutofillInlineMenu"]).toHaveBeenCalled();
|
expect(autofillOverlayContentService["openInlineMenu"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens the autofill inline menu if the form field is empty and the user is authed", async () => {
|
it("opens the autofill inline menu 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, "isUserAuthed").mockReturnValue(true);
|
||||||
jest.spyOn(autofillOverlayContentService as any, "openAutofillInlineMenu");
|
jest.spyOn(autofillOverlayContentService as any, "openInlineMenu");
|
||||||
(autofillFieldElement as HTMLInputElement).value = "";
|
(autofillFieldElement as HTMLInputElement).value = "";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(autofillOverlayContentService["openAutofillInlineMenu"]).toHaveBeenCalled();
|
expect(autofillOverlayContentService["openInlineMenu"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("opens the autofill inline menu if the form field is empty and the overlay ciphers are not populated", async () => {
|
it("opens the autofill inline menu if the form field is empty and the overlay ciphers are not populated", async () => {
|
||||||
@@ -547,17 +547,17 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(autofillOverlayContentService as any, "isInlineMenuCiphersPopulated")
|
.spyOn(autofillOverlayContentService as any, "isInlineMenuCiphersPopulated")
|
||||||
.mockResolvedValue(false);
|
.mockResolvedValue(false);
|
||||||
jest.spyOn(autofillOverlayContentService as any, "openAutofillInlineMenu");
|
jest.spyOn(autofillOverlayContentService as any, "openInlineMenu");
|
||||||
(autofillFieldElement as HTMLInputElement).value = "";
|
(autofillFieldElement as HTMLInputElement).value = "";
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
autofillFieldElement.dispatchEvent(new Event("input"));
|
autofillFieldElement.dispatchEvent(new Event("input"));
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(autofillOverlayContentService["openAutofillInlineMenu"]).toHaveBeenCalled();
|
expect(autofillOverlayContentService["openInlineMenu"]).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -566,7 +566,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(autofillOverlayContentService as any, "triggerFormFieldFocusedAction")
|
.spyOn(autofillOverlayContentService as any, "triggerFormFieldFocusedAction")
|
||||||
.mockImplementation();
|
.mockImplementation();
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -622,7 +622,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
|
||||||
autofillOverlayContentService["inlineMenuVisibility"] =
|
autofillOverlayContentService["inlineMenuVisibility"] =
|
||||||
AutofillOverlayVisibility.OnFieldFocus;
|
AutofillOverlayVisibility.OnFieldFocus;
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -634,7 +634,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("updates the most recently focused field", async () => {
|
it("updates the most recently focused field", async () => {
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -651,7 +651,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("removes the overlay list if the autofill visibility is set to onClick", async () => {
|
it("removes the overlay list if the autofill visibility is set to onClick", async () => {
|
||||||
autofillOverlayContentService["inlineMenuVisibility"] =
|
autofillOverlayContentService["inlineMenuVisibility"] =
|
||||||
AutofillOverlayVisibility.OnButtonClick;
|
AutofillOverlayVisibility.OnButtonClick;
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -661,7 +661,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -670,7 +670,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
"input",
|
"input",
|
||||||
) as ElementWithOpId<HTMLInputElement>;
|
) as ElementWithOpId<HTMLInputElement>;
|
||||||
(autofillFieldElement as HTMLInputElement).value = "test";
|
(autofillFieldElement as HTMLInputElement).value = "test";
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -680,7 +680,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -688,7 +688,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
(autofillFieldElement as HTMLInputElement).value = "";
|
(autofillFieldElement as HTMLInputElement).value = "";
|
||||||
autofillOverlayContentService["inlineMenuVisibility"] =
|
autofillOverlayContentService["inlineMenuVisibility"] =
|
||||||
AutofillOverlayVisibility.OnFieldFocus;
|
AutofillOverlayVisibility.OnFieldFocus;
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -704,7 +704,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["inlineMenuVisibility"] =
|
autofillOverlayContentService["inlineMenuVisibility"] =
|
||||||
AutofillOverlayVisibility.OnFieldFocus;
|
AutofillOverlayVisibility.OnFieldFocus;
|
||||||
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(true);
|
jest.spyOn(autofillOverlayContentService as any, "isUserAuthed").mockReturnValue(true);
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -722,7 +722,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest
|
jest
|
||||||
.spyOn(autofillOverlayContentService as any, "isInlineMenuCiphersPopulated")
|
.spyOn(autofillOverlayContentService as any, "isInlineMenuCiphersPopulated")
|
||||||
.mockReturnValue(true);
|
.mockReturnValue(true);
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -739,7 +739,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
describe("hidden form field focus event", () => {
|
describe("hidden form field focus event", () => {
|
||||||
it("sets up the inline menu listeners if the autofill field data is in the cache", async () => {
|
it("sets up the inline menu listeners if the autofill field data is in the cache", async () => {
|
||||||
autofillFieldData.viewable = false;
|
autofillFieldData.viewable = false;
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -772,7 +772,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
it("skips setting up the inline menu listeners if the autofill field data is not in the cache", async () => {
|
it("skips setting up the inline menu listeners if the autofill field data is not in the cache", async () => {
|
||||||
autofillFieldData.viewable = false;
|
autofillFieldData.viewable = false;
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -808,7 +808,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
writable: true,
|
writable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -822,7 +822,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
it("sets the most recently focused field to the passed form field element if the value is not set", async () => {
|
it("sets the most recently focused field to the passed form field element if the value is not set", async () => {
|
||||||
autofillOverlayContentService["mostRecentlyFocusedField"] = undefined;
|
autofillOverlayContentService["mostRecentlyFocusedField"] = undefined;
|
||||||
|
|
||||||
await autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
await autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -883,7 +883,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("toggleAutofillInlineMenuHidden", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("toggleAutofillInlineMenuHidden", {
|
||||||
isAutofillInlineMenuHidden: true,
|
isInlineMenuHidden: true,
|
||||||
setTransparentInlineMenu: false,
|
setTransparentInlineMenu: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -912,11 +912,11 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.advanceTimersByTime(800);
|
jest.advanceTimersByTime(800);
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("toggleAutofillInlineMenuHidden", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("toggleAutofillInlineMenuHidden", {
|
||||||
isAutofillInlineMenuHidden: false,
|
isInlineMenuHidden: false,
|
||||||
setTransparentInlineMenu: true,
|
setTransparentInlineMenu: true,
|
||||||
});
|
});
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -978,7 +978,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1001,7 +1001,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1016,7 +1016,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["handleVisibilityChangeEvent"]();
|
autofillOverlayContentService["handleVisibilityChangeEvent"]();
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).not.toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1029,7 +1029,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
autofillOverlayContentService["handleVisibilityChangeEvent"]();
|
autofillOverlayContentService["handleVisibilityChangeEvent"]();
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1058,7 +1058,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
});
|
});
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
autofillOverlayContentService.setupAutofillInlineMenuListenerOnField(
|
autofillOverlayContentService.setupInlineMenuListenerOnField(
|
||||||
autofillFieldElement,
|
autofillFieldElement,
|
||||||
autofillFieldData,
|
autofillFieldData,
|
||||||
);
|
);
|
||||||
@@ -1212,7 +1212,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
sendMockExtensionMessage({
|
sendMockExtensionMessage({
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isOpeningFullAutofillInlineMenu: false,
|
isOpeningFullInlineMenu: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillInlineMenuPosition", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillInlineMenuPosition", {
|
||||||
@@ -1232,7 +1232,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
|
|
||||||
sendMockExtensionMessage({
|
sendMockExtensionMessage({
|
||||||
command: "openAutofillInlineMenu",
|
command: "openAutofillInlineMenu",
|
||||||
isOpeningFullAutofillInlineMenu: true,
|
isOpeningFullInlineMenu: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillInlineMenuPosition", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("updateAutofillInlineMenuPosition", {
|
||||||
@@ -1247,7 +1247,7 @@ describe("AutofillOverlayContentService", () => {
|
|||||||
jest.spyOn(autofillOverlayContentService as any, "sendExtensionMessage");
|
jest.spyOn(autofillOverlayContentService as any, "sendExtensionMessage");
|
||||||
autofillOverlayContentService.pageDetailsUpdateRequired = true;
|
autofillOverlayContentService.pageDetailsUpdateRequired = true;
|
||||||
|
|
||||||
autofillOverlayContentService["openAutofillInlineMenu"]();
|
autofillOverlayContentService["openInlineMenu"]();
|
||||||
sendMockExtensionMessage({ command: "openAutofillInlineMenu" });
|
sendMockExtensionMessage({ command: "openAutofillInlineMenu" });
|
||||||
|
|
||||||
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("bgCollectPageDetails", {
|
expect(sendExtensionMessageSpy).toHaveBeenCalledWith("bgCollectPageDetails", {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
|
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
|
||||||
private eventHandlersMemo: { [key: string]: EventListener } = {};
|
private eventHandlersMemo: { [key: string]: EventListener } = {};
|
||||||
private readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = {
|
private readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = {
|
||||||
openAutofillInlineMenu: ({ message }) => this.openAutofillInlineMenu(message),
|
openAutofillInlineMenu: ({ message }) => this.openInlineMenu(message),
|
||||||
addNewVaultItemFromOverlay: () => this.addNewVaultItem(),
|
addNewVaultItemFromOverlay: () => this.addNewVaultItem(),
|
||||||
blurMostRecentlyFocusedField: () => this.blurMostRecentlyFocusedField(),
|
blurMostRecentlyFocusedField: () => this.blurMostRecentlyFocusedField(),
|
||||||
unsetMostRecentlyFocusedField: () => this.unsetMostRecentlyFocusedField(),
|
unsetMostRecentlyFocusedField: () => this.unsetMostRecentlyFocusedField(),
|
||||||
@@ -49,8 +49,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
bgVaultItemRepromptPopoutOpened: () => this.blurMostRecentlyFocusedField(true),
|
bgVaultItemRepromptPopoutOpened: () => this.blurMostRecentlyFocusedField(true),
|
||||||
redirectAutofillInlineMenuFocusOut: ({ message }) =>
|
redirectAutofillInlineMenuFocusOut: ({ message }) =>
|
||||||
this.redirectInlineMenuFocusOut(message?.data?.direction),
|
this.redirectInlineMenuFocusOut(message?.data?.direction),
|
||||||
updateAutofillInlineMenuVisibility: ({ message }) =>
|
updateAutofillInlineMenuVisibility: ({ message }) => this.updateInlineMenuVisibility(message),
|
||||||
this.updateAutofillInlineMenuVisibility(message),
|
|
||||||
getSubFrameOffsets: ({ message }) => this.getSubFrameOffsets(message),
|
getSubFrameOffsets: ({ message }) => this.getSubFrameOffsets(message),
|
||||||
getSubFrameOffsetsFromWindowMessage: ({ message }) =>
|
getSubFrameOffsetsFromWindowMessage: ({ message }) =>
|
||||||
this.getSubFrameOffsetsFromWindowMessage(message),
|
this.getSubFrameOffsetsFromWindowMessage(message),
|
||||||
@@ -85,7 +84,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
* @param formFieldElement - Form field elements identified during the page details collection process.
|
* @param formFieldElement - Form field elements identified during the page details collection process.
|
||||||
* @param autofillFieldData - Autofill field data captured from the form field element.
|
* @param autofillFieldData - Autofill field data captured from the form field element.
|
||||||
*/
|
*/
|
||||||
async setupAutofillInlineMenuListenerOnField(
|
async setupInlineMenuListenerOnField(
|
||||||
formFieldElement: ElementWithOpId<FormFieldElement>,
|
formFieldElement: ElementWithOpId<FormFieldElement>,
|
||||||
autofillFieldData: AutofillField,
|
autofillFieldData: AutofillField,
|
||||||
) {
|
) {
|
||||||
@@ -104,7 +103,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.inlineMenuVisibility) {
|
if (!this.inlineMenuVisibility) {
|
||||||
await this.getAutofillInlineMenuVisibility();
|
await this.getInlineMenuVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setupFormFieldElementEventListeners(formFieldElement);
|
this.setupFormFieldElementEventListeners(formFieldElement);
|
||||||
@@ -122,8 +121,8 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
*
|
*
|
||||||
* @param options - Options for opening the autofill inline menu.
|
* @param options - Options for opening the autofill inline menu.
|
||||||
*/
|
*/
|
||||||
openAutofillInlineMenu(options: OpenAutofillInlineMenuOptions = {}) {
|
openInlineMenu(options: OpenAutofillInlineMenuOptions = {}) {
|
||||||
const { isFocusingFieldElement, isOpeningFullAutofillInlineMenu, authStatus } = options;
|
const { isFocusingFieldElement, isOpeningFullInlineMenu, authStatus } = options;
|
||||||
// TODO: It's likely that this method functions more cleanly from the scope of the background. Will address this in a future PR when time allows.
|
// TODO: It's likely that this method functions more cleanly from the scope of the background. Will address this in a future PR when time allows.
|
||||||
if (!this.mostRecentlyFocusedField) {
|
if (!this.mostRecentlyFocusedField) {
|
||||||
return;
|
return;
|
||||||
@@ -146,13 +145,13 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
this.inlineMenuVisibility === AutofillOverlayVisibility.OnButtonClick &&
|
this.inlineMenuVisibility === AutofillOverlayVisibility.OnButtonClick &&
|
||||||
!isOpeningFullAutofillInlineMenu
|
!isOpeningFullInlineMenu
|
||||||
) {
|
) {
|
||||||
this.updateAutofillInlineMenuButtonPosition();
|
this.updateInlineMenuButtonPosition();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateAutofillInlineMenuElementsPosition();
|
this.updateInlineMenuElementsPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -324,7 +323,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
const eventCode = event.code;
|
const eventCode = event.code;
|
||||||
if (eventCode === "Escape") {
|
if (eventCode === "Escape") {
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -350,7 +349,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
private async focusInlineMenuList() {
|
private async focusInlineMenuList() {
|
||||||
if (this.mostRecentlyFocusedField && !(await this.isInlineMenuListVisible())) {
|
if (this.mostRecentlyFocusedField && !(await this.isInlineMenuListVisible())) {
|
||||||
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
||||||
this.openAutofillInlineMenu({ isOpeningFullAutofillInlineMenu: true });
|
this.openInlineMenu({ isOpeningFullInlineMenu: true });
|
||||||
globalThis.setTimeout(() => this.sendExtensionMessage("focusAutofillInlineMenuList"), 125);
|
globalThis.setTimeout(() => this.sendExtensionMessage("focusAutofillInlineMenuList"), 125);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -384,15 +383,15 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
|
|
||||||
this.storeModifiedFormElement(formFieldElement);
|
this.storeModifiedFormElement(formFieldElement);
|
||||||
|
|
||||||
if (await this.hideAutofillInlineMenuListOnFilledField(formFieldElement)) {
|
if (await this.hideInlineMenuListOnFilledField(formFieldElement)) {
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openAutofillInlineMenu();
|
this.openInlineMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -476,22 +475,16 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
if (
|
if (
|
||||||
this.inlineMenuVisibility === AutofillOverlayVisibility.OnButtonClick ||
|
this.inlineMenuVisibility === AutofillOverlayVisibility.OnButtonClick ||
|
||||||
(initiallyFocusedField !== this.mostRecentlyFocusedField &&
|
(initiallyFocusedField !== this.mostRecentlyFocusedField &&
|
||||||
(await this.hideAutofillInlineMenuListOnFilledField(
|
(await this.hideInlineMenuListOnFilledField(formFieldElement as FillableFormFieldElement)))
|
||||||
formFieldElement as FillableFormFieldElement,
|
|
||||||
)))
|
|
||||||
) {
|
) {
|
||||||
await this.sendExtensionMessage("closeAutofillInlineMenu", {
|
await this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (await this.hideInlineMenuListOnFilledField(formFieldElement as FillableFormFieldElement)) {
|
||||||
await this.hideAutofillInlineMenuListOnFilledField(
|
this.updateInlineMenuButtonPosition();
|
||||||
formFieldElement as FillableFormFieldElement,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
this.updateAutofillInlineMenuButtonPosition();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,15 +556,15 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
/**
|
/**
|
||||||
* Updates the position of both the inline menu button and list.
|
* Updates the position of both the inline menu button and list.
|
||||||
*/
|
*/
|
||||||
private updateAutofillInlineMenuElementsPosition() {
|
private updateInlineMenuElementsPosition() {
|
||||||
this.updateAutofillInlineMenuButtonPosition();
|
this.updateInlineMenuButtonPosition();
|
||||||
this.updateAutofillInlineMenuListPosition();
|
this.updateInlineMenuListPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the position of the inline menu button.
|
* Updates the position of the inline menu button.
|
||||||
*/
|
*/
|
||||||
private updateAutofillInlineMenuButtonPosition() {
|
private updateInlineMenuButtonPosition() {
|
||||||
void this.sendExtensionMessage("updateAutofillInlineMenuPosition", {
|
void this.sendExtensionMessage("updateAutofillInlineMenuPosition", {
|
||||||
overlayElement: AutofillOverlayElement.Button,
|
overlayElement: AutofillOverlayElement.Button,
|
||||||
});
|
});
|
||||||
@@ -580,7 +573,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
/**
|
/**
|
||||||
* Updates the position of the inline menu list.
|
* Updates the position of the inline menu list.
|
||||||
*/
|
*/
|
||||||
private updateAutofillInlineMenuListPosition() {
|
private updateInlineMenuListPosition() {
|
||||||
void this.sendExtensionMessage("updateAutofillInlineMenuPosition", {
|
void this.sendExtensionMessage("updateAutofillInlineMenuPosition", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
});
|
});
|
||||||
@@ -592,12 +585,9 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
* @param isHidden - Indicates if the inline menu elements should be hidden.
|
* @param isHidden - Indicates if the inline menu elements should be hidden.
|
||||||
* @param setTransparentInlineMenu - Indicates if the inline menu is closing.
|
* @param setTransparentInlineMenu - Indicates if the inline menu is closing.
|
||||||
*/
|
*/
|
||||||
private toggleAutofillInlineMenuHidden(
|
private toggleInlineMenuHidden(isHidden: boolean, setTransparentInlineMenu: boolean = false) {
|
||||||
isHidden: boolean,
|
|
||||||
setTransparentInlineMenu: boolean = false,
|
|
||||||
) {
|
|
||||||
void this.sendExtensionMessage("toggleAutofillInlineMenuHidden", {
|
void this.sendExtensionMessage("toggleAutofillInlineMenuHidden", {
|
||||||
isAutofillInlineMenuHidden: isHidden,
|
isInlineMenuHidden: isHidden,
|
||||||
setTransparentInlineMenu,
|
setTransparentInlineMenu,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -766,7 +756,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
autofillFieldData.readonly = getAttributeBoolean(formFieldElement, "disabled");
|
autofillFieldData.readonly = getAttributeBoolean(formFieldElement, "disabled");
|
||||||
autofillFieldData.disabled = getAttributeBoolean(formFieldElement, "disabled");
|
autofillFieldData.disabled = getAttributeBoolean(formFieldElement, "disabled");
|
||||||
autofillFieldData.viewable = true;
|
autofillFieldData.viewable = true;
|
||||||
void this.setupAutofillInlineMenuListenerOnField(formFieldElement, autofillFieldData);
|
void this.setupInlineMenuListenerOnField(formFieldElement, autofillFieldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.removeHiddenFieldFallbackListener(formFieldElement);
|
this.removeHiddenFieldFallbackListener(formFieldElement);
|
||||||
@@ -777,7 +767,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
* 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 getAutofillInlineMenuVisibility() {
|
private async getInlineMenuVisibility() {
|
||||||
const inlineMenuVisibility = await this.sendExtensionMessage("getAutofillInlineMenuVisibility");
|
const inlineMenuVisibility = await this.sendExtensionMessage("getAutofillInlineMenuVisibility");
|
||||||
this.inlineMenuVisibility = inlineMenuVisibility || AutofillOverlayVisibility.OnFieldFocus;
|
this.inlineMenuVisibility = inlineMenuVisibility || AutofillOverlayVisibility.OnFieldFocus;
|
||||||
}
|
}
|
||||||
@@ -814,7 +804,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.rebuildSubFrameOffsets();
|
this.rebuildSubFrameOffsets();
|
||||||
this.toggleAutofillInlineMenuHidden(true);
|
this.toggleInlineMenuHidden(true);
|
||||||
this.clearUserInteractionEventTimeout();
|
this.clearUserInteractionEventTimeout();
|
||||||
this.userInteractionEventTimeout = globalThis.setTimeout(
|
this.userInteractionEventTimeout = globalThis.setTimeout(
|
||||||
this.triggerOverlayRepositionUpdates,
|
this.triggerOverlayRepositionUpdates,
|
||||||
@@ -839,25 +829,25 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
*/
|
*/
|
||||||
private triggerOverlayRepositionUpdates = async () => {
|
private triggerOverlayRepositionUpdates = async () => {
|
||||||
if (!this.recentlyFocusedFieldIsCurrentlyFocused()) {
|
if (!this.recentlyFocusedFieldIsCurrentlyFocused()) {
|
||||||
this.toggleAutofillInlineMenuHidden(false, true);
|
this.toggleInlineMenuHidden(false, true);
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
await this.updateMostRecentlyFocusedField(this.mostRecentlyFocusedField);
|
||||||
this.updateAutofillInlineMenuElementsPosition();
|
this.updateInlineMenuElementsPosition();
|
||||||
globalThis.setTimeout(async () => {
|
globalThis.setTimeout(async () => {
|
||||||
this.toggleAutofillInlineMenuHidden(false, true);
|
this.toggleInlineMenuHidden(false, true);
|
||||||
if (
|
if (
|
||||||
await this.hideAutofillInlineMenuListOnFilledField(
|
await this.hideInlineMenuListOnFilledField(
|
||||||
this.mostRecentlyFocusedField as FillableFormFieldElement,
|
this.mostRecentlyFocusedField as FillableFormFieldElement,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
overlayElement: AutofillOverlayElement.List,
|
overlayElement: AutofillOverlayElement.List,
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 50);
|
}, 50);
|
||||||
@@ -868,7 +858,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
}
|
}
|
||||||
|
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -909,7 +899,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
*
|
*
|
||||||
* @param formFieldElement - The form field element that triggered the focus event.
|
* @param formFieldElement - The form field element that triggered the focus event.
|
||||||
*/
|
*/
|
||||||
private async hideAutofillInlineMenuListOnFilledField(
|
private async hideInlineMenuListOnFilledField(
|
||||||
formFieldElement?: FillableFormFieldElement,
|
formFieldElement?: FillableFormFieldElement,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return (
|
return (
|
||||||
@@ -948,7 +938,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
|
|
||||||
this.unsetMostRecentlyFocusedField();
|
this.unsetMostRecentlyFocusedField();
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||||
forceCloseAutofillInlineMenu: true,
|
forceCloseInlineMenu: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1100,7 +1090,7 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
|||||||
*
|
*
|
||||||
* @param data - The data object from the extension message.
|
* @param data - The data object from the extension message.
|
||||||
*/
|
*/
|
||||||
private updateAutofillInlineMenuVisibility({ data }: AutofillExtensionMessage) {
|
private updateInlineMenuVisibility({ data }: AutofillExtensionMessage) {
|
||||||
if (!isNaN(data?.inlineMenuVisibility)) {
|
if (!isNaN(data?.inlineMenuVisibility)) {
|
||||||
this.inlineMenuVisibility = data.inlineMenuVisibility;
|
this.inlineMenuVisibility = data.inlineMenuVisibility;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2558,7 +2558,7 @@ describe("CollectAutofillContentService", () => {
|
|||||||
);
|
);
|
||||||
setupAutofillOverlayListenerOnFieldSpy = jest.spyOn(
|
setupAutofillOverlayListenerOnFieldSpy = jest.spyOn(
|
||||||
collectAutofillContentService["autofillOverlayContentService"],
|
collectAutofillContentService["autofillOverlayContentService"],
|
||||||
"setupAutofillInlineMenuListenerOnField",
|
"setupInlineMenuListenerOnField",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
autofillField.viewable = await this.domElementVisibilityService.isFormFieldViewable(element);
|
autofillField.viewable = await this.domElementVisibilityService.isFormFieldViewable(element);
|
||||||
|
|
||||||
if (!currentViewableState && autofillField.viewable) {
|
if (!currentViewableState && autofillField.viewable) {
|
||||||
await this.autofillOverlayContentService?.setupAutofillInlineMenuListenerOnField(
|
await this.autofillOverlayContentService?.setupInlineMenuListenerOnField(
|
||||||
element,
|
element,
|
||||||
autofillField,
|
autofillField,
|
||||||
);
|
);
|
||||||
@@ -457,7 +457,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
|
|
||||||
if (elementIsSpanElement(element)) {
|
if (elementIsSpanElement(element)) {
|
||||||
this.cacheAutofillFieldElement(index, element, autofillFieldBase);
|
this.cacheAutofillFieldElement(index, element, autofillFieldBase);
|
||||||
void this.autofillOverlayContentService?.setupAutofillInlineMenuListenerOnField(
|
void this.autofillOverlayContentService?.setupInlineMenuListenerOnField(
|
||||||
element,
|
element,
|
||||||
autofillFieldBase,
|
autofillFieldBase,
|
||||||
);
|
);
|
||||||
@@ -500,10 +500,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.cacheAutofillFieldElement(index, element, autofillField);
|
this.cacheAutofillFieldElement(index, element, autofillField);
|
||||||
void this.autofillOverlayContentService?.setupAutofillInlineMenuListenerOnField(
|
void this.autofillOverlayContentService?.setupInlineMenuListenerOnField(element, autofillField);
|
||||||
element,
|
|
||||||
autofillField,
|
|
||||||
);
|
|
||||||
return autofillField;
|
return autofillField;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1394,7 +1391,7 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte
|
|||||||
}
|
}
|
||||||
|
|
||||||
cachedAutofillFieldElement.viewable = true;
|
cachedAutofillFieldElement.viewable = true;
|
||||||
void this.autofillOverlayContentService?.setupAutofillInlineMenuListenerOnField(
|
void this.autofillOverlayContentService?.setupInlineMenuListenerOnField(
|
||||||
formFieldElement,
|
formFieldElement,
|
||||||
cachedAutofillFieldElement,
|
cachedAutofillFieldElement,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user