diff --git a/apps/browser/src/autofill/services/collect-autofill-content.service.ts b/apps/browser/src/autofill/services/collect-autofill-content.service.ts index 4e67830553..6791d43086 100644 --- a/apps/browser/src/autofill/services/collect-autofill-content.service.ts +++ b/apps/browser/src/autofill/services/collect-autofill-content.service.ts @@ -20,6 +20,7 @@ import { elementIsTextAreaElement, nodeIsFormElement, nodeIsInputElement, + sendExtensionMessage, } from "../utils"; import { AutofillOverlayContentService } from "./abstractions/autofill-overlay-content.service"; @@ -69,6 +70,11 @@ class CollectAutofillContentService implements CollectAutofillContentServiceInte inputQuery += `:not([type="${type}"])`; } this.formFieldQueryString = `${inputQuery}, textarea:not([data-bwignore]), select:not([data-bwignore]), span[data-bwautofill]`; + + void sendExtensionMessage("getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag").then( + (useTreeWalkerStrategyFlag) => + (this.useTreeWalkerStrategyFlagSet = !!useTreeWalkerStrategyFlag?.result), + ); } /** diff --git a/apps/browser/src/background/runtime.background.ts b/apps/browser/src/background/runtime.background.ts index 1db32659d2..b550dc90be 100644 --- a/apps/browser/src/background/runtime.background.ts +++ b/apps/browser/src/background/runtime.background.ts @@ -4,6 +4,7 @@ import { NotificationsService } from "@bitwarden/common/abstractions/notificatio import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AutofillOverlayVisibility } from "@bitwarden/common/autofill/constants"; import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service"; +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 { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service"; @@ -65,7 +66,10 @@ export default class RuntimeBackground { sender: chrome.runtime.MessageSender, sendResponse: (response: any) => void, ) => { - const messagesWithResponse = ["biometricUnlock"]; + const messagesWithResponse = [ + "biometricUnlock", + "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag", + ]; if (messagesWithResponse.includes(msg.command)) { this.processMessageWithSender(msg, sender).then( @@ -177,6 +181,11 @@ export default class RuntimeBackground { const result = await this.main.biometricUnlock(); return result; } + case "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag": { + return await this.configService.getFeatureFlag( + FeatureFlag.UseTreeWalkerApiForPageDetailsCollection, + ); + } } } diff --git a/libs/common/src/enums/feature-flag.enum.ts b/libs/common/src/enums/feature-flag.enum.ts index ef8c4d61e4..dd400da7bb 100644 --- a/libs/common/src/enums/feature-flag.enum.ts +++ b/libs/common/src/enums/feature-flag.enum.ts @@ -17,6 +17,7 @@ export enum FeatureFlag { EnableDeleteProvider = "AC-1218-delete-provider", ExtensionRefresh = "extension-refresh", RestrictProviderAccess = "restrict-provider-access", + UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection", } export type AllowedFeatureFlagTypes = boolean | number | string; @@ -44,6 +45,7 @@ export const DefaultFeatureFlagValue = { [FeatureFlag.EnableDeleteProvider]: FALSE, [FeatureFlag.ExtensionRefresh]: FALSE, [FeatureFlag.RestrictProviderAccess]: FALSE, + [FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE, } satisfies Record; export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;