mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +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:
@@ -7,5 +7,4 @@ export interface DomQueryService {
|
|||||||
forceDeepQueryAttempt?: boolean,
|
forceDeepQueryAttempt?: boolean,
|
||||||
): T[];
|
): T[];
|
||||||
checkPageContainsShadowDom(): void;
|
checkPageContainsShadowDom(): void;
|
||||||
pageContainsShadowDomElements(): boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -998,10 +998,6 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
|
|||||||
private processMutations = () => {
|
private processMutations = () => {
|
||||||
const queueLength = this.mutationsQueue.length;
|
const queueLength = this.mutationsQueue.length;
|
||||||
|
|
||||||
if (!this.domQueryService.pageContainsShadowDomElements()) {
|
|
||||||
this.checkPageContainsShadowDom();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) {
|
for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) {
|
||||||
const mutations = this.mutationsQueue[queueIndex];
|
const mutations = this.mutationsQueue[queueIndex];
|
||||||
const processMutationRecords = () => {
|
const processMutationRecords = () => {
|
||||||
@@ -1018,17 +1014,6 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
|
|||||||
this.mutationsQueue = [];
|
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
|
* 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.
|
* occur again on a subsequent call after a mutation has been observed in the DOM.
|
||||||
|
|||||||
@@ -7,10 +7,6 @@ jest.mock("../utils", () => {
|
|||||||
return {
|
return {
|
||||||
...actualUtils,
|
...actualUtils,
|
||||||
sendExtensionMessage: jest.fn((command, options) => {
|
sendExtensionMessage: jest.fn((command, options) => {
|
||||||
if (command === "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag") {
|
|
||||||
return Promise.resolve({ result: false });
|
|
||||||
}
|
|
||||||
|
|
||||||
return chrome.runtime.sendMessage(Object.assign({ command }, options));
|
return chrome.runtime.sendMessage(Object.assign({ command }, options));
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { EVENTS, MAX_DEEP_QUERY_RECURSION_DEPTH } from "@bitwarden/common/autofill/constants";
|
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";
|
import { DomQueryService as DomQueryServiceInterface } from "./abstractions/dom-query.service";
|
||||||
|
|
||||||
export class DomQueryService implements DomQueryServiceInterface {
|
export class DomQueryService implements DomQueryServiceInterface {
|
||||||
private pageContainsShadowDom: boolean;
|
private pageContainsShadowDom: boolean;
|
||||||
private useTreeWalkerStrategyFlagSet = true;
|
|
||||||
private ignoredTreeWalkerNodes = new Set([
|
private ignoredTreeWalkerNodes = new Set([
|
||||||
"svg",
|
"svg",
|
||||||
"script",
|
"script",
|
||||||
@@ -56,7 +55,7 @@ export class DomQueryService implements DomQueryServiceInterface {
|
|||||||
): T[] {
|
): T[] {
|
||||||
const ignoredTreeWalkerNodes = ignoredTreeWalkerNodesOverride || this.ignoredTreeWalkerNodes;
|
const ignoredTreeWalkerNodes = ignoredTreeWalkerNodesOverride || this.ignoredTreeWalkerNodes;
|
||||||
|
|
||||||
if (!forceDeepQueryAttempt && this.pageContainsShadowDomElements()) {
|
if (!forceDeepQueryAttempt) {
|
||||||
return this.queryAllTreeWalkerNodes<T>(
|
return this.queryAllTreeWalkerNodes<T>(
|
||||||
root,
|
root,
|
||||||
treeWalkerFilter,
|
treeWalkerFilter,
|
||||||
@@ -84,24 +83,10 @@ export class DomQueryService implements DomQueryServiceInterface {
|
|||||||
this.pageContainsShadowDom = this.queryShadowRoots(globalThis.document.body, true).length > 0;
|
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.
|
* Initializes the DomQueryService, checking for the presence of shadow DOM elements on the page.
|
||||||
*/
|
*/
|
||||||
private async init() {
|
private async init() {
|
||||||
const useTreeWalkerStrategyFlag = await sendExtensionMessage(
|
|
||||||
"getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag",
|
|
||||||
);
|
|
||||||
if (useTreeWalkerStrategyFlag && typeof useTreeWalkerStrategyFlag.result === "boolean") {
|
|
||||||
this.useTreeWalkerStrategyFlagSet = useTreeWalkerStrategyFlag.result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (globalThis.document.readyState === "complete") {
|
if (globalThis.document.readyState === "complete") {
|
||||||
this.checkPageContainsShadowDom();
|
this.checkPageContainsShadowDom();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import { AccountService } from "@bitwarden/common/auth/abstractions/account.serv
|
|||||||
import { AutofillOverlayVisibility, ExtensionCommand } from "@bitwarden/common/autofill/constants";
|
import { AutofillOverlayVisibility, ExtensionCommand } from "@bitwarden/common/autofill/constants";
|
||||||
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
import { AutofillSettingsServiceAbstraction } from "@bitwarden/common/autofill/services/autofill-settings.service";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.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 { ProcessReloadServiceAbstraction } from "@bitwarden/common/key-management/abstractions/process-reload.service";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
@@ -80,7 +79,6 @@ export default class RuntimeBackground {
|
|||||||
BiometricsCommands.UnlockWithBiometricsForUser,
|
BiometricsCommands.UnlockWithBiometricsForUser,
|
||||||
BiometricsCommands.GetBiometricsStatusForUser,
|
BiometricsCommands.GetBiometricsStatusForUser,
|
||||||
BiometricsCommands.CanEnableBiometricUnlock,
|
BiometricsCommands.CanEnableBiometricUnlock,
|
||||||
"getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag",
|
|
||||||
"getUserPremiumStatus",
|
"getUserPremiumStatus",
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -205,11 +203,6 @@ export default class RuntimeBackground {
|
|||||||
case BiometricsCommands.CanEnableBiometricUnlock: {
|
case BiometricsCommands.CanEnableBiometricUnlock: {
|
||||||
return await this.main.biometricsService.canEnableBiometricUnlock();
|
return await this.main.biometricsService.canEnableBiometricUnlock();
|
||||||
}
|
}
|
||||||
case "getUseTreeWalkerApiForPageDetailsCollectionFeatureFlag": {
|
|
||||||
return await this.configService.getFeatureFlag(
|
|
||||||
FeatureFlag.UseTreeWalkerApiForPageDetailsCollection,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
case "getUserPremiumStatus": {
|
case "getUserPremiumStatus": {
|
||||||
const activeUserId = await firstValueFrom(
|
const activeUserId = await firstValueFrom(
|
||||||
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
this.accountService.activeAccount$.pipe(map((a) => a?.id)),
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export enum FeatureFlag {
|
|||||||
|
|
||||||
/* Autofill */
|
/* Autofill */
|
||||||
NotificationRefresh = "notification-refresh",
|
NotificationRefresh = "notification-refresh",
|
||||||
UseTreeWalkerApiForPageDetailsCollection = "use-tree-walker-api-for-page-details-collection",
|
|
||||||
MacOsNativeCredentialSync = "macos-native-credential-sync",
|
MacOsNativeCredentialSync = "macos-native-credential-sync",
|
||||||
WindowsDesktopAutotype = "windows-desktop-autotype",
|
WindowsDesktopAutotype = "windows-desktop-autotype",
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ export const DefaultFeatureFlagValue = {
|
|||||||
|
|
||||||
/* Autofill */
|
/* Autofill */
|
||||||
[FeatureFlag.NotificationRefresh]: FALSE,
|
[FeatureFlag.NotificationRefresh]: FALSE,
|
||||||
[FeatureFlag.UseTreeWalkerApiForPageDetailsCollection]: FALSE,
|
|
||||||
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
|
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
|
||||||
[FeatureFlag.WindowsDesktopAutotype]: FALSE,
|
[FeatureFlag.WindowsDesktopAutotype]: FALSE,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user