Bug 1950734 - Make MSIX builds skip the AUMID altering steps in taskbar pinning as it's unnecessary r=nrishel
Differential Revision: https://phabricator.services.mozilla.com/D239827
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/WinHeaderOnlyUtils.h"
|
#include "mozilla/WinHeaderOnlyUtils.h"
|
||||||
#include "mozilla/widget/WinTaskbar.h"
|
#include "mozilla/widget/WinTaskbar.h"
|
||||||
|
#include "WinUtils.h"
|
||||||
|
|
||||||
#include "mozilla/Logging.h"
|
#include "mozilla/Logging.h"
|
||||||
|
|
||||||
@@ -213,21 +214,27 @@ Win11PinToTaskBarResult PinCurrentAppToTaskbarWin11(
|
|||||||
primaryAumid = nsString(primaryAumid)](
|
primaryAumid = nsString(primaryAumid)](
|
||||||
Win11PinToTaskBarResultStatus status) {
|
Win11PinToTaskBarResultStatus status) {
|
||||||
// Set AUMID back and ensure the icon is set correctly
|
// Set AUMID back and ensure the icon is set correctly
|
||||||
HRESULT hr =
|
if (!widget::WinUtils::HasPackageIdentity()) {
|
||||||
SetCurrentProcessExplicitAppUserModelID(primaryAumid.get());
|
HRESULT hr =
|
||||||
if (FAILED(hr)) {
|
SetCurrentProcessExplicitAppUserModelID(primaryAumid.get());
|
||||||
TASKBAR_PINNING_LOG(LogLevel::Debug,
|
if (FAILED(hr)) {
|
||||||
"Taskbar: reverting AUMID after pinning "
|
TASKBAR_PINNING_LOG(LogLevel::Debug,
|
||||||
"operation failed. HRESULT = 0x%lx",
|
"Taskbar: reverting AUMID after pinning "
|
||||||
hr);
|
"operation failed. HRESULT = 0x%lx",
|
||||||
|
hr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resultStatus = status;
|
resultStatus = status;
|
||||||
event.Set();
|
event.Set();
|
||||||
};
|
};
|
||||||
|
|
||||||
hr = SetCurrentProcessExplicitAppUserModelID(aumid.get());
|
// Set the process to have the AUMID of the shortcut we want to pin,
|
||||||
if (FAILED(hr)) {
|
// this is only necessary for Win32 builds
|
||||||
return CompletedOperations(Win11PinToTaskBarResultStatus::Failed);
|
if (!widget::WinUtils::HasPackageIdentity()) {
|
||||||
|
hr = SetCurrentProcessExplicitAppUserModelID(aumid.get());
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return CompletedOperations(Win11PinToTaskBarResultStatus::Failed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ComPtr<ITaskbarManager> taskbar;
|
ComPtr<ITaskbarManager> taskbar;
|
||||||
@@ -264,13 +271,15 @@ Win11PinToTaskBarResult PinCurrentAppToTaskbarWin11(
|
|||||||
[&event, &resultStatus,
|
[&event, &resultStatus,
|
||||||
primaryAumid](Win11PinToTaskBarResultStatus status) -> HRESULT {
|
primaryAumid](Win11PinToTaskBarResultStatus status) -> HRESULT {
|
||||||
// Set AUMID back and ensure the icon is set correctly
|
// Set AUMID back and ensure the icon is set correctly
|
||||||
HRESULT hr =
|
if (!widget::WinUtils::HasPackageIdentity()) {
|
||||||
SetCurrentProcessExplicitAppUserModelID(primaryAumid.get());
|
HRESULT hr =
|
||||||
if (FAILED(hr)) {
|
SetCurrentProcessExplicitAppUserModelID(primaryAumid.get());
|
||||||
TASKBAR_PINNING_LOG(LogLevel::Debug,
|
if (FAILED(hr)) {
|
||||||
"Taskbar: reverting AUMID after pinning "
|
TASKBAR_PINNING_LOG(LogLevel::Debug,
|
||||||
"operation failed. HRESULT = 0x%lx",
|
"Taskbar: reverting AUMID after pinning "
|
||||||
hr);
|
"operation failed. HRESULT = 0x%lx",
|
||||||
|
hr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resultStatus = status;
|
resultStatus = status;
|
||||||
event.Set();
|
event.Set();
|
||||||
|
|||||||
@@ -424,6 +424,16 @@ interface nsIWindowsShellService : nsIShellService
|
|||||||
boolean checkAllProgIDsExist();
|
boolean checkAllProgIDsExist();
|
||||||
boolean checkBrowserUserChoiceHashes();
|
boolean checkBrowserUserChoiceHashes();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieves the application-defined, explicit Application User Model ID
|
||||||
|
* for the current process. This function is only to be used on
|
||||||
|
* Windows for testing purposes
|
||||||
|
*
|
||||||
|
* @return string AUMID
|
||||||
|
* @throws NS_ERROR_FAILURE when the AUMID cannot be fetched
|
||||||
|
*/
|
||||||
|
AString checkCurrentProcessAUMIDForTesting();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determines whether or not Firefox is the "Default Handler", i.e.,
|
* Determines whether or not Firefox is the "Default Handler", i.e.,
|
||||||
* is registered to handle, the given file extension (like ".pdf")
|
* is registered to handle, the given file extension (like ".pdf")
|
||||||
|
|||||||
@@ -377,6 +377,21 @@ nsWindowsShellService::CheckBrowserUserChoiceHashes(bool* aResult) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsWindowsShellService::CheckCurrentProcessAUMIDForTesting(
|
||||||
|
nsAString& aRetAumid) {
|
||||||
|
PWSTR id;
|
||||||
|
HRESULT hr = GetCurrentProcessExplicitAppUserModelID(&id);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
aRetAumid.Assign(id);
|
||||||
|
CoTaskMemFree(id);
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsWindowsShellService::CanSetDefaultBrowserUserChoice(bool* aResult) {
|
nsWindowsShellService::CanSetDefaultBrowserUserChoice(bool* aResult) {
|
||||||
*aResult = false;
|
*aResult = false;
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ skip-if = [
|
|||||||
run-if = ["os == 'win'"]
|
run-if = ["os == 'win'"]
|
||||||
tags = "os_integration"
|
tags = "os_integration"
|
||||||
|
|
||||||
|
["browser_processAUMID.js"]
|
||||||
|
run-if = ["os == 'win'"]
|
||||||
|
|
||||||
["browser_setDefaultBrowser.js"]
|
["browser_setDefaultBrowser.js"]
|
||||||
tags = "os_integration"
|
tags = "os_integration"
|
||||||
|
|
||||||
|
|||||||
27
browser/components/shell/test/browser_processAUMID.js
Normal file
27
browser/components/shell/test/browser_processAUMID.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* Any copyright is dedicated to the Public Domain.
|
||||||
|
* https://creativecommons.org/publicdomain/zero/1.0/ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bug 1950734 tracks how calling PinCurrentAppToTaskbarWin11
|
||||||
|
* on MSIX may cause the process AUMID to be unnecessarily changed.
|
||||||
|
* This test verifies that the behaviour will no longer happen
|
||||||
|
*/
|
||||||
|
|
||||||
|
ChromeUtils.defineESModuleGetters(this, {
|
||||||
|
ShellService: "resource:///modules/ShellService.sys.mjs",
|
||||||
|
});
|
||||||
|
|
||||||
|
add_task(async function test_processAUMID() {
|
||||||
|
let processAUMID = ShellService.checkCurrentProcessAUMIDForTesting();
|
||||||
|
|
||||||
|
// This function will trigger the relevant code paths that
|
||||||
|
// incorrectly changes the process AUMID on MSIX, prior to
|
||||||
|
// Bug 1950734 being fixed
|
||||||
|
await ShellService.checkPinCurrentAppToTaskbarAsync(false);
|
||||||
|
|
||||||
|
is(
|
||||||
|
processAUMID,
|
||||||
|
ShellService.checkCurrentProcessAUMIDForTesting(),
|
||||||
|
"The process AUMID should not be changed"
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user