mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 12:13:45 +00:00
[PM-5189] Reverting naming structure for OverlayBackground method
This commit is contained in:
@@ -173,5 +173,5 @@ export type InlineMenuListPortMessageHandlers = {
|
||||
export interface OverlayBackground {
|
||||
init(): Promise<void>;
|
||||
removePageDetails(tabId: number): void;
|
||||
updateInlineMenuCiphers(): void;
|
||||
updateOverlayCiphers(): void;
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ describe("OverlayBackground", () => {
|
||||
it("skips updating the overlay ciphers if the user's auth status is not unlocked", async () => {
|
||||
activeAccountStatusMock$.next(AuthenticationStatus.Locked);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(getTabFromCurrentWindowIdSpy).not.toHaveBeenCalled();
|
||||
expect(cipherService.getAllDecryptedForUrl).not.toHaveBeenCalled();
|
||||
@@ -697,7 +697,7 @@ describe("OverlayBackground", () => {
|
||||
overlayBackground["focusedFieldData"] = createFocusedFieldDataMock({ tabId: 1 });
|
||||
getTabSpy.mockResolvedValueOnce(previousTab);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
previousTab,
|
||||
@@ -709,7 +709,7 @@ describe("OverlayBackground", () => {
|
||||
it("ignores updating the overlay ciphers if the tab is undefined", async () => {
|
||||
getTabFromCurrentWindowIdSpy.mockResolvedValueOnce(undefined);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(getTabFromCurrentWindowIdSpy).toHaveBeenCalled();
|
||||
expect(cipherService.getAllDecryptedForUrl).not.toHaveBeenCalled();
|
||||
@@ -723,7 +723,7 @@ describe("OverlayBackground", () => {
|
||||
overlayBackground["focusedFieldData"] = createFocusedFieldDataMock({ tabId: 15 });
|
||||
getTabSpy.mockResolvedValueOnce(previousTab);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(tabsSendMessageSpy).toHaveBeenCalledWith(
|
||||
previousTab,
|
||||
@@ -737,7 +737,7 @@ describe("OverlayBackground", () => {
|
||||
cipherService.getAllDecryptedForUrl.mockResolvedValue([cipher1, cipher2]);
|
||||
cipherService.sortCiphersByLastUsedThenName.mockReturnValue(-1);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(BrowserApi.getTabFromCurrentWindowId).toHaveBeenCalled();
|
||||
expect(cipherService.getAllDecryptedForUrl).toHaveBeenCalledWith(url);
|
||||
@@ -756,7 +756,7 @@ describe("OverlayBackground", () => {
|
||||
cipherService.sortCiphersByLastUsedThenName.mockReturnValue(-1);
|
||||
getTabFromCurrentWindowIdSpy.mockResolvedValueOnce(tab);
|
||||
|
||||
await overlayBackground.updateInlineMenuCiphers();
|
||||
await overlayBackground.updateOverlayCiphers();
|
||||
|
||||
expect(overlayBackground["inlineMenuListPort"].postMessage).toHaveBeenCalledWith({
|
||||
command: "updateAutofillInlineMenuListCiphers",
|
||||
@@ -1542,7 +1542,7 @@ describe("OverlayBackground", () => {
|
||||
let updateInlineMenuCiphersSpy: jest.SpyInstance;
|
||||
|
||||
beforeEach(async () => {
|
||||
updateInlineMenuCiphersSpy = jest.spyOn(overlayBackground, "updateInlineMenuCiphers");
|
||||
updateInlineMenuCiphersSpy = jest.spyOn(overlayBackground, "updateOverlayCiphers");
|
||||
await initOverlayElementPorts();
|
||||
});
|
||||
|
||||
@@ -1557,7 +1557,7 @@ describe("OverlayBackground", () => {
|
||||
});
|
||||
|
||||
it("updates the overlay ciphers", async () => {
|
||||
const updateInlineMenuCiphersSpy = jest.spyOn(overlayBackground, "updateInlineMenuCiphers");
|
||||
const updateInlineMenuCiphersSpy = jest.spyOn(overlayBackground, "updateOverlayCiphers");
|
||||
sendMockExtensionMessage({ command: "unlockCompleted" });
|
||||
await flushPromises();
|
||||
|
||||
@@ -1597,13 +1597,13 @@ describe("OverlayBackground", () => {
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(overlayBackground, "updateInlineMenuCiphers").mockImplementation();
|
||||
jest.spyOn(overlayBackground, "updateOverlayCiphers").mockImplementation();
|
||||
});
|
||||
|
||||
extensionMessages.forEach((message) => {
|
||||
it(`triggers an update of the overlay ciphers when the ${message} message is received`, () => {
|
||||
sendMockExtensionMessage({ command: message });
|
||||
expect(overlayBackground.updateInlineMenuCiphers).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -107,10 +107,10 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
this.triggerDestroyInlineMenuListeners(sender.tab, message.subFrameData.frameId),
|
||||
collectPageDetailsResponse: ({ message, sender }) => this.storePageDetails(message, sender),
|
||||
unlockCompleted: ({ message }) => this.unlockCompleted(message),
|
||||
addedCipher: () => this.updateInlineMenuCiphers(),
|
||||
addEditCipherSubmitted: () => this.updateInlineMenuCiphers(),
|
||||
editedCipher: () => this.updateInlineMenuCiphers(),
|
||||
deletedCipher: () => this.updateInlineMenuCiphers(),
|
||||
addedCipher: () => this.updateOverlayCiphers(),
|
||||
addEditCipherSubmitted: () => this.updateOverlayCiphers(),
|
||||
editedCipher: () => this.updateOverlayCiphers(),
|
||||
deletedCipher: () => this.updateOverlayCiphers(),
|
||||
};
|
||||
private readonly inlineMenuButtonPortMessageHandlers: InlineMenuButtonPortMessageHandlers = {
|
||||
triggerDelayedAutofillInlineMenuClosure: ({ port }) => this.triggerDelayedInlineMenuClosure(),
|
||||
@@ -213,7 +213,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
* Queries all ciphers for the given url, and sorts them by last used. Will not update the
|
||||
* list of ciphers if the extension is not unlocked.
|
||||
*/
|
||||
async updateInlineMenuCiphers() {
|
||||
async updateOverlayCiphers() {
|
||||
const authStatus = await firstValueFrom(this.authService.activeAccountStatus$);
|
||||
if (authStatus !== AuthenticationStatus.Unlocked) {
|
||||
if (this.focusedFieldData) {
|
||||
@@ -1016,7 +1016,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
|
||||
*/
|
||||
private async unlockCompleted(message: OverlayBackgroundExtensionMessage) {
|
||||
await this.updateInlineMenuButtonAuthStatus();
|
||||
await this.updateInlineMenuCiphers();
|
||||
await this.updateOverlayCiphers();
|
||||
|
||||
if (message.data?.commandToRetry?.message?.command === "openAutofillInlineMenu") {
|
||||
await this.openInlineMenu(true);
|
||||
|
||||
@@ -75,7 +75,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sends a `windowChanged` message", async () => {
|
||||
@@ -93,7 +93,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sends a `tabChanged` message to the messaging service", async () => {
|
||||
@@ -129,7 +129,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sends a `tabChanged` message to the messaging service", async () => {
|
||||
@@ -161,7 +161,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).not.toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips updating the current tab data if the updated tab is not for the focusedWindowId", async () => {
|
||||
@@ -171,7 +171,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).not.toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips updating the current tab data if the updated tab is not active", async () => {
|
||||
@@ -181,7 +181,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).not.toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).not.toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("skips updating the badge, context menu and notification bar if the `onUpdatedRan` property of the main background class is set to `true`", async () => {
|
||||
@@ -206,7 +206,7 @@ describe("TabsBackground", () => {
|
||||
|
||||
expect(mainBackground.refreshBadge).toHaveBeenCalled();
|
||||
expect(mainBackground.refreshMenu).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateInlineMenuCiphers).toHaveBeenCalled();
|
||||
expect(overlayBackground.updateOverlayCiphers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("sends a `tabChanged` message to the messaging service", async () => {
|
||||
|
||||
@@ -94,7 +94,7 @@ export default class TabsBackground {
|
||||
return;
|
||||
}
|
||||
|
||||
this.overlayBackground.updateInlineMenuCiphers();
|
||||
this.overlayBackground.updateOverlayCiphers();
|
||||
|
||||
if (this.main.onUpdatedRan) {
|
||||
return;
|
||||
@@ -121,7 +121,7 @@ export default class TabsBackground {
|
||||
* for the current tab. Also updates the overlay ciphers.
|
||||
*/
|
||||
private updateCurrentTabData = async () => {
|
||||
this.overlayBackground.updateInlineMenuCiphers();
|
||||
this.overlayBackground.updateOverlayCiphers();
|
||||
await Promise.all([this.main.refreshBadge(), this.main.refreshMenu()]);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1259,7 +1259,7 @@ export default class MainBackground {
|
||||
|
||||
await this.refreshBadge();
|
||||
await this.refreshMenu();
|
||||
await this.overlayBackground?.updateInlineMenuCiphers(); // null in popup only contexts
|
||||
await this.overlayBackground?.updateOverlayCiphers(); // null in popup only contexts
|
||||
this.messagingService.send("goHome");
|
||||
return;
|
||||
}
|
||||
@@ -1282,7 +1282,7 @@ export default class MainBackground {
|
||||
this.messagingService.send("unlocked", { userId: userId });
|
||||
await this.refreshBadge();
|
||||
await this.refreshMenu();
|
||||
await this.overlayBackground?.updateInlineMenuCiphers(); // null in popup only contexts
|
||||
await this.overlayBackground?.updateOverlayCiphers(); // null in popup only contexts
|
||||
await this.syncService.fullSync(false);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user