1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-28 12:45:45 +01:00

[PM-14349] Collection of page details on websites with ShadowDOM elements might not capture form elements (#11809)

This commit is contained in:
Cesar Gonzalez 2024-11-01 11:17:36 -05:00 committed by GitHub
parent 00e1c936fb
commit 227e9c4c22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -980,7 +980,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
const queueLength = this.mutationsQueue.length; const queueLength = this.mutationsQueue.length;
if (!this.domQueryService.pageContainsShadowDomElements()) { if (!this.domQueryService.pageContainsShadowDomElements()) {
this.domQueryService.checkPageContainsShadowDom(); this.checkPageContainsShadowDom();
} }
for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) { for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) {
@ -999,6 +999,29 @@ 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
* occur again on a subsequent call after a mutation has been observed in the DOM.
*/
private flagPageDetailsUpdateIsRequired() {
this.domRecentlyMutated = true;
if (this.autofillOverlayContentService) {
this.autofillOverlayContentService.pageDetailsUpdateRequired = true;
}
this.noFieldsFound = false;
}
/** /**
* Processes all mutation records encountered by the mutation observer. * Processes all mutation records encountered by the mutation observer.
* *
@ -1023,11 +1046,7 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
(this.isAutofillElementNodeMutated(mutation.removedNodes, true) || (this.isAutofillElementNodeMutated(mutation.removedNodes, true) ||
this.isAutofillElementNodeMutated(mutation.addedNodes)) this.isAutofillElementNodeMutated(mutation.addedNodes))
) { ) {
this.domRecentlyMutated = true; this.flagPageDetailsUpdateIsRequired();
if (this.autofillOverlayContentService) {
this.autofillOverlayContentService.pageDetailsUpdateRequired = true;
}
this.noFieldsFound = false;
return; return;
} }