From 948a64f4c19c676291ea0fe03845224955c967b7 Mon Sep 17 00:00:00 2001 From: Toshihito Kikuchi Date: Tue, 12 Nov 2019 19:36:50 +0000 Subject: [PATCH] Bug 1592444 - Allow E_ACCESSDENIED from CoAllowSetForegroundWindow in debug build. r=aklotz Bug 1588500 reported some of Thunderbird's tests failed because `CoAllowSetForegroundWindow` failed. In that case, those tests should not launch a default browser of the system, but we should allow `E_ACCESSDENIED` because it legitimately happens if the window is not in the foreground. Differential Revision: https://phabricator.services.mozilla.com/D52618 --HG-- extra : moz-landing-system : lando --- widget/windows/ShellHeaderOnlyUtils.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/widget/windows/ShellHeaderOnlyUtils.h b/widget/windows/ShellHeaderOnlyUtils.h index 07ac6777fa0f..ddc7a914f51e 100644 --- a/widget/windows/ShellHeaderOnlyUtils.h +++ b/widget/windows/ShellHeaderOnlyUtils.h @@ -126,10 +126,11 @@ inline LauncherVoidResult ShellExecuteByExplorer(const _bstr_t& aPath, } // Passing the foreground privilege so that the shell can launch an - // application in the foreground. If CoAllowSetForegroundWindow fails, - // we continue because it's not fatal. + // application in the foreground. This fails with E_ACCESSDENIED if the + // current window is shown in the background. We keep a soft assert for + // the other failures to investigate how it happened. hr = ::CoAllowSetForegroundWindow(shellDisp, nullptr); - MOZ_ASSERT(SUCCEEDED(hr)); + MOZ_ASSERT(SUCCEEDED(hr) || hr == E_ACCESSDENIED); // shellapi.h macros interfere with the correct naming of the method being // called on IShellDispatch2. Temporarily remove that definition.