mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1696444 - Pin Firefox only if not already pinned to avoid changing taskbar icon r=andreio
Differential Revision: https://phabricator.services.mozilla.com/D108998
This commit is contained in:
parent
28ae6f7fa7
commit
c7db79e50c
@ -84,13 +84,17 @@ const SpecialMessageActions = {
|
||||
*
|
||||
* @param {Window} window Reference to a window object
|
||||
*/
|
||||
pinFirefoxToTaskbar(window) {
|
||||
async pinFirefoxToTaskbar(window) {
|
||||
try {
|
||||
// Currently this only works on certain Windows versions.
|
||||
window
|
||||
const shell = window
|
||||
.getShellService()
|
||||
.QueryInterface(Ci.nsIWindowsShellService)
|
||||
.pinCurrentAppToTaskbar();
|
||||
.QueryInterface(Ci.nsIWindowsShellService);
|
||||
|
||||
// Avoid re-pinning as that causes the taskbar icon to change.
|
||||
if (!(await shell.isCurrentAppPinnedToTaskbarAsync())) {
|
||||
shell.pinCurrentAppToTaskbar();
|
||||
}
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
|
@ -321,6 +321,18 @@
|
||||
"additionalProperties": false,
|
||||
"description": "Dismiss DOH doorhanger notification"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["PIN_FIREFOX_TO_TASKBAR"]
|
||||
}
|
||||
},
|
||||
"required": ["type"],
|
||||
"additionalProperties": false,
|
||||
"description": "Pin the app to taskbar"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
@ -12,6 +12,7 @@ support-files =
|
||||
[browser_sma_open_protection_report.js]
|
||||
[browser_sma_open_url.js]
|
||||
[browser_sma_pin_current_tab.js]
|
||||
[browser_sma_pin_firefox.js]
|
||||
[browser_sma_show_firefox_accounts.js]
|
||||
[browser_sma_show_migration_wizard.js]
|
||||
[browser_sma.js]
|
||||
|
@ -0,0 +1,48 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
add_task(async function test_PIN_FIREFOX_TO_TASKBAR() {
|
||||
const sandbox = sinon.createSandbox();
|
||||
const shell = {
|
||||
QueryInterface: () => shell,
|
||||
isCurrentAppPinnedToTaskbarAsync: sandbox.stub(),
|
||||
pinCurrentAppToTaskbar: sandbox.stub(),
|
||||
};
|
||||
|
||||
const test = () =>
|
||||
SMATestUtils.executeAndValidateAction(
|
||||
{ type: "PIN_FIREFOX_TO_TASKBAR" },
|
||||
{
|
||||
ownerGlobal: {
|
||||
getShellService: () => shell,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await test();
|
||||
Assert.equal(
|
||||
shell.pinCurrentAppToTaskbar.callCount,
|
||||
1,
|
||||
"pinCurrentAppToTaskbar was called by the action"
|
||||
);
|
||||
|
||||
// Pretend the app is already pinned.
|
||||
shell.isCurrentAppPinnedToTaskbarAsync.resolves(true);
|
||||
await test();
|
||||
Assert.equal(
|
||||
shell.pinCurrentAppToTaskbar.callCount,
|
||||
1,
|
||||
"pinCurrentAppToTaskbar was not called by the action"
|
||||
);
|
||||
|
||||
// Pretend the app became unpinned.
|
||||
shell.isCurrentAppPinnedToTaskbarAsync.resolves(false);
|
||||
await test();
|
||||
Assert.equal(
|
||||
shell.pinCurrentAppToTaskbar.callCount,
|
||||
2,
|
||||
"pinCurrentAppToTaskbar was called again by the action"
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user