From f78831b4c2482e646d1bf5110a9f2b6b52fb819b Mon Sep 17 00:00:00 2001 From: Graham Langford <30706330+grahamlangford@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:31:02 -0500 Subject: [PATCH] #8933: adds mousedown handler to solve document mousedown handler bug (#8931) * adds mousedown handler to solve document mousedown handler bug * explain the mousedown event --- src/contentScript/focusCaptureDialog.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/contentScript/focusCaptureDialog.ts b/src/contentScript/focusCaptureDialog.ts index 15f05e5efa..1da1a97485 100644 --- a/src/contentScript/focusCaptureDialog.ts +++ b/src/contentScript/focusCaptureDialog.ts @@ -63,6 +63,13 @@ async function rawFocusCaptureDialog({ dialog.showModal(); const anyPromiseWillCloseTheDialog = [ + // In Chrome 127.0.6533.73, the `chrome.sidePanel.open()` API started throwing user gesture errors + // when a message from the content script was sent to the background script. + // The root cause appears to be a registered mousedown handler on the document that sends a message + // Adding `mousedown` here ensures that the sidePanel.open call is made before the message for the mousedown + // handler on the document is sent. + // See https://issues.chromium.org/issues/355266358 for more details. + oneEvent(button, "mousedown"), oneEvent(button, "click"), oneEvent(dialog, "cancel"), onContextInvalidated.promise,