mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
[PM-5189] Fix issues present with inline menu rendering within iframes
This commit is contained in:
@@ -2,9 +2,26 @@ import { CipherType } from "@bitwarden/common/vault/enums";
|
|||||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
||||||
|
|
||||||
import AutofillPageDetails from "../../models/autofill-page-details";
|
import AutofillPageDetails from "../../models/autofill-page-details";
|
||||||
|
import { PageDetail } from "../../services/abstractions/autofill.service";
|
||||||
|
|
||||||
import { LockedVaultPendingNotificationsData } from "./notification.background";
|
import { LockedVaultPendingNotificationsData } from "./notification.background";
|
||||||
|
|
||||||
|
type PageDetailsForTab = Record<
|
||||||
|
chrome.runtime.MessageSender["tab"]["id"],
|
||||||
|
Map<chrome.runtime.MessageSender["frameId"], PageDetail>
|
||||||
|
>;
|
||||||
|
|
||||||
|
type SubFrameOffsetData = {
|
||||||
|
url: string;
|
||||||
|
top: number;
|
||||||
|
left: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SubFrameOffsetsForTab = Record<
|
||||||
|
chrome.runtime.MessageSender["tab"]["id"],
|
||||||
|
Map<chrome.runtime.MessageSender["frameId"], SubFrameOffsetData>
|
||||||
|
>;
|
||||||
|
|
||||||
type WebsiteIconData = {
|
type WebsiteIconData = {
|
||||||
imageEnabled: boolean;
|
imageEnabled: boolean;
|
||||||
image: string;
|
image: string;
|
||||||
@@ -73,7 +90,7 @@ type OverlayBackgroundExtensionMessageHandlers = {
|
|||||||
focusAutofillOverlayList: () => void;
|
focusAutofillOverlayList: () => void;
|
||||||
updateAutofillOverlayPosition: ({ message }: BackgroundMessageParam) => void;
|
updateAutofillOverlayPosition: ({ message }: BackgroundMessageParam) => void;
|
||||||
updateAutofillOverlayHidden: ({ message }: BackgroundMessageParam) => void;
|
updateAutofillOverlayHidden: ({ message }: BackgroundMessageParam) => void;
|
||||||
updateFocusedFieldData: ({ message }: BackgroundMessageParam) => void;
|
updateFocusedFieldData: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
collectPageDetailsResponse: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
collectPageDetailsResponse: ({ message, sender }: BackgroundOnMessageHandlerParams) => void;
|
||||||
unlockCompleted: ({ message }: BackgroundMessageParam) => void;
|
unlockCompleted: ({ message }: BackgroundMessageParam) => void;
|
||||||
addEditCipherSubmitted: () => void;
|
addEditCipherSubmitted: () => void;
|
||||||
@@ -116,6 +133,9 @@ interface OverlayBackground {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
PageDetailsForTab,
|
||||||
|
SubFrameOffsetData,
|
||||||
|
SubFrameOffsetsForTab,
|
||||||
WebsiteIconData,
|
WebsiteIconData,
|
||||||
OverlayBackgroundExtensionMessage,
|
OverlayBackgroundExtensionMessage,
|
||||||
OverlayPortMessage,
|
OverlayPortMessage,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
openViewVaultItemPopout,
|
openViewVaultItemPopout,
|
||||||
openAddEditVaultItemPopout,
|
openAddEditVaultItemPopout,
|
||||||
} from "../../vault/popup/utils/vault-popout-window";
|
} from "../../vault/popup/utils/vault-popout-window";
|
||||||
import { AutofillService, PageDetail } from "../services/abstractions/autofill.service";
|
import { AutofillService } from "../services/abstractions/autofill.service";
|
||||||
import { AutofillOverlayElement, AutofillOverlayPort } from "../utils/autofill-overlay.enum";
|
import { AutofillOverlayElement, AutofillOverlayPort } from "../utils/autofill-overlay.enum";
|
||||||
|
|
||||||
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
import { LockedVaultPendingNotificationsData } from "./abstractions/notification.background";
|
||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
OverlayAddNewItemMessage,
|
OverlayAddNewItemMessage,
|
||||||
OverlayPortMessage,
|
OverlayPortMessage,
|
||||||
WebsiteIconData,
|
WebsiteIconData,
|
||||||
|
PageDetailsForTab,
|
||||||
} from "./abstractions/overlay.background";
|
} from "./abstractions/overlay.background";
|
||||||
|
|
||||||
class OverlayBackground implements OverlayBackgroundInterface {
|
class OverlayBackground implements OverlayBackgroundInterface {
|
||||||
@@ -47,10 +48,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
private readonly openViewVaultItemPopout = openViewVaultItemPopout;
|
private readonly openViewVaultItemPopout = openViewVaultItemPopout;
|
||||||
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
private readonly openAddEditVaultItemPopout = openAddEditVaultItemPopout;
|
||||||
private overlayLoginCiphers: Map<string, CipherView> = new Map();
|
private overlayLoginCiphers: Map<string, CipherView> = new Map();
|
||||||
private pageDetailsForTab: Record<
|
private pageDetailsForTab: PageDetailsForTab = {};
|
||||||
chrome.runtime.MessageSender["tab"]["id"],
|
|
||||||
Map<chrome.runtime.MessageSender["frameId"], PageDetail>
|
|
||||||
> = {};
|
|
||||||
private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut;
|
private userAuthStatus: AuthenticationStatus = AuthenticationStatus.LoggedOut;
|
||||||
private overlayButtonPort: chrome.runtime.Port;
|
private overlayButtonPort: chrome.runtime.Port;
|
||||||
private overlayListPort: chrome.runtime.Port;
|
private overlayListPort: chrome.runtime.Port;
|
||||||
@@ -66,7 +64,7 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
focusAutofillOverlayList: () => this.focusOverlayList(),
|
focusAutofillOverlayList: () => this.focusOverlayList(),
|
||||||
updateAutofillOverlayPosition: ({ message }) => this.updateOverlayPosition(message),
|
updateAutofillOverlayPosition: ({ message }) => this.updateOverlayPosition(message),
|
||||||
updateAutofillOverlayHidden: ({ message }) => this.updateOverlayHidden(message),
|
updateAutofillOverlayHidden: ({ message }) => this.updateOverlayHidden(message),
|
||||||
updateFocusedFieldData: ({ message }) => this.setFocusedFieldData(message),
|
updateFocusedFieldData: ({ message, sender }) => this.setFocusedFieldData(message, sender),
|
||||||
collectPageDetailsResponse: ({ message, sender }) => this.storePageDetails(message, sender),
|
collectPageDetailsResponse: ({ message, sender }) => this.storePageDetails(message, sender),
|
||||||
unlockCompleted: ({ message }) => this.unlockCompleted(message),
|
unlockCompleted: ({ message }) => this.unlockCompleted(message),
|
||||||
addEditCipherSubmitted: () => this.updateOverlayCiphers(),
|
addEditCipherSubmitted: () => this.updateOverlayCiphers(),
|
||||||
@@ -220,6 +218,10 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
pageDetailsMap.set(sender.frameId, pageDetails);
|
pageDetailsMap.set(sender.frameId, pageDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildFrameOffset(frameId: number, tabId: number) {
|
||||||
|
return frameId ? 10 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggers autofill for the selected cipher in the overlay list. Also places
|
* Triggers autofill for the selected cipher in the overlay list. Also places
|
||||||
* the selected cipher at the top of the list of ciphers.
|
* the selected cipher at the top of the list of ciphers.
|
||||||
@@ -396,7 +398,10 @@ class OverlayBackground implements OverlayBackgroundInterface {
|
|||||||
*
|
*
|
||||||
* @param focusedFieldData - Contains the rects and styles of the focused field.
|
* @param focusedFieldData - Contains the rects and styles of the focused field.
|
||||||
*/
|
*/
|
||||||
private setFocusedFieldData({ focusedFieldData }: OverlayBackgroundExtensionMessage) {
|
private setFocusedFieldData(
|
||||||
|
{ focusedFieldData }: OverlayBackgroundExtensionMessage,
|
||||||
|
sender: chrome.runtime.MessageSender,
|
||||||
|
) {
|
||||||
this.focusedFieldData = focusedFieldData;
|
this.focusedFieldData = focusedFieldData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1087,6 +1087,10 @@ class AutofillOverlayContentService implements AutofillOverlayContentServiceInte
|
|||||||
* @param element - The element to get the root node active element for.
|
* @param element - The element to get the root node active element for.
|
||||||
*/
|
*/
|
||||||
private getRootNodeActiveElement(element: Element): Element {
|
private getRootNodeActiveElement(element: Element): Element {
|
||||||
|
if (!element) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const documentRoot = element.getRootNode() as ShadowRoot | Document;
|
const documentRoot = element.getRootNode() as ShadowRoot | Document;
|
||||||
return documentRoot?.activeElement;
|
return documentRoot?.activeElement;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,8 @@
|
|||||||
"http://*/*",
|
"http://*/*",
|
||||||
"https://*/*",
|
"https://*/*",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking"
|
"webRequestBlocking",
|
||||||
|
"webNavigation"
|
||||||
],
|
],
|
||||||
"optional_permissions": ["nativeMessaging", "privacy"],
|
"optional_permissions": ["nativeMessaging", "privacy"],
|
||||||
"content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'",
|
"content_security_policy": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'",
|
||||||
|
|||||||
Reference in New Issue
Block a user