1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-09 12:59:20 +01:00

[PM-5189] Reworking how we handle updating ciphers within nested sub frames

This commit is contained in:
Cesar Gonzalez 2024-06-17 09:03:40 -05:00
parent 6685fafff3
commit 8e9b3afe1b
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF

View File

@ -252,7 +252,12 @@ export class OverlayBackground implements OverlayBackgroundInterface {
}; };
if (pageDetails.frameId !== 0 && pageDetails.details.fields.length) { if (pageDetails.frameId !== 0 && pageDetails.details.fields.length) {
void this.buildSubFrameOffsets(sender, pageDetails.details.url); void this.buildSubFrameOffsets(
pageDetails.tab,
pageDetails.frameId,
pageDetails.details.url,
sender,
);
void BrowserApi.tabSendMessage(pageDetails.tab, { void BrowserApi.tabSendMessage(pageDetails.tab, {
command: "setupRebuildSubFrameOffsetsListeners", command: "setupRebuildSubFrameOffsetsListeners",
}); });
@ -300,12 +305,18 @@ export class OverlayBackground implements OverlayBackgroundInterface {
* Builds the offset data for a sub frame of a tab. The offset data is used * Builds the offset data for a sub frame of a tab. The offset data is used
* to calculate the position of the inline menu list and button. * to calculate the position of the inline menu list and button.
* *
* @param sender - The sender of the message * @param tab - The tab that the sub frame is associated with
* @param frameId - The frame ID of the sub frame
* @param url - The URL of the sub frame * @param url - The URL of the sub frame
* @param sender - The sender of the message
*/ */
private async buildSubFrameOffsets(sender: chrome.runtime.MessageSender, url: string) { private async buildSubFrameOffsets(
tab: chrome.tabs.Tab,
frameId: number,
url: string,
sender: chrome.runtime.MessageSender,
) {
let subFrameDepth = 0; let subFrameDepth = 0;
const { tab, frameId } = sender;
const tabId = tab.id; const tabId = tab.id;
let subFrameOffsetsForTab = this.subFrameOffsetsForTab[tabId]; let subFrameOffsetsForTab = this.subFrameOffsetsForTab[tabId];
if (!subFrameOffsetsForTab) { if (!subFrameOffsetsForTab) {
@ -395,7 +406,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
const tabFrameIds = Array.from(subFrameOffsetsForTab.keys()); const tabFrameIds = Array.from(subFrameOffsetsForTab.keys());
for (const frameId of tabFrameIds) { for (const frameId of tabFrameIds) {
subFrameOffsetsForTab.delete(frameId); subFrameOffsetsForTab.delete(frameId);
await this.buildSubFrameOffsets(sender, sender.url); await this.buildSubFrameOffsets(sender.tab, frameId, sender.url, sender);
} }
} }
} }
@ -442,7 +453,7 @@ export class OverlayBackground implements OverlayBackgroundInterface {
const mostRecentlyFocusedFieldHasValue = await BrowserApi.tabSendMessage( const mostRecentlyFocusedFieldHasValue = await BrowserApi.tabSendMessage(
sender.tab, sender.tab,
{ command: "checkMostRecentlyFocusedFieldHasValue" }, { command: "checkMostRecentlyFocusedFieldHasValue" },
{ frameId: this.focusedFieldData.frameId }, { frameId: this.focusedFieldData?.frameId },
); );
if ( if (
mostRecentlyFocusedFieldHasValue && mostRecentlyFocusedFieldHasValue &&