mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
[PM-5189] Fixing an issue found with iframe service
This commit is contained in:
@@ -9,7 +9,8 @@ import {
|
|||||||
} from "../abstractions/autofill-inline-menu-iframe.service";
|
} from "../abstractions/autofill-inline-menu-iframe.service";
|
||||||
|
|
||||||
export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframeServiceInterface {
|
export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframeServiceInterface {
|
||||||
private sendExtensionMessage = sendExtensionMessage;
|
private readonly setElementStyles = setElementStyles;
|
||||||
|
private readonly sendExtensionMessage = sendExtensionMessage;
|
||||||
private port: chrome.runtime.Port | null = null;
|
private port: chrome.runtime.Port | null = null;
|
||||||
private portKey: string;
|
private portKey: string;
|
||||||
private iframeMutationObserver: MutationObserver;
|
private iframeMutationObserver: MutationObserver;
|
||||||
@@ -288,12 +289,42 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
|
|
||||||
this.unobserveIframe();
|
this.unobserveIframe();
|
||||||
|
|
||||||
setElementStyles(customElement, styles, true);
|
this.setElementStyles(customElement, styles, true);
|
||||||
this.iframeStyles = { ...this.iframeStyles, ...styles };
|
if (customElement === this.iframe) {
|
||||||
|
this.iframeStyles = { ...this.iframeStyles, ...styles };
|
||||||
|
}
|
||||||
|
|
||||||
this.observeIframe();
|
this.observeIframe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers a forced closure of the autofill inline menu. This is used when the
|
||||||
|
* mutation observer is triggered excessively.
|
||||||
|
*/
|
||||||
|
private forceCloseInlineMenu() {
|
||||||
|
void this.sendExtensionMessage("closeAutofillInlineMenu", { forceClose: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers a delayed closure of the inline menu to ensure that click events are
|
||||||
|
* caught if focus is programmatically redirected away from the inline menu.
|
||||||
|
*/
|
||||||
|
private handleDelayedAutofillInlineMenuClosure() {
|
||||||
|
if (this.delayedCloseTimeout) {
|
||||||
|
clearTimeout(this.delayedCloseTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateElementStyles(this.iframe, {
|
||||||
|
transition: this.fadeOutOpacityTransition,
|
||||||
|
opacity: "0",
|
||||||
|
});
|
||||||
|
|
||||||
|
this.delayedCloseTimeout = globalThis.setTimeout(() => {
|
||||||
|
this.updateElementStyles(this.iframe, { transition: this.fadeInOpacityTransition });
|
||||||
|
this.forceCloseInlineMenu();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles mutations to the iframe element. The ensures that the iframe
|
* Handles mutations to the iframe element. The ensures that the iframe
|
||||||
* element's styles are not modified by a third party source.
|
* element's styles are not modified by a third party source.
|
||||||
@@ -323,34 +354,6 @@ export class AutofillInlineMenuIframeService implements AutofillInlineMenuIframe
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggers a forced closure of the autofill inline menu. This is used when the
|
|
||||||
* mutation observer is triggered excessively.
|
|
||||||
*/
|
|
||||||
private forceCloseInlineMenu() {
|
|
||||||
void this.sendExtensionMessage("closeAutofillInlineMenu", { forceClose: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Triggers a delayed closure of the inline menu to ensure that click events are
|
|
||||||
* caught if focus is programmatically redirected away from the inline menu.
|
|
||||||
*/
|
|
||||||
private handleDelayedAutofillInlineMenuClosure() {
|
|
||||||
if (this.delayedCloseTimeout) {
|
|
||||||
clearTimeout(this.delayedCloseTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.updateElementStyles(this.iframe, {
|
|
||||||
transition: this.fadeOutOpacityTransition,
|
|
||||||
opacity: "0",
|
|
||||||
});
|
|
||||||
|
|
||||||
this.delayedCloseTimeout = globalThis.setTimeout(() => {
|
|
||||||
this.updateElementStyles(this.iframe, { transition: this.fadeInOpacityTransition });
|
|
||||||
this.forceCloseInlineMenu();
|
|
||||||
}, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles mutations to the iframe element's attributes. This ensures that
|
* Handles mutations to the iframe element's attributes. This ensures that
|
||||||
* the iframe element's attributes are not modified by a third party source.
|
* the iframe element's attributes are not modified by a third party source.
|
||||||
|
|||||||
Reference in New Issue
Block a user