diff --git a/apps/browser/src/autofill/background/overlay-notifications.background.spec.ts b/apps/browser/src/autofill/background/overlay-notifications.background.spec.ts index 57930496978..a51757dabea 100644 --- a/apps/browser/src/autofill/background/overlay-notifications.background.spec.ts +++ b/apps/browser/src/autofill/background/overlay-notifications.background.spec.ts @@ -1,8 +1,6 @@ import { mock, MockProxy } from "jest-mock-extended"; -import { BehaviorSubject } from "rxjs"; import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { EnvironmentServerConfigData } from "@bitwarden/common/platform/models/data/server-config.data"; @@ -25,8 +23,6 @@ import { OverlayNotificationsBackground } from "./overlay-notifications.backgrou describe("OverlayNotificationsBackground", () => { let logService: MockProxy; - let getFeatureFlagMock$: BehaviorSubject; - let configService: MockProxy; let notificationBackground: NotificationBackground; let getEnableChangedPasswordPromptSpy: jest.SpyInstance; let getEnableAddedLoginPromptSpy: jest.SpyInstance; @@ -35,10 +31,6 @@ describe("OverlayNotificationsBackground", () => { beforeEach(async () => { jest.useFakeTimers(); logService = mock(); - getFeatureFlagMock$ = new BehaviorSubject(true); - configService = mock({ - getFeatureFlag$: jest.fn().mockReturnValue(getFeatureFlagMock$), - }); notificationBackground = mock(); getEnableChangedPasswordPromptSpy = jest .spyOn(notificationBackground, "getEnableChangedPasswordPrompt") @@ -48,10 +40,8 @@ describe("OverlayNotificationsBackground", () => { .mockResolvedValue(true); overlayNotificationsBackground = new OverlayNotificationsBackground( logService, - configService, notificationBackground, ); - configService.getFeatureFlag.mockResolvedValue(true); await overlayNotificationsBackground.init(); }); @@ -60,27 +50,6 @@ describe("OverlayNotificationsBackground", () => { jest.clearAllTimers(); }); - describe("feature flag behavior", () => { - let runtimeRemoveListenerSpy: jest.SpyInstance; - - beforeEach(() => { - runtimeRemoveListenerSpy = jest.spyOn(chrome.runtime.onMessage, "removeListener"); - }); - - it("removes the extension listeners if the current flag value is set to `false`", () => { - getFeatureFlagMock$.next(false); - - expect(runtimeRemoveListenerSpy).toHaveBeenCalled(); - }); - - it("ignores the feature flag change if the previous flag value is equal to the current flag value", () => { - getFeatureFlagMock$.next(false); - getFeatureFlagMock$.next(false); - - expect(runtimeRemoveListenerSpy).toHaveBeenCalledTimes(1); - }); - }); - describe("setting up the form submission listeners", () => { let fields: MockProxy[]; let details: MockProxy; diff --git a/apps/browser/src/autofill/background/overlay-notifications.background.ts b/apps/browser/src/autofill/background/overlay-notifications.background.ts index ce30dd462b3..5c85ce132d7 100644 --- a/apps/browser/src/autofill/background/overlay-notifications.background.ts +++ b/apps/browser/src/autofill/background/overlay-notifications.background.ts @@ -1,11 +1,8 @@ // FIXME: Update this file to be type safe and remove this and next line // @ts-strict-ignore -import { startWith, Subject, Subscription, switchMap, timer } from "rxjs"; -import { pairwise } from "rxjs/operators"; +import { Subject, switchMap, timer } from "rxjs"; import { CLEAR_NOTIFICATION_LOGIN_DATA_DURATION } from "@bitwarden/common/autofill/constants"; -import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum"; -import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service"; import { LogService } from "@bitwarden/common/platform/abstractions/log.service"; import { BrowserApi } from "../../platform/browser/browser-api"; @@ -26,7 +23,6 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg private websiteOriginsWithFields: WebsiteOriginsWithFields = new Map(); private activeFormSubmissionRequests: ActiveFormSubmissionRequests = new Set(); private modifyLoginCipherFormData: ModifyLoginCipherFormDataForTab = new Map(); - private featureFlagState$: Subscription; private clearLoginCipherFormDataSubject: Subject = new Subject(); private notificationFallbackTimeout: number | NodeJS.Timeout | null; private readonly formSubmissionRequestMethods: Set = new Set(["POST", "PUT", "PATCH"]); @@ -38,7 +34,6 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg constructor( private logService: LogService, - private configService: ConfigService, private notificationBackground: NotificationBackground, ) {} @@ -46,35 +41,13 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg * Initialize the overlay notifications background service. */ async init() { - this.featureFlagState$ = this.configService - .getFeatureFlag$(FeatureFlag.NotificationBarAddLoginImprovements) - .pipe(startWith(undefined), pairwise()) - .subscribe(([prev, current]) => this.handleInitFeatureFlagChange(prev, current)); + this.setupExtensionListeners(); + this.clearLoginCipherFormDataSubject .pipe(switchMap(() => timer(CLEAR_NOTIFICATION_LOGIN_DATA_DURATION))) .subscribe(() => this.modifyLoginCipherFormData.clear()); } - /** - * Handles enabling/disabling the extension listeners that trigger the - * overlay notifications based on the feature flag state. - * - * @param previousValue - The previous value of the feature flag - * @param currentValue - The current value of the feature flag - */ - private handleInitFeatureFlagChange = (previousValue: boolean, currentValue: boolean) => { - if (previousValue === currentValue) { - return; - } - - if (currentValue) { - this.setupExtensionListeners(); - return; - } - - this.removeExtensionListeners(); - }; - /** * Handles the response from the content script with the page details. Triggers an initialization * of the add login or change password notification if the conditions are met. @@ -520,15 +493,6 @@ export class OverlayNotificationsBackground implements OverlayNotificationsBackg chrome.tabs.onUpdated.addListener(this.handleTabUpdated); } - /** - * Removes the listeners for the extension messages and the tab events. - */ - private removeExtensionListeners() { - BrowserApi.removeListener(chrome.runtime.onMessage, this.handleExtensionMessage); - chrome.tabs.onRemoved.removeListener(this.handleTabRemoved); - chrome.tabs.onUpdated.removeListener(this.handleTabUpdated); - } - /** * Handles messages that are sent to the extension background. * diff --git a/apps/browser/src/autofill/content/notification-bar.ts b/apps/browser/src/autofill/content/notification-bar.ts deleted file mode 100644 index bf3d562a0ef..00000000000 --- a/apps/browser/src/autofill/content/notification-bar.ts +++ /dev/null @@ -1,1082 +0,0 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore -import { ServerConfig } from "@bitwarden/common/platform/abstractions/config/server-config"; - -import { - AddLoginMessageData, - ChangePasswordMessageData, -} from "../background/abstractions/notification.background"; -import AutofillField from "../models/autofill-field"; -import { WatchedForm } from "../models/watched-form"; -import { NotificationBarIframeInitData } from "../notification/abstractions/notification-bar"; -import { NotificationTypeData } from "../overlay/notifications/abstractions/overlay-notifications-content.service"; -import { FormData } from "../services/abstractions/autofill.service"; -import { sendExtensionMessage, setupExtensionDisconnectAction } from "../utils"; - -interface HTMLElementWithFormOpId extends HTMLElement { - formOpId: string; -} - -/** - * @fileoverview This file contains the code for the Bitwarden Notification Bar content script. - * The notification bar is used to notify logged in users that they can - * save a new login, change a existing password on a password change screen, - * or update an existing login after detecting a different password on login. - * - * Note: content scripts are reloaded on non-SPA page change. - */ - -/* - * Run content script when the DOM is fully loaded - * - * The DOMContentLoaded event fires when the HTML document has been completely parsed, - * and all deferred scripts (