From 64e577e2e6480ea1d35962b410aaf5fa71ff4e06 Mon Sep 17 00:00:00 2001 From: Miles Blackwood Date: Thu, 12 Jun 2025 17:15:16 -0400 Subject: [PATCH] Failsafe for Chromium browsers' forced rendering of opaque bkgd (#15098) --- apps/browser/src/autofill/notification/bar.ts | 11 ++++++++++- ...notifications-content.service.spec.ts.snap | 2 +- .../overlay-notifications-content.service.ts | 9 +++++++-- apps/browser/src/autofill/utils/index.ts | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/apps/browser/src/autofill/notification/bar.ts b/apps/browser/src/autofill/notification/bar.ts index 285ae4aa25..a83e9fce53 100644 --- a/apps/browser/src/autofill/notification/bar.ts +++ b/apps/browser/src/autofill/notification/bar.ts @@ -12,7 +12,7 @@ import { NotificationConfirmationContainer } from "../content/components/notific import { NotificationContainer } from "../content/components/notification/container"; import { selectedFolder as selectedFolderSignal } from "../content/components/signals/selected-folder"; import { selectedVault as selectedVaultSignal } from "../content/components/signals/selected-vault"; -import { buildSvgDomElement } from "../utils"; +import { buildSvgDomElement, matchAllowedColorSchemes } from "../utils"; import { circleCheckIcon } from "../utils/svg-icons"; import { @@ -238,6 +238,15 @@ async function initNotificationBar(message: NotificationBarWindowMessage) { const i18n = getI18n(); const resolvedTheme = getResolvedTheme(theme ?? ThemeTypes.Light); + // https://drafts.csswg.org/css-color-adjust-1/#preferred + // Prevents preferred color scheme from forcing an opaque background in the iframe + const colorScheme = new URLSearchParams(window.location.search).get("colorScheme") || ""; + const allowedColorScheme = matchAllowedColorSchemes(colorScheme); + const meta = document.createElement("meta"); + meta.setAttribute("name", "color-scheme"); + meta.setAttribute("content", allowedColorScheme); + document.getElementsByTagName("head")[0].appendChild(meta); + if (useComponentBar) { const resolvedType = resolveNotificationType(notificationBarIframeInitData); const headerMessage = getNotificationHeaderMessage(i18n, resolvedType); diff --git a/apps/browser/src/autofill/overlay/notifications/content/__snapshots__/overlay-notifications-content.service.spec.ts.snap b/apps/browser/src/autofill/overlay/notifications/content/__snapshots__/overlay-notifications-content.service.spec.ts.snap index c20626212f..1b5d9a7388 100644 --- a/apps/browser/src/autofill/overlay/notifications/content/__snapshots__/overlay-notifications-content.service.spec.ts.snap +++ b/apps/browser/src/autofill/overlay/notifications/content/__snapshots__/overlay-notifications-content.service.spec.ts.snap @@ -7,7 +7,7 @@ exports[`OverlayNotificationsContentService opening the notification bar creates >