mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-06 23:51:28 +01:00
[PM-5189] Adding a test to the overlay iframe service
This commit is contained in:
parent
ab80443073
commit
4c986425b3
@ -202,6 +202,23 @@ describe("AutofillOverlayIframeService", () => {
|
||||
).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
describe("initializing the overlay button", () => {
|
||||
it("sets the port key and posts the message to the overlay page iframe", () => {
|
||||
const portKey = "portKey";
|
||||
const message = {
|
||||
command: "initAutofillOverlayButton",
|
||||
portKey,
|
||||
};
|
||||
|
||||
sendPortMessage(portSpy, message);
|
||||
|
||||
expect(autofillOverlayIframeService["portKey"]).toBe(portKey);
|
||||
expect(
|
||||
autofillOverlayIframeService["iframe"].contentWindow.postMessage,
|
||||
).toHaveBeenCalledWith(message, "*");
|
||||
});
|
||||
});
|
||||
|
||||
describe("initializing the overlay list", () => {
|
||||
let updateElementStylesSpy: jest.SpyInstance;
|
||||
|
||||
|
@ -93,7 +93,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
||||
*/
|
||||
private createAriaAlertElement(ariaAlertText: string) {
|
||||
this.ariaAlertElement = globalThis.document.createElement("div");
|
||||
this.ariaAlertElement.setAttribute("role", "status");
|
||||
this.ariaAlertElement.setAttribute("role", "alert");
|
||||
this.ariaAlertElement.setAttribute("aria-live", "polite");
|
||||
this.ariaAlertElement.setAttribute("aria-atomic", "true");
|
||||
this.updateElementStyles(this.ariaAlertElement, {
|
||||
@ -182,6 +182,13 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
||||
this.postMessageToIFrame(message);
|
||||
};
|
||||
|
||||
/**
|
||||
* Handles the initialization of the autofill overlay. This includes setting
|
||||
* the port key and sending a message to the iframe to initialize the overlay.
|
||||
*
|
||||
* @param message
|
||||
* @private
|
||||
*/
|
||||
private initAutofillOverlay(message: AutofillOverlayIframeExtensionMessage) {
|
||||
this.portKey = message.portKey;
|
||||
if (message.command === "initAutofillOverlayList") {
|
||||
@ -193,8 +200,8 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles messages sent from the iframe to the extension background script.
|
||||
* Will adjust the border element to fit the user's set theme.
|
||||
* Handles initialization of the autofill overlay list. This includes setting
|
||||
* the theme and sending a message to the iframe to initialize the overlay.
|
||||
*
|
||||
* @param message - The message sent from the iframe
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user