From d798a8796a9970bbbadee9c79025c956012c3a11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 17 Oct 2022 20:04:14 +0000 Subject: [PATCH] Bug 1793829 - Don't steal focus for navigations without user activation. r=hsivonen Differential Revision: https://phabricator.services.mozilla.com/D158758 --- docshell/base/nsDocShell.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 6b6900e6f809..0a029957c823 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -9223,7 +9223,9 @@ static bool NavigationShouldTakeFocus(nsDocShell* aDocShell, if (!aLoadState->AllowFocusMove()) { return false; } - + if (!aLoadState->HasValidUserGestureActivation()) { + return false; + } const auto& sourceBC = aLoadState->SourceBrowsingContext(); if (!sourceBC || !sourceBC->IsActive()) { // If the navigation didn't come from a foreground tab, then we don't steal