mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
[PM-5189] Adding a test to the overlay iframe service
This commit is contained in:
@@ -202,6 +202,23 @@ describe("AutofillOverlayIframeService", () => {
|
|||||||
).not.toHaveBeenCalled();
|
).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", () => {
|
describe("initializing the overlay list", () => {
|
||||||
let updateElementStylesSpy: jest.SpyInstance;
|
let updateElementStylesSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
*/
|
*/
|
||||||
private createAriaAlertElement(ariaAlertText: string) {
|
private createAriaAlertElement(ariaAlertText: string) {
|
||||||
this.ariaAlertElement = globalThis.document.createElement("div");
|
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-live", "polite");
|
||||||
this.ariaAlertElement.setAttribute("aria-atomic", "true");
|
this.ariaAlertElement.setAttribute("aria-atomic", "true");
|
||||||
this.updateElementStyles(this.ariaAlertElement, {
|
this.updateElementStyles(this.ariaAlertElement, {
|
||||||
@@ -182,6 +182,13 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
this.postMessageToIFrame(message);
|
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) {
|
private initAutofillOverlay(message: AutofillOverlayIframeExtensionMessage) {
|
||||||
this.portKey = message.portKey;
|
this.portKey = message.portKey;
|
||||||
if (message.command === "initAutofillOverlayList") {
|
if (message.command === "initAutofillOverlayList") {
|
||||||
@@ -193,8 +200,8 @@ class AutofillOverlayIframeService implements AutofillOverlayIframeServiceInterf
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles messages sent from the iframe to the extension background script.
|
* Handles initialization of the autofill overlay list. This includes setting
|
||||||
* Will adjust the border element to fit the user's set theme.
|
* the theme and sending a message to the iframe to initialize the overlay.
|
||||||
*
|
*
|
||||||
* @param message - The message sent from the iframe
|
* @param message - The message sent from the iframe
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user