mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-23 21:31:29 +01:00
[PM-5189] Reverting content script port rework
This commit is contained in:
parent
bd7a84fa70
commit
f51be89664
@ -1354,9 +1354,8 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private async triggerSubFrameFocusInRebuild({ sender }: chrome.runtime.Port) {
|
||||
private async triggerSubFrameFocusInRebuild(sender: chrome.runtime.MessageSender) {
|
||||
await this.rebuildSubFrameOffsets(sender);
|
||||
this.cancelUpdateInlineMenuPositionSubject.next();
|
||||
this.repositionInlineMenuSubject.next(sender);
|
||||
}
|
||||
|
||||
|
@ -901,17 +901,6 @@ describe("AutofillOverlayContentService", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("clears the user interaction timeout", async () => {
|
||||
jest.useFakeTimers();
|
||||
const clearTimeoutSpy = jest.spyOn(globalThis, "clearTimeout");
|
||||
autofillOverlayContentService["userInteractionEventTimeout"] = setTimeout(jest.fn(), 123);
|
||||
|
||||
globalThis.dispatchEvent(new Event(EVENTS.SCROLL));
|
||||
await flushPromises();
|
||||
|
||||
expect(clearTimeoutSpy).toHaveBeenCalledWith(expect.anything());
|
||||
});
|
||||
|
||||
it("removes the overlay completely if the field is not focused", async () => {
|
||||
jest.useFakeTimers();
|
||||
jest
|
||||
@ -1691,14 +1680,6 @@ describe("AutofillOverlayContentService", () => {
|
||||
autofillOverlayContentService["mostRecentlyFocusedField"] = autofillFieldElement;
|
||||
});
|
||||
|
||||
it("clears the user interaction event timeout", () => {
|
||||
jest.spyOn(autofillOverlayContentService as any, "clearUserInteractionEventTimeout");
|
||||
|
||||
autofillOverlayContentService.destroy();
|
||||
|
||||
expect(autofillOverlayContentService["clearUserInteractionEventTimeout"]).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("de-registers all global event listeners", () => {
|
||||
jest.spyOn(globalThis.document, "removeEventListener");
|
||||
jest.spyOn(globalThis, "removeEventListener");
|
||||
|
@ -53,11 +53,8 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
||||
private focusableElements: FocusableElement[] = [];
|
||||
private mostRecentlyFocusedField: ElementWithOpId<FormFieldElement>;
|
||||
private focusedFieldData: FocusedFieldData;
|
||||
private userInteractionEventTimeout: number | NodeJS.Timeout;
|
||||
private recalculateSubFrameOffsetsTimeout: number | NodeJS.Timeout;
|
||||
private closeInlineMenuOnRedirectTimeout: number | NodeJS.Timeout;
|
||||
private focusInlineMenuListTimeout: number | NodeJS.Timeout;
|
||||
private closeInlineMenuOnFilledFieldTimeout: number | NodeJS.Timeout;
|
||||
private eventHandlersMemo: { [key: string]: EventListener } = {};
|
||||
private readonly extensionMessageHandlers: AutofillOverlayContentExtensionMessageHandlers = {
|
||||
openAutofillInlineMenu: ({ message }) => this.openInlineMenu(message),
|
||||
@ -510,13 +507,6 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
||||
await this.sendExtensionMessage("updateIsFieldCurrentlyFocused", {
|
||||
isFieldCurrentlyFocused: true,
|
||||
});
|
||||
if (this.userInteractionEventTimeout) {
|
||||
this.clearUserInteractionEventTimeout();
|
||||
void this.toggleInlineMenuHidden(false, true);
|
||||
void this.sendExtensionMessage("closeAutofillInlineMenu", {
|
||||
forceCloseInlineMenu: true,
|
||||
});
|
||||
}
|
||||
const initiallyFocusedField = this.mostRecentlyFocusedField;
|
||||
await this.updateMostRecentlyFocusedField(formFieldElement);
|
||||
|
||||
@ -582,19 +572,6 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message that facilitates hiding the inline menu elements.
|
||||
*
|
||||
* @param isHidden - Indicates if the inline menu elements should be hidden.
|
||||
* @param setTransparentInlineMenu - Indicates if the inline menu is closing.
|
||||
*/
|
||||
private toggleInlineMenuHidden(isHidden: boolean, setTransparentInlineMenu: boolean = false) {
|
||||
void this.sendExtensionMessage("toggleAutofillInlineMenuHidden", {
|
||||
isInlineMenuHidden: isHidden,
|
||||
setTransparentInlineMenu,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the data used to position the inline menu elements in relation
|
||||
* to the most recently focused form field.
|
||||
@ -1118,32 +1095,6 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the user interaction event timeout. This is used to ensure that
|
||||
* the overlay is not repositioned while the user is interacting with it.
|
||||
*/
|
||||
private clearUserInteractionEventTimeout() {
|
||||
if (this.userInteractionEventTimeout) {
|
||||
globalThis.clearTimeout(this.userInteractionEventTimeout);
|
||||
this.userInteractionEventTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
private clearCloseInlineMenuOnFilledFieldTimeout() {
|
||||
if (this.closeInlineMenuOnFilledFieldTimeout) {
|
||||
globalThis.clearTimeout(this.closeInlineMenuOnFilledFieldTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the timeout that facilitates recalculating the sub frame offsets.
|
||||
*/
|
||||
private clearRecalculateSubFrameOffsetsTimeout() {
|
||||
if (this.recalculateSubFrameOffsetsTimeout) {
|
||||
globalThis.clearTimeout(this.recalculateSubFrameOffsetsTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
private clearFocusInlineMenuListTimeout() {
|
||||
if (this.focusInlineMenuListTimeout) {
|
||||
globalThis.clearTimeout(this.focusInlineMenuListTimeout);
|
||||
@ -1157,9 +1108,6 @@ export class AutofillOverlayContentService implements AutofillOverlayContentServ
|
||||
}
|
||||
|
||||
private clearAllTimeouts() {
|
||||
this.clearUserInteractionEventTimeout();
|
||||
this.clearCloseInlineMenuOnFilledFieldTimeout();
|
||||
this.clearRecalculateSubFrameOffsetsTimeout();
|
||||
this.clearFocusInlineMenuListTimeout();
|
||||
this.clearCloseInlineMenuOnRedirectTimeout();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user