1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

Remove UseTreeWalkerApiForPageDetailsCollection feature flag (#16130)

* remove flag and instances of use

* feedback jprusik: additional removals of pageContainsShadowDomElements

* feedback jprusik: remove a stray logic branch
This commit is contained in:
neuronull
2025-09-02 08:46:30 -06:00
committed by GitHub
parent 1ae5a7798d
commit 048d8a5f79
6 changed files with 2 additions and 46 deletions

View File

@@ -7,5 +7,4 @@ export interface DomQueryService {
forceDeepQueryAttempt?: boolean,
): T[];
checkPageContainsShadowDom(): void;
pageContainsShadowDomElements(): boolean;
}

View File

@@ -998,10 +998,6 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
private processMutations = () => {
const queueLength = this.mutationsQueue.length;
if (!this.domQueryService.pageContainsShadowDomElements()) {
this.checkPageContainsShadowDom();
}
for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) {
const mutations = this.mutationsQueue[queueIndex];
const processMutationRecords = () => {
@@ -1018,17 +1014,6 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
this.mutationsQueue = [];
};
/**
* Handles checking if the current page contains a ShadowDOM element and
* flags that a re-collection of page details is required if it does.
*/
private checkPageContainsShadowDom() {
this.domQueryService.checkPageContainsShadowDom();
if (this.domQueryService.pageContainsShadowDomElements()) {
this.flagPageDetailsUpdateIsRequired();
}
}
/**
* Triggers several flags that indicate that a collection of page details should
* occur again on a subsequent call after a mutation has been observed in the DOM.

View File

@@ -7,10 +7,6 @@ jest.mock("../utils", () => {
return {
...actualUtils,
sendExtensionMessage: jest.fn((command, options) => {
if (command === "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag") {
return Promise.resolve({ result: false });
}
return chrome.runtime.sendMessage(Object.assign({ command }, options));
}),
};

View File

@@ -2,13 +2,12 @@
// @ts-strict-ignore
import { EVENTS, MAX_DEEP_QUERY_RECURSION_DEPTH } from "@bitwarden/common/autofill/constants";
import { nodeIsElement, sendExtensionMessage } from "../utils";
import { nodeIsElement } from "../utils";
import { DomQueryService as DomQueryServiceInterface } from "./abstractions/dom-query.service";
export class DomQueryService implements DomQueryServiceInterface {
private pageContainsShadowDom: boolean;
private useTreeWalkerStrategyFlagSet = true;
private ignoredTreeWalkerNodes = new Set([
"svg",
"script",
@@ -56,7 +55,7 @@ export class DomQueryService implements DomQueryServiceInterface {
): T[] {
const ignoredTreeWalkerNodes = ignoredTreeWalkerNodesOverride || this.ignoredTreeWalkerNodes;
if (!forceDeepQueryAttempt && this.pageContainsShadowDomElements()) {
if (!forceDeepQueryAttempt) {
return this.queryAllTreeWalkerNodes<T>(
root,
treeWalkerFilter,
@@ -84,24 +83,10 @@ export class DomQueryService implements DomQueryServiceInterface {
this.pageContainsShadowDom = this.queryShadowRoots(globalThis.document.body, true).length > 0;
};
/**
* Determines whether to use the treeWalker strategy for querying the DOM.
*/
pageContainsShadowDomElements(): boolean {
return this.useTreeWalkerStrategyFlagSet || this.pageContainsShadowDom;
}
/**
* Initializes the DomQueryService, checking for the presence of shadow DOM elements on the page.
*/
private async init() {
const useTreeWalkerStrategyFlag = await sendExtensionMessage(
"getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag",
);
if (useTreeWalkerStrategyFlag && typeof useTreeWalkerStrategyFlag.result === "boolean") {
this.useTreeWalkerStrategyFlagSet = useTreeWalkerStrategyFlag.result;
}
if (globalThis.document.readyState === "complete") {
this.checkPageContainsShadowDom();
return;

View File

@@ -7,7 +7,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
import { AutofillOverlayVisibility, ExtensionCommand } from "@bitwarden/common/autofill/constants";
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
@@ -80,7 +79,6 @@ export default class RuntimeBackground {
BiometricsCommands.UnlockWithBiometricsForUser,
BiometricsCommands.GetBiometricsStatusForUser,
BiometricsCommands.CanEnableBiometricUnlock,
"getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag",
"getUserPremiumStatus",
];
@@ -205,11 +203,6 @@ export default class RuntimeBackground {
case BiometricsCommands.CanEnableBiometricUnlock: {
return await this.main.biometricsService.canEnableBiometricUnlock();
}
case "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag": {
return await this.configService.getFeatureFlag(
FeatureFlag.UseTreeWalkerApiForPageDetailsCollection,
);
}
case "getUserPremiumStatus": {
const activeUserId = await firstValueFrom(
this.accountService.activeAccount$.pipe(map((a) => a?.id)),

View File

@@ -18,7 +18,6 @@ export enum FeatureFlag {
/* Autofill */
NotificationRefresh = "notification-refresh",
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
MacOsNativeCredentialSync = "macos-native-credential-sync",
WindowsDesktopAutotype = "windows-desktop-autotype",
@@ -74,7 +73,6 @@ export const DefaultFeatureFlagValue = {
/* Autofill */
[FeatureFlag.NotificationRefresh]: FALSE,
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
[FeatureFlag.WindowsDesktopAutotype]: FALSE,