[PM-5295] Incorporating methodology for triggering a fallback to the TreeWalker API if issues arise with the deepQuery approach

This commit is contained in:
Cesar Gonzalez 2024-05-10 16:10:43 -05:00
parent c0533c1aca
commit 3eb4f38466
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF
3 changed files with 18 additions and 1 deletions

View File

@ -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),
);
}
/**

View File

@ -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,
);
}
}
}

View File

@ -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<FeatureFlag, AllowedFeatureFlagTypes>;
export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;