From 828e187dc49899f5442a6fd36b4c96ff9eb7e32b Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Wed, 1 May 2024 00:37:51 -0500 Subject: [PATCH] [PM-5189] Add a fallback for image assets that do not load correctly --- .../content/autofill-overlay-inline-menu-elements.ts | 2 ++ .../autofill/overlay/pages/list/autofill-overlay-list.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/apps/browser/src/autofill/overlay/content/autofill-overlay-inline-menu-elements.ts b/apps/browser/src/autofill/overlay/content/autofill-overlay-inline-menu-elements.ts index cec2f56994..11b57cfc15 100644 --- a/apps/browser/src/autofill/overlay/content/autofill-overlay-inline-menu-elements.ts +++ b/apps/browser/src/autofill/overlay/content/autofill-overlay-inline-menu-elements.ts @@ -79,6 +79,8 @@ export class AutofillOverlayInlineMenuElements implements InlineMenuElementsInte * longer triggers. */ private removeInlineMenu = (message?: AutofillExtensionMessage) => { + return; + if (message?.overlayElement === AutofillOverlayElement.Button) { this.removeInlineMenuButton(); return; diff --git a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts index ac5a7e3ef0..8b10dafd96 100644 --- a/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts +++ b/apps/browser/src/autofill/overlay/pages/list/autofill-overlay-list.ts @@ -397,6 +397,15 @@ class AutofillOverlayList extends AutofillOverlayPageElement { try { const url = new URL(cipher.icon.image); cipherIcon.style.backgroundImage = `url(${url.href})`; + + const dummyImageElement = globalThis.document.createElement("img"); + dummyImageElement.src = url.href; + dummyImageElement.addEventListener("error", () => { + cipherIcon.style.backgroundImage = ""; + cipherIcon.classList.add("cipher-icon", "bwi", cipher.icon.icon); + }); + dummyImageElement.remove(); + return cipherIcon; } catch { // Silently default to the globe icon element if the image URL is invalid