Bug 1716884 - Allow experimenting with disabling Keep in Dock / Pin to taskbar r=andreio

Add new NimbusFeature.shellService that is available at startup, e.g., for default browser prompt.

Differential Revision: https://phabricator.services.mozilla.com/D118092
This commit is contained in:
Ed Lee
2021-06-17 23:44:38 +00:00
parent c5e0b83a15
commit 0920a773c8
4 changed files with 69 additions and 7 deletions

View File

@@ -13,15 +13,11 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"WindowsRegistry",
"resource://gre/modules/WindowsRegistry.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
Subprocess: "resource://gre/modules/Subprocess.jsm",
NimbusFeatures: "resource://nimbus/ExperimentAPI.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
Subprocess: "resource://gre/modules/Subprocess.jsm",
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
});
XPCOMUtils.defineLazyServiceGetter(
@@ -277,6 +273,11 @@ let ShellServiceInternal = {
);
}
// Pretend pinning is not needed/supported if remotely disabled.
if (NimbusFeatures.shellService.getVariable("disablePin")) {
return false;
}
// Currently this only works on certain Windows versions.
try {
// First check if we can even pin the app where an exception means no.

View File

@@ -8,6 +8,7 @@ skip-if = os != "linux"
support-files =
mac_desktop_image.py
skip-if = os != "mac" || verify
[browser_doesAppNeedPin.js]
[browser_setDesktopBackgroundPreview.js]
[browser_headless_screenshot_1.js]
support-files =

View File

@@ -0,0 +1,51 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
const { ExperimentFakes } = ChromeUtils.import(
"resource://testing-common/NimbusTestUtils.jsm"
);
const { NimbusFeatures } = ChromeUtils.import(
"resource://nimbus/ExperimentAPI.jsm"
);
let defaultValue;
add_task(async function default_need() {
defaultValue = await ShellService.doesAppNeedPin();
Assert.ok(defaultValue !== undefined, "Got a default app need pin value");
});
add_task(async function remote_disable() {
if (defaultValue === false) {
info("Default pin already false, so nothing to test");
return;
}
await ExperimentFakes.remoteDefaultsHelper({
feature: NimbusFeatures.shellService,
configuration: { variables: { disablePin: true } },
});
Assert.equal(
await ShellService.doesAppNeedPin(),
false,
"Pinning disabled via nimbus"
);
});
add_task(async function restore_default() {
if (defaultValue === undefined) {
info("No default pin value set, so nothing to test");
return;
}
await ExperimentFakes.remoteDefaultsHelper({
feature: NimbusFeatures.shellService,
configuration: {},
});
Assert.equal(
await ShellService.doesAppNeedPin(),
defaultValue,
"Pinning restored to original"
);
});

View File

@@ -115,6 +115,15 @@ const FeatureManifest = {
},
},
},
shellService: {
description: "Interface with OS, e.g., pinning and set default",
isEarlyStartup: true,
variables: {
disablePin: {
type: "boolean",
},
},
},
upgradeDialog: {
description: "The dialog shown for major upgrades",
isEarlyStartup: true,