From caa998c5b15f2112c26f025d3238ddf1ff57cb88 Mon Sep 17 00:00:00 2001 From: Cesar Gonzalez Date: Thu, 15 Feb 2024 12:10:45 -0600 Subject: [PATCH] [PM-5639] Fix Safari Window Popouts Issues When Manually Locking Extension (#7953) * [PM-5639] Safari Browser Shows Issues When Manually Locking Extension * [PM-5639] Safari Browser Shows Issues When Manually Locking Extension --- .../content/content-message-handler.ts | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/apps/browser/src/autofill/content/content-message-handler.ts b/apps/browser/src/autofill/content/content-message-handler.ts index 05e87c2da8..0cb9f45b43 100644 --- a/apps/browser/src/autofill/content/content-message-handler.ts +++ b/apps/browser/src/autofill/content/content-message-handler.ts @@ -34,9 +34,9 @@ const windowMessageHandlers: ContentMessageWindowEventHandlers = { * @param data - Data from the window message * @param referrer - The referrer of the window */ -async function handleAuthResultMessage(data: ContentMessageWindowData, referrer: string) { +function handleAuthResultMessage(data: ContentMessageWindowData, referrer: string) { const { command, lastpass, code, state } = data; - await chrome.runtime.sendMessage({ command, code, state, lastpass, referrer }); + sendExtensionRuntimeMessage({ command, code, state, lastpass, referrer }); } /** @@ -47,7 +47,7 @@ async function handleAuthResultMessage(data: ContentMessageWindowData, referrer: */ async function handleDuoResultMessage(data: ContentMessageWindowData, referrer: string) { const { command, code, state } = data; - await chrome.runtime.sendMessage({ command, code, state, referrer }); + sendExtensionRuntimeMessage({ command, code, state, referrer }); } /** @@ -56,9 +56,9 @@ async function handleDuoResultMessage(data: ContentMessageWindowData, referrer: * @param data - Data from the window message * @param referrer - The referrer of the window */ -async function handleWebAuthnResultMessage(data: ContentMessageWindowData, referrer: string) { +function handleWebAuthnResultMessage(data: ContentMessageWindowData, referrer: string) { const { command, remember } = data; - await chrome.runtime.sendMessage({ command, data: data.data, remember, referrer }); + sendExtensionRuntimeMessage({ command, data: data.data, remember, referrer }); } /** @@ -96,12 +96,23 @@ const forwardCommands = new Set([ * * @param message - The message from the extension */ -async function handleExtensionMessage(message: any) { +function handleExtensionMessage(message: any) { if (forwardCommands.has(message.command)) { - await chrome.runtime.sendMessage(message); + sendExtensionRuntimeMessage(message); } } +/** + * Sends a message to the extension runtime, and ignores + * any potential promises that should be handled using + * the `void` operator. + * + * @param message - The message to send to the extension runtime + */ +function sendExtensionRuntimeMessage(message: any) { + void chrome.runtime.sendMessage(message); +} + /** * Duplicate implementation of the same named method within `apps/browser/src/autofill/utils/index.ts`. * This is done due to some strange observed compilation behavior present when importing the method from