mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Upgrade typescript to 5.1 (#7917)
Co-authored-by: Cesar Gonzalez <cgonzalez@bitwarden.com>
This commit is contained in:
@@ -15,7 +15,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
||||
private iframeMutationObserver: MutationObserver;
|
||||
private iframe: HTMLIFrameElement;
|
||||
private ariaAlertElement: HTMLDivElement;
|
||||
private ariaAlertTimeout: NodeJS.Timeout;
|
||||
private ariaAlertTimeout: number | NodeJS.Timeout;
|
||||
private iframeStyles: Partial<CSSStyleDeclaration> = {
|
||||
all: "initial",
|
||||
position: "fixed",
|
||||
@@ -41,7 +41,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
||||
};
|
||||
private foreignMutationsCount = 0;
|
||||
private mutationObserverIterations = 0;
|
||||
private mutationObserverIterationsResetTimeout: NodeJS.Timeout;
|
||||
private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout;
|
||||
private readonly windowMessageHandlers: AutofillOverlayIframeWindowMessageHandlers = {
|
||||
updateAutofillOverlayListHeight: (message) =>
|
||||
this.updateElementStyles(this.iframe, message.styles),
|
||||
|
||||
@@ -16,6 +16,21 @@ import {
|
||||
import { AutoFillConstants } from "./autofill-constants";
|
||||
import AutofillOverlayContentService from "./autofill-overlay-content.service";
|
||||
|
||||
function createMutationRecordMock(customFields = {}): MutationRecord {
|
||||
return {
|
||||
addedNodes: mock<NodeList>(),
|
||||
attributeName: "default-attributeName",
|
||||
attributeNamespace: "default-attributeNamespace",
|
||||
nextSibling: null,
|
||||
oldValue: "default-oldValue",
|
||||
previousSibling: null,
|
||||
removedNodes: mock<NodeList>(),
|
||||
target: null,
|
||||
type: "attributes",
|
||||
...customFields,
|
||||
};
|
||||
}
|
||||
|
||||
const defaultWindowReadyState = document.readyState;
|
||||
const defaultDocumentVisibilityState = document.visibilityState;
|
||||
describe("AutofillOverlayContentService", () => {
|
||||
@@ -1304,9 +1319,7 @@ describe("AutofillOverlayContentService", () => {
|
||||
.mockReturnValue(true);
|
||||
|
||||
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
|
||||
mock<MutationRecord>({
|
||||
target: usernameField,
|
||||
}),
|
||||
createMutationRecordMock({ target: usernameField }),
|
||||
]);
|
||||
|
||||
expect(usernameField.removeAttribute).not.toHaveBeenCalled();
|
||||
@@ -1314,10 +1327,7 @@ describe("AutofillOverlayContentService", () => {
|
||||
|
||||
it("skips handling the mutation if the record type is not for `attributes`", () => {
|
||||
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
|
||||
mock<MutationRecord>({
|
||||
target: usernameField,
|
||||
type: "childList",
|
||||
}),
|
||||
createMutationRecordMock({ target: usernameField, type: "childList" }),
|
||||
]);
|
||||
|
||||
expect(usernameField.removeAttribute).not.toHaveBeenCalled();
|
||||
@@ -1325,7 +1335,7 @@ describe("AutofillOverlayContentService", () => {
|
||||
|
||||
it("removes all element attributes that are not the style attribute", () => {
|
||||
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
|
||||
mock<MutationRecord>({
|
||||
createMutationRecordMock({
|
||||
target: usernameField,
|
||||
type: "attributes",
|
||||
attributeName: "placeholder",
|
||||
@@ -1337,7 +1347,7 @@ describe("AutofillOverlayContentService", () => {
|
||||
|
||||
it("removes all attached style attributes and sets the default styles", () => {
|
||||
autofillOverlayContentService["handleOverlayElementMutationObserverUpdate"]([
|
||||
mock<MutationRecord>({
|
||||
createMutationRecordMock({
|
||||
target: usernameField,
|
||||
type: "attributes",
|
||||
attributeName: "style",
|
||||
|
||||
@@ -42,12 +42,12 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
||||
private overlayListElement: HTMLElement;
|
||||
private mostRecentlyFocusedField: ElementWithOpId<FormFieldElement>;
|
||||
private focusedFieldData: FocusedFieldData;
|
||||
private userInteractionEventTimeout: NodeJS.Timeout;
|
||||
private userInteractionEventTimeout: number | NodeJS.Timeout;
|
||||
private overlayElementsMutationObserver: MutationObserver;
|
||||
private bodyElementMutationObserver: MutationObserver;
|
||||
private documentElementMutationObserver: MutationObserver;
|
||||
private mutationObserverIterations = 0;
|
||||
private mutationObserverIterationsResetTimeout: NodeJS.Timeout;
|
||||
private mutationObserverIterationsResetTimeout: number | NodeJS.Timeout;
|
||||
private autofillFieldKeywordsMap: WeakMap<AutofillField, string> = new WeakMap();
|
||||
private eventHandlersMemo: { [key: string]: EventListener } = {};
|
||||
private readonly customElementDefaultStyles: Partial<CSSStyleDeclaration> = {
|
||||
@@ -846,7 +846,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
||||
|
||||
this.toggleOverlayHidden(true);
|
||||
this.clearUserInteractionEventTimeout();
|
||||
this.userInteractionEventTimeout = setTimeout(this.triggerOverlayRepositionUpdates, 750);
|
||||
this.userInteractionEventTimeout = setTimeout(
|
||||
this.triggerOverlayRepositionUpdates,
|
||||
750,
|
||||
) as unknown as number;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user